Class Command

java.lang.Object
com.sun.javatest.tool.Command
Direct Known Subclasses:
VerboseCommand

public abstract class Command extends Object
A class to represent a command to be executed. Commands are typically read from the command line or from command files.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    This exception is used to report problems with a specific command.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A value to indicate that a command accepts the default desktop mode.
    static final int
    A value to indicate that a command does not require the use of a desktop to function.
    static final int
    A value to indicate that a command requires the use of a desktop to function.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create an instance of a command.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Record another argument in the argument array.
    Get the array of arguments for this command.
    A convenience method to get the configuration from a command context, and rewrapping any exception that might occur.
    Get the classpath to load the custom splash screen from.
    int
    Get the desktop mode for this command.
    boolean
    Check whether this command is an action command or not.
    protected String
    Get another argument from the iterator, and add it to the argument array.
    protected void
    Back up the iterator to reject an argument, and remove the corresponding entry from the argument array.
    abstract void
    Execute the work embodied by this command, using the given command context.
    Get a printable representation of this command.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Command

      protected Command(String name)
      Create an instance of a command.
      Parameters:
      name - The name for this command. The name will be saved as the first entry as the argument array.
  • Method Details

    • addArg

      protected void addArg(String arg)
      Record another argument in the argument array.
      Parameters:
      arg - the argument to be added
    • nextArg

      protected String nextArg(Iterator<String> argIter)
      Get another argument from the iterator, and add it to the argument array.
      Parameters:
      argIter - the iterator from which to get the next argument
      Returns:
      the next argument from the iterator
    • putbackArg

      protected void putbackArg(ListIterator<String> argIter)
      Back up the iterator to reject an argument, and remove the corresponding entry from the argument array.
      Parameters:
      argIter - the iterator from which teh argument was obtained
    • getArgs

      public String[] getArgs()
      Get the array of arguments for this command. The first element in the array will be the command name; the subsequent arguments will be the ones added by the addArg method.
      Returns:
      the array of arguments for this command
    • toString

      public String toString()
      Get a printable representation of this command. The string is composed of the entries in the argument array.
      Overrides:
      toString in class Object
      Returns:
      a printable representation of this command
    • getDesktopMode

      public int getDesktopMode()
      Get the desktop mode for this command. Valid responses are one of DEFAULT_DTMODE, DESKTOP_NOT_REQUIRED_DTMODE, DESKTOP_REQUIRED_DTMODE. The default is DESKTOP_NOT_REQUIRED_DTMODE if isActionCommand is true, and DESKTOP_DEFAULT_DTMODE otherwise.
      Returns:
      a value indicating the desktop mode for this command
      See Also:
    • getCustomSplash

      public URL getCustomSplash()
      Get the classpath to load the custom splash screen from. At this location, it is expected that a resource bundle prefixed with "splash" will be available. The search strategy given in ResourceBundle will be used, with the returned File as the classpath for the class loader. The limited classpath/classloader is used to make this operation as fast as possible, rather than requiring that the command's entire context be loaded.

      In the resource bundle, there should be a property named startup.icon.

      Returns:
      the location of the splash screen resource bundle
      Since:
      4.0
      See Also:
    • isActionCommand

      public boolean isActionCommand()
      Check whether this command is an action command or not. Action commands are those that do work such as running tests, writing a report, etc. The default implementation is to return false.
      Returns:
      true if this command is an action command, and false otherwise
    • run

      public abstract void run(CommandContext ctx) throws Command.Fault
      Execute the work embodied by this command, using the given command context.
      Parameters:
      ctx - context information that may be set up by preceding commands.
      Throws:
      Command.Fault - if there is an error while executing this command
    • getConfig

      protected InterviewParameters getConfig(CommandContext ctx) throws Command.Fault
      A convenience method to get the configuration from a command context, and rewrapping any exception that might occur.
      Parameters:
      ctx - the command context from which to get the configuration
      Returns:
      the current configuration from the command context
      Throws:
      Command.Fault - if there is a problem obtaining or evaluating the configuration.