Package mgui.command
Class CommandInterpreter
java.lang.Object
mgui.command.CommandInterpreter
- Direct Known Subclasses:
CommandInstance
public abstract class CommandInterpreter
extends java.lang.Object
Serves as the base class for command-line interpreters which interact with mgui.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Field Summary
Fields Modifier and Type Field Description protected static longclock_startprotected longelapsedprotected longinstance_clock_startprotected CommandFunctions.ProcessStateinstance_stateprotected booleansuccess_status -
Constructor Summary
Constructors Constructor Description CommandInterpreter() -
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 longgetInstanceTimer()static java.util.HashMap<java.lang.String,java.lang.String>getParameters(java.lang.String[] args)Extracts parameters from a list of arguments, such that a parameter is specified by a dash.booleangetSuccessStatus()protected static longgetTimer()protected static booleanisNumeric(java.lang.String n)protected voidsetSuccessStatus(boolean status)protected voidstartInstanceTimer()protected static voidstartTimer()protected voidstopInstanceTimer()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
clock_start
protected static long clock_start -
elapsed
protected long elapsed -
instance_clock_start
protected long instance_clock_start -
success_status
protected boolean success_status -
instance_state
-
-
Constructor Details
-
CommandInterpreter
public CommandInterpreter()
-
-
Method Details
-
execute
Executes a process, similar tomain, but runs as an instance, and returns the elapsed time in milliseconds.- Parameters:
args-- Returns:
- Throws:
java.lang.Exception
-
getSuccessStatus
public boolean getSuccessStatus() -
setSuccessStatus
protected void setSuccessStatus(boolean status) -
getParameters
public static java.util.HashMap<java.lang.String,java.lang.String> getParameters(java.lang.String[] args)Extracts parameters from a list of arguments, such that a parameter is specified by a dash. A parameter followed by an argument without a dash is assigned that value. This method returns the parameters as a hash map, with the parameter names as keys pointing to their values.For instance:
the argument series "-z" "-b" "value" would be placed in the hash map as [["z"->""],["b"->"value"]
- Parameters:
args-- Returns:
-
isNumeric
protected static boolean isNumeric(java.lang.String n) -
startTimer
protected static void startTimer() -
getTimer
protected static long getTimer() -
startInstanceTimer
protected void startInstanceTimer() -
getInstanceTimer
protected long getInstanceTimer() -
stopInstanceTimer
protected void stopInstanceTimer()
-