org.jargp
Class StringDef
java.lang.Object
|
+--org.jargp.ParameterDef
|
+--org.jargp.StringDef
- public class StringDef
- extends ParameterDef
Command line string parameter definition. This defines a command line flag
with an associated string value, supplied as a separate argument on the
command line. The argument giving the parameter value must be the next
unused argument from the command line, and must not begin with the '-'
character used to indicate control argument flags.
- Version:
- 1.0
- Author:
- Dennis M. Sosnoski
Constructor Summary |
StringDef(char chr,
java.lang.String name)
Constructor without description. |
StringDef(char chr,
java.lang.String name,
java.lang.String desc)
Constructor with description. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringDef
public StringDef(char chr,
java.lang.String name,
java.lang.String desc)
- Constructor with description.
- Parameters:
chr
- parameter flag charactername
- field name for parameterdesc
- discription text for parameter
StringDef
public StringDef(char chr,
java.lang.String name)
- Constructor without description.
- Parameters:
chr
- parameter flag charactername
- field name for parameter
bindToClass
protected void bindToClass(java.lang.Class clas)
- Bind parameter to target class field.
- Overrides:
bindToClass
in class ParameterDef
- Parameters:
clas
- target class for saving parameter values
- Throws:
java.lang.IllegalArgumentException
- if the field is not a String
handle
public void handle(ArgumentProcessor proc)
- Handle argument. This implementation of the abstract base class method
makes sure that we have another command line argument available, and
checks that the argument does not begin with the '-' character used to
indicate control argument flags. If these conditions are met the
parameter field is set to the string value of the argument.
- Specified by:
handle
in class ParameterDef
- Parameters:
proc
- argument processor making call to handler
- Throws:
ArgumentErrorException
- if argument value missing or malformed
java.lang.IllegalArgumentException
- on error in processing