Module openj9.dtfj

Class Context

java.lang.Object
com.ibm.java.diagnostics.utils.Context
All Implemented Interfaces:
IContext
Direct Known Subclasses:
DTFJContext

public abstract class Context extends Object implements IContext
A context represents the environment within which a command is executing. This abstract class provides common functionality which is required by all types of context.
  • Field Details

    • globalCommands

      protected final ArrayList<ICommand> globalCommands
    • commands

      protected final ArrayList<ICommand> commands
    • lastExecutedCommand

      protected ICommand lastExecutedCommand
    • lastException

      protected Exception lastException
    • logger

      public static final Logger logger
      Shared logger for all commands to write to
    • loader

      protected PluginManager loader
  • Constructor Details

    • Context

      public Context()
  • Method Details

    • getPluginManager

      public PluginManager getPluginManager()
    • isCommandRecognised

      public boolean isCommandRecognised(String command)
      Description copied from interface: IContext
      Allows to check if the given command will be executed (i.e. if there is a command that will accept the string) without actually executing it, avoiding error messages etc.
      Specified by:
      isCommandRecognised in interface IContext
      Parameters:
      command - - just the actual command WITHOUT ARGUMENTS
      Returns:
    • execute

      public void execute(String command, String[] arguments, PrintStream out)
      Description copied from interface: IContext
      Execute the entered command line with the output sent to the supplied print stream.
      Specified by:
      execute in interface IContext
      Parameters:
      command - line to execute
      out - where to write the output to
    • execute

      public void execute(CommandParser commandParser, PrintStream out)
      Description copied from interface: IContext
      Execute the entered command line with the output sent to the supplied print stream.
      Specified by:
      execute in interface IContext
    • execute

      public void execute(String line, PrintStream out)
      Description copied from interface: IContext
      Execute the entered command line with the output sent to the supplied print stream.
      Specified by:
      execute in interface IContext
      Parameters:
      line - line to execute
      out - where to write the output to
    • getCommandNames

      public Vector<String> getCommandNames()
      List of all the command names that are available within this context
      Returns:
      list of names
    • getCommands

      public List<ICommand> getCommands()
      Description copied from interface: IContext
      Returns a list of commands which are available for this context
      Specified by:
      getCommands in interface IContext
      Returns:
    • addGlobalCommandsToContext

      protected void addGlobalCommandsToContext()
      This adds the list of global commands which are applicable for any context to this specific context instance
    • getLastExecutedCommand

      public ICommand getLastExecutedCommand()
      Description copied from interface: IContext
      The last command which was successfully executed by the context.
      Specified by:
      getLastExecutedCommand in interface IContext
      Returns:
      the command or null if none have been executed or the command threw an exception
    • getLastCommandException

      public Exception getLastCommandException()
      Description copied from interface: IContext
      Provides access to any uncaught exceptions thrown when the last command was executed.
      Specified by:
      getLastCommandException in interface IContext
      Returns:
      the exception or null of no uncaught exceptions were thrown