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.logging.AbstractLoggable
      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
All Implemented Interfaces:
Loggable
Direct Known Subclasses:
ClassParameter, FileParameter, ListParameter, NumberParameter, PatternParameter, StringParameter

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
name, shortDescription, value
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
Parameter(OptionID optionID)
          Constructs a parameter with the given optionID.
Parameter(String name, String description)
          Deprecated.  
 
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 getDescription()
          Returns the extended description of the option which includes the option's type, the short description and the default value (if specified).
protected abstract  String getParameterType()
          Returns a string representation of the parameter's type (e.g. an IntParameter should return <int>).
 T getValue()
          Returns the value of the option.
 boolean hasDefaultValue()
          Checks if this parameter has a default value.
 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, getShortDescription, isValid, setShortDescription, setValue
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
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 List<ParameterConstraint<C>> constraints
Holds parameter constraints for this parameter.

Constructor Detail

Parameter

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

Parameters:
optionID - the unique id of the option

Parameter

@Deprecated
public Parameter(String name,
                            String description)
Deprecated. 

Constructs a parameter with the given name and description.

Parameters:
name - the parameter name
description - the parameter description
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.
See Also:
Option.isSet()

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
See Also:
Option.getValue()

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.

reset

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


getDescription

public final String getDescription()
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:
getDescription in class Option<T>
Returns:
the option's description.
See Also:
Option.getDescription()

getParameterType

protected abstract String getParameterType()
Returns a string representation of the parameter's type (e.g. an IntParameter should return <int>).

Returns:
a string representation of the parameter's type

Release 0.1 (2008-07-10_1838)