Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.optionhandling
Class AbstractParameterizable

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
All Implemented Interfaces:
Parameterizable
Direct Known Subclasses:
AbstractAlgorithm, AbstractApplication, AbstractDatabase, AbstractDatabaseConnection, AbstractMeasurementFunction, AbstractNormalization, AbstractParser, CompositeEigenPairFilter, CovarianceMatrixBuilder, DiscardResultHandler, DiSHPreprocessor, DummyNormalization, FirstNEigenPairFilter, HiCOPreprocessor, HiSCPreprocessor, KernelMatrix, LimitEigenPairFilter, MaterializeKNNPreprocessor, MetaParser, NormalizingEigenPairFilter, PCARunner, PercentageEigenPairFilter, PreprocessorHandler, ProgressiveEigenPairFilter, ProjectedDBSCANPreprocessor, RelativeEigenPairFilter, ResultROCCurveVisualizer, ResultWriter, SharedNearestNeighborsPreprocessor, SignificantEigenPairFilter, TreeIndex, WeakEigenPairFilter

public abstract class AbstractParameterizable
extends AbstractLoggable
implements Parameterizable

Abstract superclass for classes parameterizable. Provides the option handler and the parameter array.

Author:
Elke Achtert

Field Summary
private  List<String> currentParameterArrayList
          Holds the currently set parameter array.
protected  OptionHandler optionHandler
          OptionHandler for handling options.
private  List<Pair<Parameterizable,List<OptionID>>> parameterizables
          Hold parameterizables contained
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
AbstractParameterizable()
          Creates a new AbstractParameterizable that provides the option handler and the parameter array.
 
Method Summary
protected  void addOption(Option<?> option)
          Adds the given Option to the set of Options known to this Parameterizable.
protected  void addParameterizable(Parameterizable p)
          Add a new parameterizable to the list.
protected  void addParameterizable(Parameterizable p, List<OptionID> override)
          Add a new parameterizable to the list.
 void checkGlobalParameterConstraints()
          Checks if all global parameter constraints are kept
 void collectOptions(List<Pair<Parameterizable,Option<?>>> collection)
          Get all possible options.
 List<AttributeSettings> getAttributeSettings()
          Returns the settings of all options assigned to the option handler.
 ArrayList<String> getParameters()
          Returns the parameter array as given to the last call of setParameters(List) but without unnecessary entries.
protected  void rememberParametersExcept(List<String> complete, List<String> part)
          Sets the difference of the first array minus the second array as the currently set parameter array.
protected  void removeOption(Option<?> option)
          Deletes the given Option from the set of Options known to this Parameterizable.
protected  void removeParameterizable(Parameterizable p)
          Remove a parameterizable from the list.
 List<String> setParameters(List<String> args)
          Grabs all specified options from the option handler.
 String shortDescription()
          Returns a short description of the class.
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

optionHandler

protected OptionHandler optionHandler
OptionHandler for handling options.


currentParameterArrayList

private List<String> currentParameterArrayList
Holds the currently set parameter array.


parameterizables

private List<Pair<Parameterizable,List<OptionID>>> parameterizables
Hold parameterizables contained

Constructor Detail

AbstractParameterizable

public AbstractParameterizable()
Creates a new AbstractParameterizable that provides the option handler and the parameter array.

Method Detail

addOption

protected void addOption(Option<?> option)
Adds the given Option to the set of Options known to this Parameterizable.

Parameters:
option - the Option to add to the set of known Options of this Parameterizable

removeOption

protected void removeOption(Option<?> option)
                     throws UnusedParameterException
Deletes the given Option from the set of Options known to this Parameterizable.

Parameters:
option - the Option to remove from the set of Options known to this Parameterizable
Throws:
UnusedParameterException - if the given Option is unknown

addParameterizable

protected void addParameterizable(Parameterizable p)
Add a new parameterizable to the list. Used for listing options and settings.

Parameters:
p - parameterizable

addParameterizable

protected void addParameterizable(Parameterizable p,
                                  List<OptionID> override)
Add a new parameterizable to the list. Used for listing options and settings.

Parameters:
p - parameterizable
override - overridden parameters

removeParameterizable

protected void removeParameterizable(Parameterizable p)
Remove a parameterizable from the list. Used for listing options and settings.

Parameters:
p - parameterizable to remove

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Grabs all specified options from the option handler. Any extending class should call this method first and return the returned array without further changes, but after setting further required parameters. An example for overwriting this method taking advantage from the previously (in superclasses) defined options would be:

 {
   List remainingParameters = super.setParameters(args);
   // set parameters for your class
   // for example like this:
   if(isSet(MY_PARAM_VALUE_PARAM))
   {
      myParamValue = getParameterValue(MY_PARAM_VALUE_PARAM);
   }
   .
   .
   .
   return remainingParameters;
   // or in case of attributes requesting parameters themselves
   // return parameterizableAttribbute.setParameters(remainingParameters);
 }
 

Specified by:
setParameters in interface Parameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

rememberParametersExcept

protected final void rememberParametersExcept(List<String> complete,
                                              List<String> part)
Sets the difference of the first array minus the second array as the currently set parameter array.

Parameters:
complete - the complete array
part - an array that contains only elements of the first array

getParameters

public final ArrayList<String> getParameters()
Description copied from interface: Parameterizable
Returns the parameter array as given to the last call of setParameters(List) but without unnecessary entries. The provided array should be suitable to call setParameters(List) with it resulting in the identical parameterization.

Specified by:
getParameters in interface Parameterizable
Returns:
the parameter array as given to the last call of setParameters(List) but without unnecessary entries

getAttributeSettings

public List<AttributeSettings> getAttributeSettings()
Returns the settings of all options assigned to the option handler.

Returns:
the settings of all options assigned to the option handler

shortDescription

public String shortDescription()
Returns a short description of the class.

Specified by:
shortDescription in interface Parameterizable
Returns:
Description of the class

checkGlobalParameterConstraints

public void checkGlobalParameterConstraints()
                                     throws ParameterException
Description copied from interface: Parameterizable
Checks if all global parameter constraints are kept

Specified by:
checkGlobalParameterConstraints in interface Parameterizable
Throws:
ParameterException - if the parameters don't satisfy the parameter constraints
See Also:
OptionHandler.checkGlobalParameterConstraints()

collectOptions

public void collectOptions(List<Pair<Parameterizable,Option<?>>> collection)
Get all possible options.

Specified by:
collectOptions in interface Parameterizable
Parameters:
collection - existing collection to add to.

Release 0.2 (2009-07-06_1820)