Package mgui.command
Class CommandInstance
java.lang.Object
mgui.command.CommandInterpreter
mgui.command.CommandInstance
- Direct Known Subclasses:
DataSourceCommands
public abstract class CommandInstance extends CommandInterpreter
Class which handles command-line arguments and calls specific methods
as implemented by a sub-class.
Parameters are handled as pairs (parameter name preceded by a dash and followed by a value) or as flags (single flag parameter preceded by a dash).
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.HashMap<java.lang.Long,JavaProcess>current_processesprotected LoggingTypedefault_logging_typeprotected booleanexit_on_terminationprotected longinstance_timerprotected booleanis_interruptedprotected java.io.BufferedWriterlog_outprotected java.util.HashMap<java.lang.String,java.lang.String>parametersFields inherited from class mgui.command.CommandInterpreter
clock_start, elapsed, instance_clock_start, instance_state, success_status -
Constructor Summary
Constructors Constructor Description CommandInstance() -
Method Summary
Modifier and Type Method Description CommandFunctions.ProcessStateexecute(java.lang.String[] args)Executes a process, similar tomain, but runs as an instance, and returns the elapsed time in milliseconds.protected java.lang.StringgetCommandLine(java.lang.String[] args)Converts an array of parameters to a single space-delimited line.booleaninterrupt()Requests that the currently executing process terminateprotected booleanload_parameter_file(java.lang.String file)Loads a parameter file and populatesparameterswith it.protected voidlog(java.lang.String message)protected voidlog(java.lang.String message, LoggingType type)protected booleanoutput_help(java.net.URL resource)Reads and outputs a help file from the given URLprotected abstract booleanrun_command(java.lang.String command)Runs a single command with the current parameters.protected voidsetSuccessStatus(boolean status)protected booleanstart_log(java.lang.String file)protected booleanstop_log()Methods inherited from class mgui.command.CommandInterpreter
getInstanceTimer, getParameters, getSuccessStatus, getTimer, isNumeric, startInstanceTimer, startTimer, stopInstanceTimerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
instance_timer
protected long instance_timer -
parameters
protected java.util.HashMap<java.lang.String,java.lang.String> parameters -
log_out
protected java.io.BufferedWriter log_out -
default_logging_type
-
current_processes
-
is_interrupted
protected boolean is_interrupted -
exit_on_termination
protected boolean exit_on_termination
-
-
Constructor Details
-
CommandInstance
public CommandInstance()
-
-
Method Details
-
interrupt
public boolean interrupt()Requests that the currently executing process terminate- Returns:
-
execute
Description copied from class:CommandInterpreterExecutes a process, similar tomain, but runs as an instance, and returns the elapsed time in milliseconds.- Overrides:
executein classCommandInterpreter- Returns:
- Throws:
java.lang.Exception
-
setSuccessStatus
protected void setSuccessStatus(boolean status)- Overrides:
setSuccessStatusin classCommandInterpreter
-
getCommandLine
protected java.lang.String getCommandLine(java.lang.String[] args)Converts an array of parameters to a single space-delimited line.- Parameters:
args-- Returns:
-
start_log
protected boolean start_log(java.lang.String file) -
stop_log
protected boolean stop_log() -
log
protected void log(java.lang.String message) -
log
-
load_parameter_file
protected boolean load_parameter_file(java.lang.String file)Loads a parameter file and populatesparameterswith it. Returnstrueif successful. File must be of the form [parameter_name]\t[parameter_value].- Parameters:
file-- Returns:
-
run_command
protected abstract boolean run_command(java.lang.String command)Runs a single command with the current parameters.- Parameters:
command-
-
output_help
protected boolean output_help(java.net.URL resource)Reads and outputs a help file from the given URL- Parameters:
resource-- Returns:
-