public class FrameworkCommandInterpreter extends Object implements CommandInterpreter
| Modifier and Type | Field and Description |
|---|---|
protected int |
currentLineCount
The number of lines printed without user prompt.
|
protected static int |
maxLineCount
The maximum number of lines to print without user prompt.
|
| Constructor and Description |
|---|
FrameworkCommandInterpreter(String cmdline,
CommandProvider[] commandProviders,
FrameworkConsole con)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
_more()
Toggles the use of the more prompt for displayed output.
|
protected boolean |
confirm(String string,
boolean defaultAnswer)
Prompts the user for confirmation.
|
Object |
execute(String cmd)
Execute a command line as if it came from the end user.
|
String |
getHelp(String commandName)
Answer a string (may be as many lines as you like) with help
texts that explain the command.
|
String |
nextArgument()
Get the next argument in the input.
|
void |
print(Object o)
Prints an object to the outputstream
|
void |
printBundleResource(Bundle bundle,
String resource)
Prints the given bundle resource if it exists
|
void |
printDictionary(Dictionary<?,?> dic,
String title)
Prints the given dictionary sorted by keys.
|
void |
println()
Prints a empty line to the outputstream
|
void |
println(Object o)
Prints an object to the output medium (appended with newline character).
|
void |
printStackTrace(Throwable t)
Print a stack trace including nested exceptions.
|
protected int |
prompt(String string,
int defaultAnswer)
Prompts the user for input of a positive integer.
|
protected String |
prompt(String string,
String defaultAnswer)
Prompts the user for input from the input medium providing a default value.
|
protected static int maxLineCount
protected int currentLineCount
public FrameworkCommandInterpreter(String cmdline, CommandProvider[] commandProviders, FrameworkConsole con)
public String nextArgument()
nextArgument in interface CommandInterpreterpublic Object execute(String cmd)
execute in interface CommandInterpretercmd - The name of the command to execute.public void print(Object o)
print in interface CommandInterpretero - the object to be printedpublic void println()
println in interface CommandInterpreterpublic void printStackTrace(Throwable t)
printStackTrace in interface CommandInterpretert - The offending exceptionpublic void println(Object o)
If running on the target environment, the user is prompted with '--more' if more than the configured number of lines have been printed without user prompt. This enables the user of the program to have control over scrolling.
For this to work properly you should not embed "\n" etc. into the string.
println in interface CommandInterpretero - the object to be printedpublic void printDictionary(Dictionary<?,?> dic, String title)
printDictionary in interface CommandInterpreterdic - the dictionary to printtitle - the header to print above the key/value pairspublic void printBundleResource(Bundle bundle, String resource)
printBundleResource in interface CommandInterpreterbundle - the bundle containing the resourceresource - the resource to printpublic String getHelp(String commandName)
public void _more()
throws Exception
Exceptionprotected boolean confirm(String string, boolean defaultAnswer)
string - the message to present to the user to confirmdefaultAnswer - the default resulttrue if the user confirms; false otherwise.protected String prompt(String string, String defaultAnswer)
string - the message to present to the userdefaultAnswer - the string to use as a default return valueprotected int prompt(String string, int defaultAnswer)
string - the message to present to the userdefaultAnswer - the integer to use as a default return valueCopyright © 2007–2016 The Apache Software Foundation. All rights reserved.