Class CommandPrompt

java.lang.Object
i5.las2peer.tools.CommandPrompt

public class CommandPrompt extends Object
A simple command line for executing commands, generating new instances and handling local variables.
  • Constructor Details

    • CommandPrompt

      public CommandPrompt()
      create a new unbound prompt
    • CommandPrompt

      public CommandPrompt(Object boundTo)
      create a new prompt bound to the given object
      Parameters:
      boundTo -
  • Method Details

    • handleAssignment

      public CommandPrompt.ReturnStatus handleAssignment(String line)
      handle an assignment command
      Parameters:
      line -
      Returns:
      status code
    • handleNew

      public Object handleNew(String command) throws Exception
      handle a NEW command, e.g. try to create a new instance of the given class with the possibly given parameters
      Parameters:
      command -
      Returns:
      result of the new instantiation
      Throws:
      Exception
    • handleCommand

      public Object handleCommand(String command) throws Exception
      handle a command, i.e. a static method or a class method of a local variable or the bound object
      Parameters:
      command -
      Returns:
      result of the invoked operation
      Throws:
      Exception
    • handleLine

      public CommandPrompt.ReturnStatus handleLine(String line)
      handle a line of input
      Parameters:
      line -
      Returns:
      return status code
    • printException

      public void printException()
      print the last caught exception / throwable
    • handlePrint

      public CommandPrompt.ReturnStatus handlePrint(String line)
      print the value of all given local variables
      Parameters:
      line -
      Returns:
      return status code
    • localCommand

      public CommandPrompt.ReturnStatus localCommand(String line)
      check, if the given line contains (starts with) a local command and execute it.
      Parameters:
      line -
      Returns:
      return status code
    • printHelp

      public void printHelp()
      print a help message
    • printVersion

      public void printVersion()
      Prints the las2peer version.
    • prompt

      public CommandPrompt.ReturnStatus prompt()
      print a simple prompt and wait for input
      Returns:
      return status code
    • startPrompt

      public void startPrompt()
      loop through input and execution
    • main

      public static void main(String[] argv) throws ClassNotFoundException
      start a command line
      Parameters:
      argv -
      Throws:
      ClassNotFoundException