All Packages Class Hierarchy This Package Previous Next Index
Class org.ajug.jsl.jester.tester.CommandExtractor
java.lang.Object
|
+----org.ajug.jsl.jester.tester.CommandExtractor
- public class CommandExtractor
- extends Object
This class extracts what's needed from a command. The command is
in the form of a String array of tokens. This class is designed
to be reusable, for use in command line argument use.
To use this class, first configure it by using
setTokens(String[] tokens) and other setup as
desired. Then get the data needed, such as by using
hasOption(String optionName).
-
CommandExtractor()
-
-
getFirstToken()
- Returns the first token in the array, which may be important.
-
getLastToken()
- Returns the last token in the array, which may be important.
-
hasOption(String)
- Determines whether the tokens have an option with the optionName.
-
main(String[])
- Runs the unit test for this class.
-
setOptionPrefix(String)
- Sets the prefix signifying a token is an option.
-
setTokens(String[])
- Sets the tokens to be used.
CommandExtractor
public CommandExtractor()
main
public static void main(String args[])
- Runs the unit test for this class.
setTokens
public void setTokens(String tokens[])
- Sets the tokens to be used. For example they might be:
-nocatch org.jsl.tester.samples.TestContainer
in the form of the array.
Note that null values in the tokens makes no sense. If any are
found (or tokens is null itself) an IllegalArgumentException is
thrown. A zero length array is allowed.
Note that duplicate options are currently not checked for, and
are thus allowed.
getFirstToken
public String getFirstToken()
- Returns the first token in the array, which may be important.
If a zero length array then null is returned.
Thus null return values must be checked for by the client.
If the tokens are null then an IllegalStateException is thrown.
getLastToken
public String getLastToken()
- Returns the last token in the array, which may be important.
If a zero length array then null is returned.
Thus null return values must be checked for by the client.
If the tokens are null then an IllegalStateException is thrown.
setOptionPrefix
public void setOptionPrefix(String prefix)
- Sets the prefix signifying a token is an option. The default is
the standard "-". Normally this is never called.
hasOption
public boolean hasOption(String optionName)
- Determines whether the tokens have an option with the optionName.
This is one of the main uses of this class.
If optionName is null then an IllegalArgumentException is thrown.
All Packages Class Hierarchy This Package Previous Next Index