Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.optionhandling
Class Parameter<T,C>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.Option<T>
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameter<T,C>
Type Parameters:
T - the type of a possible value (i.e., the type of the option)
C - the type of a possible parameter constraint
Direct Known Subclasses:
ClassParameter, FileParameter, ListParameter, NumberParameter, PatternParameter

public abstract class Parameter<T,C>
extends Option<T>

Abstract class for specifying a parameter.

A parameter is defined as an option having a specific value.

Author:
Steffi Wanka

Field Summary
protected  List<ParameterConstraint<C>> constraints
          Holds parameter constraints for this parameter.
protected  T defaultValue
          The default value of the parameter (may be null).
private  boolean defaultValueTaken
          Specifies if the default value of this parameter was taken as parameter value.
protected  boolean optionalParameter
          Specifies if this parameter is an optional parameter.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.Option
optionid, shortDescription, value
 
Constructor Summary
Parameter(OptionID optionID)
          Constructs a parameter with the given optionID.
Parameter(OptionID optionID, List<ParameterConstraint<C>> constraints)
          Constructs a parameter with the given optionID, and constraints.
Parameter(OptionID optionID, List<ParameterConstraint<C>> constraints, boolean optional, T defaultValue)
          Constructs a parameter with the given optionID, constraints, and optional flag.
Parameter(OptionID optionID, ParameterConstraint<C> constraint)
          Constructs a parameter with the given optionID, and constraint.
Parameter(OptionID optionID, ParameterConstraint<C> constraint, boolean optional, T defaultValue)
          Constructs a parameter with the given optionID, constraint, and optional flag.
 
Method Summary
protected  void addConstraint(ParameterConstraint<C> constraint)
          Adds a parameter constraint to the list of parameter constraints.
protected  void addConstraintList(List<ParameterConstraint<C>> constraints)
          Adds a list of parameter constraints to the current list of parameter constraints.
 T getDefaultValue()
          Returns the default value of the parameter.
 String getFullDescription()
          Returns the extended description of the option which includes the option's type, the short description and the default value (if specified).
 T getValue()
          Returns the value of the option.
 String getValuesDescription()
          Return a string explaining valid values.
 boolean hasDefaultValue()
          Checks if this parameter has a default value.
 boolean hasValuesDescription()
          Whether this class has a list of default values.
 boolean isOptional()
          Checks if this parameter is an optional parameter.
 boolean isSet()
          Returns true if the value of the option is set, false otherwise.
 void reset()
          Resets the value of the parameter to null.
 void setDefaultValue(T defaultValue)
          Sets the default value of this parameter.
 void setDefaultValueToValue()
          Sets the default value of this parameter as the actual value of this parameter.
 void setOptional(boolean opt)
          Specifies if this parameter is an optional parameter.
 boolean tookDefaultValue()
          Checks if the default value of this parameter was taken as the actual parameter value.
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.Option
getName, getOptionID, getShortDescription, getSyntax, isValid, setShortDescription, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultValue

protected T defaultValue
The default value of the parameter (may be null).


defaultValueTaken

private boolean defaultValueTaken
Specifies if the default value of this parameter was taken as parameter value.


optionalParameter

protected boolean optionalParameter
Specifies if this parameter is an optional parameter.


constraints

protected final List<ParameterConstraint<C>> constraints
Holds parameter constraints for this parameter.

Constructor Detail

Parameter

public Parameter(OptionID optionID,
                 List<ParameterConstraint<C>> constraints)
Constructs a parameter with the given optionID, and constraints.

Parameters:
optionID - the unique id of this parameter
constraints - the constraints of this parameter, may be empty if there are no constraints

Parameter

public Parameter(OptionID optionID,
                 ParameterConstraint<C> constraint)
Constructs a parameter with the given optionID, and constraint.

Parameters:
optionID - the unique id of this parameter
constraint - the constraint of this parameter

Parameter

public Parameter(OptionID optionID,
                 List<ParameterConstraint<C>> constraints,
                 boolean optional,
                 T defaultValue)
Constructs a parameter with the given optionID, constraints, and optional flag.

Parameters:
optionID - the unique id of this parameter
constraints - the constraints of this parameter, may be empty if there are no constraints
optional - specifies if this parameter is an optional parameter
defaultValue - the default value of this parameter (may be null)

Parameter

public Parameter(OptionID optionID,
                 ParameterConstraint<C> constraint,
                 boolean optional,
                 T defaultValue)
Constructs a parameter with the given optionID, constraint, and optional flag.

Parameters:
optionID - the unique id of this parameter
constraint - the constraint of this parameter
optional - specifies if this parameter is an optional parameter
defaultValue - the default value of this parameter (may be null)

Parameter

public Parameter(OptionID optionID)
Constructs a parameter with the given optionID.

Parameters:
optionID - the unique id of the option
Method Detail

addConstraint

protected void addConstraint(ParameterConstraint<C> constraint)
Adds a parameter constraint to the list of parameter constraints.

Parameters:
constraint - the parameter constraint to be added

addConstraintList

protected void addConstraintList(List<ParameterConstraint<C>> constraints)
Adds a list of parameter constraints to the current list of parameter constraints.

Parameters:
constraints - list of parameter constraints to be added

setDefaultValue

public void setDefaultValue(T defaultValue)
Sets the default value of this parameter.

Parameters:
defaultValue - default value of this parameter

hasDefaultValue

public boolean hasDefaultValue()
Checks if this parameter has a default value.

Returns:
true, if this parameter has a default value, false otherwise

setDefaultValueToValue

public void setDefaultValueToValue()
Sets the default value of this parameter as the actual value of this parameter.


setOptional

public void setOptional(boolean opt)
Specifies if this parameter is an optional parameter.

Parameters:
opt - true if this parameter is optional,false otherwise

isOptional

public boolean isOptional()
Checks if this parameter is an optional parameter.

Returns:
true if this parameter is optional, false otherwise

tookDefaultValue

public boolean tookDefaultValue()
Checks if the default value of this parameter was taken as the actual parameter value.

Returns:
true, if the default value was taken as actual parameter value, false otherwise

isSet

public boolean isSet()
Description copied from class: Option
Returns true if the value of the option is set, false otherwise.

Specified by:
isSet in class Option<T>
Returns:
true if the value of the option is set, false otherwise.

getValue

public T getValue()
           throws UnusedParameterException
Description copied from class: Option
Returns the value of the option.

Overrides:
getValue in class Option<T>
Returns:
the option's value.
Throws:
UnusedParameterException - is not thrown actually in this class but subclasses may require allowance to throw this Exception

getDefaultValue

public T getDefaultValue()
Returns the default value of the parameter.

If the parameter has no default value, the method returns null.

Returns:
the default value of the parameter, null if the parameter has no default value.

hasValuesDescription

public boolean hasValuesDescription()
Whether this class has a list of default values.

Returns:
whether the class has a description of valid values.

getValuesDescription

public String getValuesDescription()
Return a string explaining valid values.

Returns:
String explaining valid values (e.g. a class list)

reset

public void reset()
Resets the value of the parameter to null.


getFullDescription

public final String getFullDescription()
Description copied from class: Option
Returns the extended description of the option which includes the option's type, the short description and the default value (if specified).

Specified by:
getFullDescription in class Option<T>
Returns:
the option's description.

Release 0.2 (2009-07-06_1820)