Package i5.las2peer.tools
Class CommandPrompt
java.lang.Object
i5.las2peer.tools.CommandPrompt
A simple command line for executing commands, generating new instances and handling local variables.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration for different return status codes of executed lines. -
Constructor Summary
ConstructorDescriptioncreate a new unbound promptCommandPrompt
(Object boundTo) create a new prompt bound to the given object -
Method Summary
Modifier and TypeMethodDescriptionhandleAssignment
(String line) handle an assignment commandhandleCommand
(String command) handle a command, i.e.handleLine
(String line) handle a line of inputhandle a NEW command, e.g.handlePrint
(String line) print the value of all given local variableslocalCommand
(String line) check, if the given line contains (starts with) a local command and execute it.static void
start a command linevoid
print the last caught exception / throwablevoid
print a help messagevoid
Prints the las2peer version.prompt()
print a simple prompt and wait for inputvoid
loop through input and execution
-
Constructor Details
-
CommandPrompt
public CommandPrompt()create a new unbound prompt -
CommandPrompt
create a new prompt bound to the given object- Parameters:
boundTo
-
-
-
Method Details
-
handleAssignment
handle an assignment command- Parameters:
line
-- Returns:
- status code
-
handleNew
handle a NEW command, e.g. try to create a new instance of the given class with the possibly given parameters- Parameters:
command
-- Returns:
- result of the new instantiation
- Throws:
Exception
-
handleCommand
handle a command, i.e. a static method or a class method of a local variable or the bound object- Parameters:
command
-- Returns:
- result of the invoked operation
- Throws:
Exception
-
handleLine
handle a line of input- Parameters:
line
-- Returns:
- return status code
-
printException
public void printException()print the last caught exception / throwable -
handlePrint
print the value of all given local variables- Parameters:
line
-- Returns:
- return status code
-
localCommand
check, if the given line contains (starts with) a local command and execute it.- Parameters:
line
-- Returns:
- return status code
-
printHelp
public void printHelp()print a help message -
printVersion
public void printVersion()Prints the las2peer version. -
prompt
print a simple prompt and wait for input- Returns:
- return status code
-
startPrompt
public void startPrompt()loop through input and execution -
main
start a command line- Parameters:
argv
-- Throws:
ClassNotFoundException
-