org.jargp
Class ParameterDef

java.lang.Object
  |
  +--org.jargp.ParameterDef
Direct Known Subclasses:
BoolDef, FloatDef, IntDef, StringDef

public abstract class ParameterDef
extends java.lang.Object

Base class for command line parameter definitions. This is used for simple command line parameters of various flavors. Subclasses define the particular types of parameters supported.

Version:
1.0
Author:
Dennis M. Sosnoski

Field Summary
protected  char m_char
          Argument flag character.
protected  java.lang.String m_description
          Argument description text.
protected  java.lang.reflect.Field m_field
          Information for field linked to parameter.
protected  java.lang.String m_name
          Name of field holding parameter value.
 
Constructor Summary
protected ParameterDef(char chr, java.lang.String name, java.lang.String desc)
          Constructor
 
Method Summary
protected  void bindToClass(java.lang.Class clas)
          Bind parameter to target class field.
 java.lang.String getAbbreviation()
          Get text abbreviation for parameter.
 java.lang.String getDescription()
          Get text of parameter description.
 char getFlag()
          Get flag character for parameter.
abstract  void handle(ArgumentProcessor proc)
          Handle argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_char

protected final char m_char
Argument flag character.


m_name

protected final java.lang.String m_name
Name of field holding parameter value.


m_description

protected final java.lang.String m_description
Argument description text.


m_field

protected java.lang.reflect.Field m_field
Information for field linked to parameter.

Constructor Detail

ParameterDef

protected ParameterDef(char chr,
                       java.lang.String name,
                       java.lang.String desc)
Constructor

Parameters:
chr - parameter flag character
name - field name for parameter
desc - discription text for parameter (may be null)
Throws:
java.lang.IllegalArgumentException - if the field is not accessible
Method Detail

getAbbreviation

public java.lang.String getAbbreviation()
Get text abbreviation for parameter. The default format is just "-c", where 'c' is the flag character for the parameter. If a different format is needed by a subclass it should override this method.

Returns:
text abbreviation for showing parameter

getFlag

public char getFlag()
Get flag character for parameter.

Returns:
flag character specifying the parameter

getDescription

public java.lang.String getDescription()
Get text of parameter description.

Returns:
array of bytes containing all data from file
Throws:
IOException - on file access error

bindToClass

protected void bindToClass(java.lang.Class clas)
Bind parameter to target class field. This will generally be overridden by subclasses to verify the field type found, but should be called during the subclass processing.

Parameters:
clas - target class for saving parameter values

handle

public abstract void handle(ArgumentProcessor proc)
Handle argument. This abstract method must be overridden in each subclass to perform the appropriate processing, if necessary using additional characters from the current argument or the next argument in the list.

Parameters:
proc - argument processor making call to handler


Project Web Site