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).


Constructor Index

 o CommandExtractor()

Method Index

 o getFirstToken()
Returns the first token in the array, which may be important.
 o getLastToken()
Returns the last token in the array, which may be important.
 o hasOption(String)
Determines whether the tokens have an option with the optionName.
 o main(String[])
Runs the unit test for this class.
 o setOptionPrefix(String)
Sets the prefix signifying a token is an option.
 o setTokens(String[])
Sets the tokens to be used.

Constructors

 o CommandExtractor
 public CommandExtractor()

Methods

 o main
 public static void main(String args[])
Runs the unit test for this class.

 o 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.

 o 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.

 o 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.

 o 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.

 o 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