|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.web.notification.bobject.Command
This is a class to store and execute a console command
Field Summary | |
private java.util.List |
m_arguments
The map of arguments in the command |
private java.lang.String |
m_commandComments
The comments for the command |
private java.lang.String |
m_commandName
The name of the command |
private java.util.List |
m_types
The types of the command, useful for supporting classes to do things based on what this command is for. |
private boolean |
m_useStream
A boolean that indicates if this command requires data passed to it from an input stream. |
Constructor Summary | |
Command()
Default constructor, intializes the members |
Method Summary | |
void |
addArgument(Argument anArgument)
Adds a argument to the list of arguments |
void |
addType(java.lang.String aType)
Adds an identifier type for command |
Command |
copy()
Creates a new Command objects with identical values to the current Command object. |
static java.lang.String[] |
createCommandArray(java.lang.String s,
char delim)
Convenience method for creating arrays of strings suitable for use as command-line parameters when executing an external process. |
int |
execute()
This method executes the command using a Process. |
java.util.List |
getArguments()
Returns the list of arguments |
java.util.List |
getArgumentSwitches()
This method gets the list of switches that Notify knows about that will map to a given console command. |
java.lang.String |
getCommandComments()
Returns the comments for the command |
java.lang.String |
getCommandName()
Returns the command name |
java.lang.String |
getType()
Returns the first type in the list as a string |
boolean |
hasSwitch(java.lang.String aSwitch)
This method determines if this command has a given switch as a member of its arguments |
boolean |
isOfType(java.lang.String aType)
Returns the notification type of the command |
void |
setArgumentValue(java.lang.String aSwitch,
java.lang.String aValue)
This method sets an argument specified by the switch param to the given value param |
void |
setCommandComments(java.lang.String someComments)
Sets the comments for the command |
void |
setCommandName(java.lang.String aName)
Sets the command name |
void |
setUseStream(boolean aBool)
This method sets the boolean that indicates if this command requires an input stream. |
java.lang.String |
toString()
Returns a String representation of the command as it would look to execute on the console. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.lang.String m_commandName
private java.util.List m_types
private java.lang.String m_commandComments
private java.util.List m_arguments
private boolean m_useStream
Constructor Detail |
public Command()
Method Detail |
public Command copy()
public void setCommandName(java.lang.String aName)
aName
- the name of the commandpublic java.lang.String getCommandName()
public void addType(java.lang.String aType)
aType
- the notification typepublic boolean isOfType(java.lang.String aType)
public java.lang.String getType()
public void setCommandComments(java.lang.String someComments)
someComments
- the comments for the commandpublic java.lang.String getCommandComments()
public void addArgument(Argument anArgument)
anArgument
- the argument to be added.public void setUseStream(boolean aBool)
aBool
- true if a stream should be used, false otherwisepublic java.util.List getArguments()
public void setArgumentValue(java.lang.String aSwitch, java.lang.String aValue)
aSwitch
- the argument to setaValue
- the value to setpublic boolean hasSwitch(java.lang.String aSwitch)
aSwitch
- the switch to check for
public java.util.List getArgumentSwitches()
public int execute()
public java.lang.String toString()
public static java.lang.String[] createCommandArray(java.lang.String s, char delim)
The default Runtime.exec(java.lang.String[])
method
will split a single string based on spaces, but it does not respect
spaces within quotation marks, and it will leave the quotation marks in
the resulting substrings. This method solves those problems by replacing
all in-quote spaces with the given delimiter, removes the quotes, and
then splits the resulting string by the remaining out-of-quote spaces. It
then goes through each substring and replaces the delimiters with spaces.
Caveat: This method does not respect escaped quotes! It will simply remove them and leave the stray escape characters.
s
- the string to splitdelim
- a char that does not already exist in s
java.lang.IllegalArgumentException
- If s
is null or if delim
already exists in s
.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |