org.jargp
Class BoolDef

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

public class BoolDef
extends ParameterDef

Command line flag definition. This defines a simple command line flag that sets a boolean parameter value. Both true and false settings are supported.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
protected  boolean m_value
          Value set when flag is seen.
 
Fields inherited from class org.jargp.ParameterDef
m_char, m_description, m_field, m_name
 
Constructor Summary
BoolDef(char chr, java.lang.String name)
          Constructor defaulting to flag true.
BoolDef(char chr, java.lang.String name, boolean sense)
          Constructor with flag sense specified.
BoolDef(char chr, java.lang.String name, java.lang.String desc)
          Constructor defaulting to flag true with description.
BoolDef(char chr, java.lang.String name, java.lang.String desc, boolean sense)
          Constructor with flag sense specified and description.
 
Method Summary
protected  void bindToClass(java.lang.Class clas)
          Bind parameter to target class field.
 void handle(ArgumentProcessor proc)
          Handle argument.
 
Methods inherited from class org.jargp.ParameterDef
getAbbreviation, getDescription, getFlag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_value

protected boolean m_value
Value set when flag is seen.

Constructor Detail

BoolDef

public BoolDef(char chr,
               java.lang.String name,
               java.lang.String desc,
               boolean sense)
Constructor with flag sense specified and description.

Parameters:
chr - parameter flag character
name - field name for parameter
desc - discription text for parameter (may be null)
sense - value set when flag is seen

BoolDef

public BoolDef(char chr,
               java.lang.String name,
               boolean sense)
Constructor with flag sense specified.

Parameters:
chr - parameter flag character
name - field name for parameter
sense - value set when flag is seen

BoolDef

public BoolDef(char chr,
               java.lang.String name,
               java.lang.String desc)
Constructor defaulting to flag true with description.

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

BoolDef

public BoolDef(char chr,
               java.lang.String name)
Constructor defaulting to flag true.

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

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 boolean

handle

public void handle(ArgumentProcessor proc)
Handle argument. This implementation of the abstract base class method just sets the parameter value as appropriate for the flag.

Specified by:
handle in class ParameterDef
Parameters:
proc - argument processor making call to handler
Throws:
java.lang.IllegalArgumentException - on error in processing


Project Web Site