de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization
Class AbstractParameterization

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.AbstractParameterization
All Implemented Interfaces:
Parameterization
Direct Known Subclasses:
ChainedParameterization, EmptyParameterization, ListParameterization, SerializedParameterization

public abstract class AbstractParameterization
extends Object
implements Parameterization

Abstract class with shared code for parameterization handling.


Field Summary
(package private)  Vector<ParameterException> errors
          Errors
private static Logging logger
          The logger of the class.
 
Constructor Summary
AbstractParameterization()
           
 
Method Summary
 boolean checkConstraint(GlobalParameterConstraint constraint)
          Check a parameter constraint.
 void clearErrors()
          Clear errors.
 void failOnErrors()
          Fail on errors, log any error that had occurred.
 void finalize()
          Upon destruction, report any errors that weren't handled yet.
 Collection<ParameterException> getErrors()
          Get the configuration errors thrown in Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter)
 boolean grab(Parameter<?,?> opt)
          Get the option value from the Parameterization.
 boolean hasErrors()
          Return true when there have been errors.
 void logAndClearReportedErrors()
          Log any error that has accumulated.
 void reportError(ParameterException e)
          Report a configuration error.
 void reportInternalParameterizationErrors(Parameterization config)
          Report the internal parameterization errors to another parameterization
abstract  boolean setValueForOption(Parameter<?,?> opt)
          Perform the actual parameter assignment.
<C> C
tryInstantiate(Class<C> c)
          Try to instantiate a particular class.
<C> C
tryInstantiate(Class<C> r, Class<?> c)
          Try to instantiate a particular class.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization
descend, hasUnusedParameters
 

Field Detail

errors

Vector<ParameterException> errors
Errors


logger

private static final Logging logger
The logger of the class.

Constructor Detail

AbstractParameterization

public AbstractParameterization()
Method Detail

getErrors

public Collection<ParameterException> getErrors()
Description copied from interface: Parameterization
Get the configuration errors thrown in Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter)

Specified by:
getErrors in interface Parameterization
Returns:
Configuration errors encountered

hasErrors

public boolean hasErrors()
Description copied from interface: Parameterization
Return true when there have been errors.

Specified by:
hasErrors in interface Parameterization
Returns:
Success code

reportError

public void reportError(ParameterException e)
Description copied from interface: Parameterization
Report a configuration error.

Specified by:
reportError in interface Parameterization
Parameters:
e - Destination to report errors to

logAndClearReportedErrors

public void logAndClearReportedErrors()
Log any error that has accumulated.


clearErrors

public void clearErrors()
Clear errors.


failOnErrors

public void failOnErrors()
                  throws RuntimeException
Fail on errors, log any error that had occurred.

Throws:
RuntimeException - if any error has occurred.

reportInternalParameterizationErrors

public void reportInternalParameterizationErrors(Parameterization config)
Report the internal parameterization errors to another parameterization

Parameters:
config - Other parameterization

grab

public final boolean grab(Parameter<?,?> opt)
Description copied from interface: Parameterization
Get the option value from the Parameterization. Note: this method returns success; the actual value can be obtained from opt itself! In particular Parameterization.grab(de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter) can return true when Flag.getValue() returns false! Instead the semantics of grab are those of Parameter#isDefined(). This method will catch ParameterExceptions and store them to be retrieved by Parameterization.getErrors().

Specified by:
grab in interface Parameterization
Parameters:
opt - Option to add
Returns:
if the value is available (= readable)

setValueForOption

public abstract boolean setValueForOption(Parameter<?,?> opt)
                                   throws ParameterException
Perform the actual parameter assignment.

Specified by:
setValueForOption in interface Parameterization
Parameters:
opt - Option to be set
Returns:
Success code (value available)
Throws:
ParameterException - on assignment errors.

finalize

public void finalize()
Upon destruction, report any errors that weren't handled yet.

Overrides:
finalize in class Object

checkConstraint

public boolean checkConstraint(GlobalParameterConstraint constraint)
Description copied from interface: Parameterization
Check a parameter constraint.

Specified by:
checkConstraint in interface Parameterization
Parameters:
constraint - Parameter constraint
Returns:
test result

tryInstantiate

public <C> C tryInstantiate(Class<C> r,
                            Class<?> c)
Description copied from interface: Parameterization
Try to instantiate a particular class.

Specified by:
tryInstantiate in interface Parameterization
Type Parameters:
C - return type
Parameters:
r - Restriction class
c - Base class
Returns:
class instance or null

tryInstantiate

public <C> C tryInstantiate(Class<C> c)
Description copied from interface: Parameterization
Try to instantiate a particular class.

Specified by:
tryInstantiate in interface Parameterization
Type Parameters:
C - return type
Parameters:
c - Base class
Returns:
class instance or null

Release 0.4.0 (2011-09-20_1324)