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 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

      protected LoggingType default_logging_type
    • current_processes

      protected static java.util.HashMap<java.lang.Long,​JavaProcess> 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

      public CommandFunctions.ProcessState execute​(java.lang.String[] args) throws java.lang.Exception
      Description copied from class: CommandInterpreter
      Executes a process, similar to main, but runs as an instance, and returns the elapsed time in milliseconds.
      Overrides:
      execute in class CommandInterpreter
      Returns:
      Throws:
      java.lang.Exception
    • setSuccessStatus

      protected void setSuccessStatus​(boolean status)
      Overrides:
      setSuccessStatus in class CommandInterpreter
    • 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

      protected void log​(java.lang.String message, LoggingType type)
    • load_parameter_file

      protected boolean load_parameter_file​(java.lang.String file)
      Loads a parameter file and populates parameters with it. Returns true if 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: