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 long
clock_start
protected long
elapsed
protected long
instance_clock_start
protected CommandFunctions.ProcessState
instance_state
protected boolean
success_status
-
Constructor Summary
Constructors Constructor Description CommandInterpreter()
-
Method Summary
Modifier and Type Method Description CommandFunctions.ProcessState
execute(java.lang.String[] args)
Executes a process, similar tomain
, but runs as an instance, and returns the elapsed time in milliseconds.protected long
getInstanceTimer()
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.boolean
getSuccessStatus()
protected static long
getTimer()
protected static boolean
isNumeric(java.lang.String n)
protected void
setSuccessStatus(boolean status)
protected void
startInstanceTimer()
protected static void
startTimer()
protected void
stopInstanceTimer()
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()
-