|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter
public class FrameworkCommandInterpreter
This class knows how to parse and execute the command line arguments to the FrameworkConsole. It attempts to pass the command to each registered CommandProvider until it finds one that knows what to do with it. FrameworkCommandInterpreter provides support for the "More" command which allows the operator to configure the number of lines to display before being prompted to continue. FrameworkCommandInterpreter provides several print methods which handle the "More" command.
Field Summary | |
---|---|
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. 0 means no user prompt is required, the window is scrollable. |
Constructor Summary | |
---|---|
FrameworkCommandInterpreter(java.lang.String cmdline,
java.lang.Object[] commandProviders,
FrameworkConsole con)
The constructor. |
Method Summary | |
---|---|
void |
_more()
Toggles the use of the more prompt for displayed output. |
protected boolean |
confirm(java.lang.String string,
boolean defaultAnswer)
Prompts the user for confirmation. |
java.lang.Object |
execute(java.lang.String cmd)
Execute a command line as if it came from the end user. |
java.lang.String |
getHelp()
Answer a string (may be as many lines as you like) with help texts that explain the command. |
java.lang.String |
nextArgument()
Get the next argument in the input. |
void |
print(java.lang.Object o)
Prints an object to the outputstream |
void |
printBundleResource(Bundle bundle,
java.lang.String resource)
Prints the given bundle resource if it exists |
void |
printDictionary(java.util.Dictionary dic,
java.lang.String title)
Prints the given dictionary sorted by keys. |
void |
println()
Prints a empty line to the outputstream |
void |
println(java.lang.Object o)
Prints an object to the output medium (appended with newline character). |
void |
printStackTrace(java.lang.Throwable t)
Print a stack trace including nested exceptions. |
protected int |
prompt(java.lang.String string,
int defaultAnswer)
Prompts the user for input of a positive integer. |
protected java.lang.String |
prompt(java.lang.String string,
java.lang.String defaultAnswer)
Prompts the user for input from the input medium providing a default value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static int maxLineCount
protected int currentLineCount
Constructor Detail |
---|
public FrameworkCommandInterpreter(java.lang.String cmdline, java.lang.Object[] commandProviders, FrameworkConsole con)
Method Detail |
---|
public java.lang.String nextArgument()
nextArgument
in interface CommandInterpreter
public java.lang.Object execute(java.lang.String cmd)
execute
in interface CommandInterpreter
cmd
- The name of the command to execute.
public void print(java.lang.Object o)
print
in interface CommandInterpreter
o
- the object to be printedpublic void println()
println
in interface CommandInterpreter
public void printStackTrace(java.lang.Throwable t)
printStackTrace
in interface CommandInterpreter
t
- The offending exceptionpublic void println(java.lang.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 CommandInterpreter
o
- the object to be printedpublic void printDictionary(java.util.Dictionary dic, java.lang.String title)
printDictionary
in interface CommandInterpreter
dic
- the dictionary to printtitle
- the header to print above the key/value pairspublic void printBundleResource(Bundle bundle, java.lang.String resource)
printBundleResource
in interface CommandInterpreter
bundle
- the bundle containing the resourceresource
- the resource to printpublic java.lang.String getHelp()
public void _more() throws java.lang.Exception
java.lang.Exception
protected boolean confirm(java.lang.String string, boolean defaultAnswer)
string
- the message to present to the user to confirmdefaultAnswer
- the default result
true
if the user confirms; false
otherwise.protected java.lang.String prompt(java.lang.String string, java.lang.String defaultAnswer)
string
- the message to present to the userdefaultAnswer
- the string to use as a default return value
protected int prompt(java.lang.String string, int defaultAnswer)
string
- the message to present to the userdefaultAnswer
- the integer to use as a default return value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |