Package com.sun.javatest.tool
Class Command
java.lang.Object
com.sun.javatest.tool.Command
- Direct Known Subclasses:
VerboseCommand
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 ClassesModifier and TypeClassDescriptionclass
This exception is used to report problems with a specific command. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Record another argument in the argument array.String[]
getArgs()
Get the array of arguments for this command.protected InterviewParameters
getConfig
(CommandContext ctx) 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
putbackArg
(ListIterator<String> argIter) Back up the iterator to reject an argument, and remove the corresponding entry from the argument array.abstract void
run
(CommandContext ctx) Execute the work embodied by this command, using the given command context.toString()
Get a printable representation of this command.
-
Field Details
-
DEFAULT_DTMODE
public static final int DEFAULT_DTMODEA value to indicate that a command accepts the default desktop mode. This means that it neither requires nor discourages the use of a desktop for its use.- See Also:
-
DESKTOP_NOT_REQUIRED_DTMODE
public static final int DESKTOP_NOT_REQUIRED_DTMODEA value to indicate that a command does not require the use of a desktop to function.- See Also:
-
DESKTOP_REQUIRED_DTMODE
public static final int DESKTOP_REQUIRED_DTMODEA value to indicate that a command requires the use of a desktop to function.- See Also:
-
-
Constructor Details
-
Command
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
Record another argument in the argument array.- Parameters:
arg
- the argument to be added
-
nextArg
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
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
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
Get a printable representation of this command. The string is composed of the entries in the argument array. -
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
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
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
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.
-