iaik.tc.utils.cmdline
Class Param

java.lang.Object
  extended by iaik.tc.utils.cmdline.Param

public class Param
extends java.lang.Object

This class holds all information relevant for an individual command line parameter. That includes e.g. the key of the parameter, if it is required or optional or legal values.


Field Summary
static byte OPT_BOTH
          This flag means that the key is optional.
static byte OPT_KEY
          This flag means the key is optional.
static byte REQ_BOTH
          This flag means that both, key and value, are required.
static byte REQ_KEY
          This flag means that the key of the parameter is required.
 
Constructor Summary
Param(java.lang.String key, java.lang.String dummyValue, byte required)
          Constructor.
Param(java.lang.String key, java.lang.String dummyValue, byte required, java.lang.String description)
          Constructor.
Param(java.lang.String key, java.lang.String dummyValue, byte required, java.lang.String description, java.lang.String defaultValue)
          Constructor.
Param(java.lang.String key, java.lang.String dummyValue, byte required, java.lang.String description, java.lang.String defaultValue, java.lang.String[] legalValues)
          Constructor.
 
Method Summary
 java.lang.String getDefaultValue()
          Returns the defaultValue field.
 java.lang.String getDescription()
          Returns the description field.
 java.lang.String getDummyValue()
          Returns the dummyValue field.
 java.lang.String getKey()
          Returns the key field.
 java.lang.String[] getLegalValues()
          Returns the legalValues field.
 java.lang.String getValue()
          Returns the value field.
 boolean isKeyPresent()
          Returns if the key is present (i.e.
 boolean isRequired()
          This method returns true if the parameter (or more precisely it key of the parameter) is required, false otherwise.
 boolean isValuePresent()
          Returns if a value is present (i.e.
 boolean isValueRequired()
          This method returns true if a value (and not only a key) is required, false otherwise.
 void setDefaultValue(java.lang.String defaultValue)
          Sets the defaultValue field.
 void setDescription(java.lang.String description)
          Sets the description field.
 void setDummyValue(java.lang.String dummyValue)
          Sets the dummyValue field.
 void setKey(java.lang.String key)
          Sets the key field.
 void setKeyPresent(boolean present)
          Sets the present field for the key.
 void setLegalValues(java.lang.String[] legalValues)
          Sets the legalValues field.
 void setRequired(byte required)
          Sets the required field.
 void setValue(java.lang.String value)
          Sets the Value field.
 void setValuePresent(boolean present)
          Sets the present field for the value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQ_KEY

public static byte REQ_KEY
This flag means that the key of the parameter is required.


REQ_BOTH

public static byte REQ_BOTH
This flag means that both, key and value, are required.


OPT_KEY

public static byte OPT_KEY
This flag means the key is optional.


OPT_BOTH

public static byte OPT_BOTH
This flag means that the key is optional. If the key is specified by the user, also a value has to be given.

Constructor Detail

Param

public Param(java.lang.String key,
             java.lang.String dummyValue,
             byte required)
Constructor.


Param

public Param(java.lang.String key,
             java.lang.String dummyValue,
             byte required,
             java.lang.String description)
Constructor.


Param

public Param(java.lang.String key,
             java.lang.String dummyValue,
             byte required,
             java.lang.String description,
             java.lang.String defaultValue)
Constructor.


Param

public Param(java.lang.String key,
             java.lang.String dummyValue,
             byte required,
             java.lang.String description,
             java.lang.String defaultValue,
             java.lang.String[] legalValues)
Constructor.

Method Detail

getDescription

public java.lang.String getDescription()
Returns the description field.

Returns:
the description

setDescription

public void setDescription(java.lang.String description)
Sets the description field.

Parameters:
description - the description to set

getKey

public java.lang.String getKey()
Returns the key field.

Returns:
the key

setKey

public void setKey(java.lang.String key)
Sets the key field.

Parameters:
key - the key to set

getLegalValues

public java.lang.String[] getLegalValues()
Returns the legalValues field.

Returns:
the legalValues

setLegalValues

public void setLegalValues(java.lang.String[] legalValues)
Sets the legalValues field.

Parameters:
legalValues - the legalValues to set

isRequired

public boolean isRequired()
This method returns true if the parameter (or more precisely it key of the parameter) is required, false otherwise.


isValueRequired

public boolean isValueRequired()
This method returns true if a value (and not only a key) is required, false otherwise.


setRequired

public void setRequired(byte required)
Sets the required field.

Parameters:
required - the required to set

getValue

public java.lang.String getValue()
Returns the value field.

Returns:
the value

setValue

public void setValue(java.lang.String value)
              throws java.lang.IllegalArgumentException
Sets the Value field. It checks if the given values is acceptable (i.e. if it is part of the legalValues field). If legalValues is empty (or not set), all values will be accepted.

Parameters:
value - the value to set
Throws:
java.lang.IllegalArgumentException

getDefaultValue

public java.lang.String getDefaultValue()
Returns the defaultValue field.

Returns:
the defaultValue

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Sets the defaultValue field.

Parameters:
defaultValue - the defaultValue to set

isKeyPresent

public boolean isKeyPresent()
Returns if the key is present (i.e. specified by the user) or not.


isValuePresent

public boolean isValuePresent()
Returns if a value is present (i.e. specified by the user) or not.


setKeyPresent

public void setKeyPresent(boolean present)
Sets the present field for the key.


setValuePresent

public void setValuePresent(boolean present)
Sets the present field for the value.


getDummyValue

public java.lang.String getDummyValue()
Returns the dummyValue field.

Returns:
the dummyValue

setDummyValue

public void setDummyValue(java.lang.String dummyValue)
Sets the dummyValue field.

Parameters:
dummyValue - the dummyValue to set