|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opennms.web.notification.bobject.Command
public class Command
This is a class to store and execute a console command
| Constructor Summary | |
|---|---|
Command()
Default constructor, intializes the members |
|
| Method Summary | |
|---|---|
void |
addArgument(Argument anArgument)
Adds a argument to the list of arguments |
void |
addType(String aType)
Adds an identifier type for command |
Command |
copy()
Creates a new Command objects with identical values to the current Command object. |
static String[] |
createCommandArray(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. |
List |
getArguments()
Returns the list of arguments |
List<String> |
getArgumentSwitches()
This method gets the list of switches that Notify knows about that will map to a given console command. |
String |
getCommandComments()
Returns the comments for the command |
String |
getCommandName()
Returns the command name |
String |
getType()
Returns the first type in the list as a string |
boolean |
hasSwitch(String aSwitch)
This method determines if this command has a given switch as a member of its arguments |
boolean |
isOfType(String aType)
Returns the notification type of the command |
void |
setArgumentValue(String aSwitch,
String aValue)
This method sets an argument specified by the switch param to the given value param |
void |
setCommandComments(String someComments)
Sets the comments for the command |
void |
setCommandName(String aName)
Sets the command name |
void |
setUseStream(boolean aBool)
This method sets the boolean that indicates if this command requires an input stream. |
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 |
| Constructor Detail |
|---|
public Command()
| Method Detail |
|---|
public Command copy()
public void setCommandName(String aName)
aName - the name of the commandpublic String getCommandName()
public void addType(String aType)
aType - the notification typepublic boolean isOfType(String aType)
public String getType()
public void setCommandComments(String someComments)
someComments - the comments for the commandpublic 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 List getArguments()
public void setArgumentValue(String aSwitch,
String aValue)
aSwitch - the argument to setaValue - the value to setpublic boolean hasSwitch(String aSwitch)
aSwitch - the switch to check for
public List<String> getArgumentSwitches()
public int execute()
public String toString()
toString in class Object
public static String[] createCommandArray(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
IllegalArgumentException - If s is null or if delim
already exists in s.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||