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:
Loggable, Parameterizable
Direct Known Subclasses:
AbstractAlgorithm, AbstractDatabase, AbstractDatabaseConnection, AbstractMeasurementFunction, AbstractNormalization, AbstractParser, AbstractPCA, CompositeEigenPairFilter, DiSHPreprocessor, DummyNormalization, FirstNEigenPairFilter, FracClusPreprocessor, HiCOPreprocessor, HiSCPreprocessor, KDDTask, KernelMatrix, LimitEigenPairFilter, NormalizingEigenPairFilter, PercentageEigenPairFilter, ProjectedDBSCANPreprocessor, SharedNearestNeighborsPreprocessor, TreeIndex

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  String[] currentParameterArray
          Holds the currently set parameter array.
protected  OptionHandler optionHandler
          OptionHandler for handling options.
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
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.
 void checkGlobalParameterConstraints()
          Checks if all global parameter constraints are kept
protected  void deleteOption(Option<?> option)
          Deletes the given Option from the set of Options known to this Parameterizable.
 String description()
          Returns a description of the class and the required parameters.
protected  String description(String message)
          Returns an usage-String by calling OptionHandler.usage(String).
protected  String description(String message, boolean standalone)
          Returns an usage-String by calling OptionHandler.usage(String,boolean).
 List<AttributeSettings> getAttributeSettings()
          Returns the settings of all options assigned to the option handler.
 String[] getParameters()
          Returns the parameter array as given to the last call of setParameters(String[]) but without unnecessary entries.
protected
<T> T
getParameterValue(Parameter<T,?> parameter)
          Returns the value of the given parameter by calling Parameter.getValue().
 Option<?>[] getPossibleOptions()
          Returns an array containing all options of this parameterizable object
 String inlineDescription()
          Returns a description of the class and the required parameters.
protected  boolean isSet(Option<?> option)
          Returns true if the value of the given option is set, false otherwise.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
protected  void setParameters(String[] complete, String[] part)
          Sets the difference of the first array minus the second array as the currently set parameter array.
 
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

optionHandler

protected OptionHandler optionHandler
OptionHandler for handling options.


currentParameterArray

private String[] currentParameterArray
Holds the currently set parameter array.

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

deleteOption

protected void deleteOption(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

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

setParameters

protected final void setParameters(String[] complete,
                                   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 String[] getParameters()
Description copied from interface: Parameterizable
Returns the parameter array as given to the last call of setParameters(String[]) but without unnecessary entries. The provided array should be suitable to call setParameters(String[]) 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(String[]) but without unnecessary entries
See Also:
Parameterizable.getParameters()

getAttributeSettings

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

Specified by:
getAttributeSettings in interface Parameterizable
Returns:
the setting of the attributes of the parameterizable
See Also:
Parameterizable.getAttributeSettings()

description

public String description()
Description copied from interface: Parameterizable
Returns a description of the class and the required parameters.

This description should be suitable for a usage description as for a standalone application.

Specified by:
description in interface Parameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.description()

inlineDescription

public String inlineDescription()
Description copied from interface: Parameterizable
Returns a description of the class and the required parameters.

This description should be suitable for a usage description as for an inline application, i.e. the usage of a Parameterizable within another Parameterizable where this Parameterizable is not a parameter itself but is used and expects parameters.

Specified by:
inlineDescription in interface Parameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.inlineDescription()

description

protected String description(String message)
Returns an usage-String by calling OptionHandler.usage(String).

Parameters:
message - some error-message, if needed (may be null or empty String)
Returns:
an usage-String

description

protected String description(String message,
                             boolean standalone)
Returns an usage-String by calling OptionHandler.usage(String,boolean).

Parameters:
message - some error-message, if needed (may be null or empty String)
standalone - whether the class using the OptionHandler provides a main method
Returns:
an usage-String

isSet

protected boolean isSet(Option<?> option)
Returns true if the value of the given option is set, false otherwise.

Parameters:
option - The option should be asked for without leading "-" or closing ":".
Returns:
boolean true if the value of the given option is set, false otherwise
See Also:
OptionHandler.isSet(Option)

getParameterValue

protected <T> T getParameterValue(Parameter<T,?> parameter)
                       throws IllegalStateException
Returns the value of the given parameter by calling Parameter.getValue().

Parameters:
parameter - the parameter to get the value of
Returns:
the value of given parameter
Throws:
IllegalStateException - if this Parameterizable object has not been initialized properly (e.g. the setParameters(String[]) method has been failed to be called).
See Also:
Parameter.getValue()

getPossibleOptions

public Option<?>[] getPossibleOptions()
Description copied from interface: Parameterizable
Returns an array containing all options of this parameterizable object

Specified by:
getPossibleOptions in interface Parameterizable
Returns:
the options of this parameterizable object
See Also:
Parameterizable.getPossibleOptions()

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
See Also:
Parameterizable.checkGlobalParameterConstraints()

Release 0.1 (2008-07-10_1838)