org.jargp
Class IntDef

java.lang.Object
  |
  +--org.jargp.ParameterDef
        |
        +--org.jargp.IntDef

public class IntDef
extends ParameterDef

Command line integer parameter definition. This defines a command line flag with an associated integer value. The optionally signed value must immediately follow the flag character within the same argument string.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
 
Fields inherited from class org.jargp.ParameterDef
m_char, m_description, m_field, m_name
 
Constructor Summary
IntDef(char chr, java.lang.String name)
          Constructor with no range or description.
IntDef(char chr, java.lang.String name, int min, int max)
          Constructor with range but no description.
IntDef(char chr, java.lang.String name, java.lang.String desc)
          Constructor with no range defined.
IntDef(char chr, java.lang.String name, java.lang.String desc, int min, int max)
          Constructor with range and description.
 
Method Summary
protected  void bindToClass(java.lang.Class clas)
          Bind parameter to target class field.
 java.lang.String getAbbreviation()
          Get text abbreviation for parameter.
 void handle(ArgumentProcessor proc)
          Handle argument.
 
Methods inherited from class org.jargp.ParameterDef
getDescription, getFlag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntDef

public IntDef(char chr,
              java.lang.String name,
              java.lang.String desc,
              int min,
              int max)
Constructor with range and description.

Parameters:
chr - parameter flag character
name - field name for parameter
desc - discription text for parameter
min - minimum allowed value
max - maximum allowed value

IntDef

public IntDef(char chr,
              java.lang.String name,
              int min,
              int max)
Constructor with range but no description.

Parameters:
chr - parameter flag character
name - field name for parameter
min - minimum allowed value
max - maximum allowed value

IntDef

public IntDef(char chr,
              java.lang.String name,
              java.lang.String desc)
Constructor with no range defined.

Parameters:
chr - parameter flag character
name - field name for parameter
desc - discription text for parameter

IntDef

public IntDef(char chr,
              java.lang.String name)
Constructor with no range or description.

Parameters:
chr - parameter flag character
name - field name for parameter
Method Detail

getAbbreviation

public java.lang.String getAbbreviation()
Get text abbreviation for parameter. This override of the base class method returns "-cNN", where 'c' is the flag character for the parameter.

Overrides:
getAbbreviation in class ParameterDef
Returns:
text abbreviation for showing 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 an int

handle

public void handle(ArgumentProcessor proc)
Handle argument. This implementation of the abstract base class method interprets the characters following the flag character as an optionally signed decimal value. If the value is within the allowed range the parameter is set to that value. Other flag characters may follow the numeric value within the argument.

Specified by:
handle in class ParameterDef
Parameters:
proc - argument processor making call to handler
Throws:
ArgumentErrorException - if decimal value missing or out of range
java.lang.IllegalArgumentException - on error in processing


Project Web Site