Interface CommandInterpreter
-
public interface CommandInterpreter
A command interpreter is a shell that can interpret command lines. This object is passed as parameter when a CommandProvider is invoked.This interface is not intended to be implemented by clients.
- Since:
- 3.1
- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
execute(String cmd)
Execute a command line as if it came from the end user and return the result.String
nextArgument()
Get the next argument in the input.void
print(Object o)
Prints an object to the outputstreamvoid
printBundleResource(Bundle bundle, String resource)
Prints the given bundle resource if it existsvoid
printDictionary(Dictionary<?,?> dic, String title)
Prints the given dictionary sorted by keys.void
println()
Prints an empty line to the outputstreamvoid
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.
-
-
-
Method Detail
-
nextArgument
String nextArgument()
Get the next argument in the input. If no arguments are left then null is returned. E.g. if the commandline is hello world, the _hello method will get "world" as the first argument.- Returns:
- the next argument or null if no arguments are left.
-
execute
Object execute(String cmd)
Execute a command line as if it came from the end user and return the result.- Parameters:
cmd
- The command line to execute.- Returns:
- the result of the command.
-
print
void print(Object o)
Prints an object to the outputstream- Parameters:
o
- the object to be printed
-
println
void println()
Prints an empty line to the outputstream
-
println
void println(Object o)
Prints an object to the output medium (appended with newline character).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. That way the user of the program has control over the scrolling.
For this to work properly you should not embedded "\n" etc. into the string.
- Parameters:
o
- the object to be printed
-
printStackTrace
void printStackTrace(Throwable t)
Print a stack trace including nested exceptions.- Parameters:
t
- The offending exception
-
printDictionary
void printDictionary(Dictionary<?,?> dic, String title)
Prints the given dictionary sorted by keys.- Parameters:
dic
- the dictionary to printtitle
- the header to print above the key/value pairs
-
-