|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectprotoj.core.Command
public final class Command
Represents a unit of work to be carried out by the project. A command consists of two parts:
execute(Instruction) method checks for the existence
of the BODY command line options. If it isn't present the command
will bootstrap to a new vm, but with the BODY option added. If the BODY
option does exist then the body will be executed.
| Constructor Summary | |
|---|---|
Command(CommandStore store,
java.lang.String name,
java.lang.String description,
java.lang.String memory,
java.lang.Runnable body)
Creates a command with an associated body that will execute in another instance of the current vm. |
|
| Method Summary | |
|---|---|
boolean |
containsAlias(java.lang.String alias)
Convenience method that checks whether or not the given alias is known to this command. |
void |
execute(Instruction instruction)
Executes this command using the given specified instruction that usually originates from the command line. |
java.util.List<java.lang.String> |
getAliases()
A read-only list of all the names this command is known by. |
java.lang.String |
getAliasText()
Reports the aliases available, useful for help text. |
java.lang.String |
getDescription()
A description useful for help text. |
java.lang.String |
getHelpText()
Builds a message suitable for displaying in response to a help command. |
java.lang.String |
getInstructionText()
Includes both the command name and arguments, if any, that make up the full definition of the command. |
java.lang.String |
getMemory()
The maximum amount of memory that the forked vm will be able to claim. |
java.lang.String |
getName()
The unique name of this command. |
joptsimple.OptionSet |
getOptions()
The helper responsible for parsing the command line arguments. |
joptsimple.OptionParser |
getParser()
Use in order to configure the command line options for this command. |
ArgRunnable<StartVmCommand> |
getStartVmConfig()
The instance used to provide additional configuration before the vm is launched inside the startVm() method. |
CommandStore |
getStore()
A reference to the owning store. |
void |
initAliases(java.lang.String... aliases)
Optional method, specify alternate names for this command. |
void |
initBootstrapCurrentVm()
There is almost no reason to use this method since by default most commands should bootstrap to the project main. |
void |
setMemory(java.lang.String memory)
See getMemory(). |
void |
setStartVmConfig(ArgRunnable<StartVmCommand> startVmConfig)
See setStartVmConfig(ArgRunnable). |
void |
throwBadOptionsException(java.lang.String hint)
Throws an InformationException with standardized error information. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Command(CommandStore store,
java.lang.String name,
java.lang.String description,
java.lang.String memory,
java.lang.Runnable body)
store - name - description - memory - body - | Method Detail |
|---|
public void setStartVmConfig(ArgRunnable<StartVmCommand> startVmConfig)
setStartVmConfig(ArgRunnable).
startVmConfig - public ArgRunnable<StartVmCommand> getStartVmConfig()
startVm() method.
public void initAliases(java.lang.String... aliases)
aliases - public void initBootstrapCurrentVm()
public void execute(Instruction instruction)
instruction - public java.lang.String getMemory()
public void setMemory(java.lang.String memory)
getMemory().
memory - public java.lang.String getName()
public java.util.List<java.lang.String> getAliases()
public java.lang.String getDescription()
public joptsimple.OptionParser getParser()
OptionSpec<File> fileOpt = parser.accepts("f").withRequiredArg().ofType(
File.class);
The returned parser is already configured to look for the "--body" option that when specified indicates the command body is to be executed. When not specified, a new vm is to be created.
public java.lang.String getAliasText()
public joptsimple.OptionSet getOptions()
public boolean containsAlias(java.lang.String alias)
alias -
public java.lang.String getInstructionText()
public CommandStore getStore()
public java.lang.String getHelpText()
public void throwBadOptionsException(java.lang.String hint)
hint - may be null or empty if no hint is available
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||