jcmdline
Interface Parameter

All Known Implementing Classes:
AbstractParameter

public interface Parameter

Interface for command line parameters.

Version:
jcmdline Rel. 1.0.3 $Id: Parameter.java,v 1.2 2002/12/07 14:22:06 lglawrence Exp $
Author:
Lynne Lawrence

Field Summary
static boolean HIDDEN
          when used as a value for the hidden indicator, indicates that a parameter is hidden, and its description will not be listed in the usage.
static boolean MULTI_VALUED
          when used as a value for the multiValued indicator, specifies that an parameter accepts mulitiple values
static boolean OPTIONAL
          when used as a value for the optional indicator, specifies that an parameter is optional
static boolean PUBLIC
          when used as a value for the hidden indicator, indicates that a parameter is public, and its description will be listed in the usage.
static boolean REQUIRED
          when used as a value for the optional indicator, specifies that an parameter is required
static boolean SINGLE_VALUED
          when used as a value for the multiValued indicator, specifies that a parameter accepts only one value
 
Method Summary
 void addValue(java.lang.String value)
          adds the specified string as a value for this entity
 java.lang.String[] getAcceptableValues()
          Gets the values that are acceptable for this parameter, if a restricted set exists.
 java.lang.String getDesc()
          gets the value of the parameter's description
 boolean getIgnoreRequired()
          Gets the flag indicating that during parse, missing required Parameters are ignored if this Parameter is set.
 java.lang.String getOptionLabel()
          gets the value of optionLabel
 java.lang.String getTag()
          gets the value of tag
 java.lang.String getValue()
          The value of the parameter, in the case where the parameter is not multi-valued.
 java.util.Collection getValues()
          gets the values associated with this Parameter
 boolean isHidden()
          gets the value of the hidden indicator
 boolean isMultiValued()
          gets the value of multiValued indicator
 boolean isOptional()
          returns the value of the optional indicator
 boolean isSet()
          gets an indicator that the parameter's value has been set
 void setAcceptableValues(java.util.Collection vals)
          Sets the values that are acceptable for this parameter, if a restricted set exists.
 void setAcceptableValues(java.lang.String[] vals)
          Sets the values that are acceptable for this parameter, if a restricted set exists.
 void setDesc(java.lang.String desc)
          sets the value of this parameter's description
 void setHidden(boolean hidden)
          sets the value of the hidden indicator
 void setIgnoreRequired(boolean ignoreRequired)
          Sets a flag such that during parse, missing required Parameters are ignored if this Parameter is set.
 void setMultiValued(boolean multiValued)
          sets the value of the multiValued indicator
 void setOptional(boolean optional)
          indicates whether or not the parameter is optional
 void setOptionLabel(java.lang.String optionLabel)
          Sets the value of optionLabel.
 void setTag(java.lang.String tag)
          sets the value of tag
 void setValue(java.lang.String value)
          Sets the value of the parameter to the specified string.
 void setValues(java.util.Collection values)
          Sets the values of the parameter to those specified.
 void setValues(java.lang.String[] values)
          Sets the values of the parameter to those specified.
 void validateValue(java.lang.String value)
          verifies that value is valid for this entity
 

Field Detail

PUBLIC

public static final boolean PUBLIC
when used as a value for the hidden indicator, indicates that a parameter is public, and its description will be listed in the usage.

See Also:
Constant Field Values

HIDDEN

public static final boolean HIDDEN
when used as a value for the hidden indicator, indicates that a parameter is hidden, and its description will not be listed in the usage.

See Also:
Constant Field Values

OPTIONAL

public static final boolean OPTIONAL
when used as a value for the optional indicator, specifies that an parameter is optional

See Also:
Constant Field Values

REQUIRED

public static final boolean REQUIRED
when used as a value for the optional indicator, specifies that an parameter is required

See Also:
Constant Field Values

MULTI_VALUED

public static final boolean MULTI_VALUED
when used as a value for the multiValued indicator, specifies that an parameter accepts mulitiple values

See Also:
Constant Field Values

SINGLE_VALUED

public static final boolean SINGLE_VALUED
when used as a value for the multiValued indicator, specifies that a parameter accepts only one value

See Also:
Constant Field Values
Method Detail

isSet

public boolean isSet()
gets an indicator that the parameter's value has been set

Returns:
true if the parameter's value has been set, false otherwise

isHidden

public boolean isHidden()
gets the value of the hidden indicator

Returns:
true (HIDDEN) if the parameter is a hidden parameter

setHidden

public void setHidden(boolean hidden)
sets the value of the hidden indicator

Parameters:
hidden - true (HIDDEN) if the parameter is a hidden parameter

getDesc

public java.lang.String getDesc()
gets the value of the parameter's description

Returns:
this parameter's description

setDesc

public void setDesc(java.lang.String desc)
             throws java.lang.IllegalArgumentException
sets the value of this parameter's description

Parameters:
desc - a description of the parameter, suitable for display in the command's usage
Throws:
java.lang.IllegalArgumentException - if desc is fewer than 5 charaters.

getTag

public java.lang.String getTag()
gets the value of tag

Returns:
a unique identifier for this parameter

setTag

public void setTag(java.lang.String tag)
            throws java.lang.IllegalArgumentException
sets the value of tag

Parameters:
tag - a unique identifier for this parameter. If the parameter is used as an option, it will be used to identify the option on the command line. In the case where the parameter is used as an argument, it will only be used to identify the argument in the usage statement. Tags must be made up of any character but '='.
Throws:
java.lang.IllegalArgumentException - if the length of tag is less than 1, or tag contains an invalid character.

isMultiValued

public boolean isMultiValued()
gets the value of multiValued indicator

Returns:
true if the parameter can have multiple values

setMultiValued

public void setMultiValued(boolean multiValued)
sets the value of the multiValued indicator

Parameters:
multiValued - true if the parameter can have multiple values

isOptional

public boolean isOptional()
returns the value of the optional indicator

Returns:
true if the parameter is optional

setOptional

public void setOptional(boolean optional)
indicates whether or not the parameter is optional

Parameters:
optional - true if the parameter is optional

getAcceptableValues

public java.lang.String[] getAcceptableValues()
Gets the values that are acceptable for this parameter, if a restricted set exists. If there is no restricted set of acceptable values, null is returned.

Returns:
a set of acceptable values for the Parameter, or null if there is none.

setAcceptableValues

public void setAcceptableValues(java.lang.String[] vals)
Sets the values that are acceptable for this parameter, if a restricted set exists. A null vals value, or an empty vals array, will result in any previously set acceptable values being cleared.

Parameters:
vals - the new acceptable values
See Also:
getAcceptableValues()

setAcceptableValues

public void setAcceptableValues(java.util.Collection vals)
Sets the values that are acceptable for this parameter, if a restricted set exists. A null vals value, or an empty vals Collection, will result in any previously set acceptable values being cleared.

The toString() values of the Objects in vals will be used for the acceptable values.

Parameters:
vals - the new acceptable values

addValue

public void addValue(java.lang.String value)
              throws CmdLineException
adds the specified string as a value for this entity

Parameters:
value - the value to be added
Throws:
CmdLineException - if the value of the entity has already been set and multiValued is not true, or if validateValue() detects a problem.

setValue

public void setValue(java.lang.String value)
              throws CmdLineException
Sets the value of the parameter to the specified string.

Parameters:
value - the new value of the parameter
Throws:
if - validateValue() detects a problem.
CmdLineException

setValues

public void setValues(java.util.Collection values)
               throws CmdLineException
Sets the values of the parameter to those specified.

Parameters:
values - A collection of String objects to be used as the parameter's values.
Throws:
java.lang.ClassCastException - if the Collection contains object that are not Strings.
CmdLineException - if more than one value is specified and multiValued is not true, or if validateValue() detects a problem.

setValues

public void setValues(java.lang.String[] values)
               throws CmdLineException
Sets the values of the parameter to those specified.

Parameters:
values - The String objects to be used as the parameter's values.
Throws:
CmdLineException - if more than one value is specified and multiValued is not true, or if validateValue() detects a problem.

validateValue

public void validateValue(java.lang.String value)
                   throws CmdLineException
verifies that value is valid for this entity

Parameters:
value - the value to be validated
Throws:
CmdLineException - if value is not valid.

getValue

public java.lang.String getValue()
The value of the parameter, in the case where the parameter is not multi-valued. For a multi-valued parameter, the first value specified is returned.

Returns:
The value of the parameter as a String, or null if the paramter has not been set.
See Also:
getValues()

getValues

public java.util.Collection getValues()
gets the values associated with this Parameter

Returns:
The values associated with this Parameter. Note that this might be an empty Collection if the Parameter has not been set.
See Also:
isSet()

getOptionLabel

public java.lang.String getOptionLabel()
gets the value of optionLabel

Returns:
the string used as a label for the parameter's value

setOptionLabel

public void setOptionLabel(java.lang.String optionLabel)
Sets the value of optionLabel. This label will be used when the usage for the command is displayed. For instance, a date parameter might use "<mm/dd/yy>". This could then be displayed as in the following usage.
 st_date <mm/dd/yy>  the start date of the report
 
The default is the empty string.

Parameters:
optionLabel - The string used as a label for the parameter's value. If null, an empty string is used.
See Also:
getOptionLabel()

getIgnoreRequired

public boolean getIgnoreRequired()
Gets the flag indicating that during parse, missing required Parameters are ignored if this Parameter is set. Typically used by Parameters that cause an action then call System.exit(), like "-help".

Returns:
true if missing required Parameters will be ignored when this Parameter is set.

setIgnoreRequired

public void setIgnoreRequired(boolean ignoreRequired)
Sets a flag such that during parse, missing required Parameters are ignored if this Parameter is set. Typically used by Parameters that cause an action then call System.exit(), like "-help".

Parameters:
ignoreRequired - set to true to ignore missing required Parameters if this Parameter is set
See Also:
getIgnoreRequired()