Class TrackParameters
- java.lang.Object
-
- elki.utilities.optionhandling.parameterization.TrackParameters
-
- All Implemented Interfaces:
Parameterization
public class TrackParameters extends java.lang.Object implements Parameterization
Utility wrapper to track parameters for a configuration session.All actual Parameterization operations are forwarded to the inner class.
- Since:
- 0.3
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Map<java.lang.Object,java.util.List<java.lang.Object>>childrenTree information: child links(package private) ParameterizationinnerInner parameterization(package private) java.util.List<TrackedParameter>optionsTracking storage(package private) java.lang.ObjectownerCurrent parent for nested parameterization(package private) java.util.Map<java.lang.Object,java.lang.Object>parentsTree information: parent links
-
Constructor Summary
Constructors Modifier Constructor Description TrackParameters(Parameterization inner)Constructor.TrackParameters(Parameterization inner, java.lang.Object owner)Constructor.privateTrackParameters(Parameterization inner, java.lang.Object owner, java.util.List<TrackedParameter> options, java.util.Map<java.lang.Object,java.lang.Object> parents, java.util.Map<java.lang.Object,java.util.List<java.lang.Object>> children)Internal constructor, for nested tracking.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parameterizationdescend(java.lang.Object option)Descend parameterization tree into sub-option.java.util.Collection<TrackedParameter>getAllParameters()Get all seen parameters, set or unset, along with their owner objects.java.util.Collection<ParameterException>getErrors()Get the configuration errors thrown inParameterization.grab(elki.utilities.optionhandling.parameters.Parameter<?>)java.lang.ObjectgetParent(java.lang.Object pos)Traverse the tree upwards.booleangrab(Parameter<?> opt)Get the option value from the Parameterization.booleanhasUnusedParameters()Check for unused parametersprivate voidregisterChild(java.lang.Object opt)voidreportError(ParameterException e)Report a configuration error.booleansetValueForOption(Parameter<?> opt)Assign a value for an option, but not using default values and throwing exceptions on error.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.utilities.optionhandling.parameterization.Parameterization
hasErrors, tryInstantiate
-
-
-
-
Field Detail
-
inner
Parameterization inner
Inner parameterization
-
options
java.util.List<TrackedParameter> options
Tracking storage
-
parents
java.util.Map<java.lang.Object,java.lang.Object> parents
Tree information: parent links
-
children
java.util.Map<java.lang.Object,java.util.List<java.lang.Object>> children
Tree information: child links
-
owner
java.lang.Object owner
Current parent for nested parameterization
-
-
Constructor Detail
-
TrackParameters
public TrackParameters(Parameterization inner)
Constructor.- Parameters:
inner- Inner parameterization to wrap.
-
TrackParameters
public TrackParameters(Parameterization inner, java.lang.Object owner)
Constructor.- Parameters:
inner- Inner parameterization to wrap.owner- Class/instance owning the parameter
-
TrackParameters
private TrackParameters(Parameterization inner, java.lang.Object owner, java.util.List<TrackedParameter> options, java.util.Map<java.lang.Object,java.lang.Object> parents, java.util.Map<java.lang.Object,java.util.List<java.lang.Object>> children)
Internal constructor, for nested tracking.- Parameters:
inner- Inner parameterizationowner- Object owning the current parametersoptions- List of optionsparents- Parent mapchildren- Child map
-
-
Method Detail
-
getErrors
public java.util.Collection<ParameterException> getErrors()
Description copied from interface:ParameterizationGet the configuration errors thrown inParameterization.grab(elki.utilities.optionhandling.parameters.Parameter<?>)- Specified by:
getErrorsin interfaceParameterization- Returns:
- Configuration errors encountered
-
grab
public boolean grab(Parameter<?> opt)
Description copied from interface:ParameterizationGet the option value from the Parameterization.Note: this method returns success; the actual value can be obtained from
optitself!In particular
Parameterization.grab(elki.utilities.optionhandling.parameters.Parameter<?>)can returntruewhenFlag.getValue()returnsfalse! Instead the semantics ofgrabare those ofParameter#isDefined().This method will catch
ParameterExceptions and store them to be retrieved byParameterization.getErrors().- Specified by:
grabin interfaceParameterization- Parameters:
opt- Option to add- Returns:
- if the value is available (= readable)
-
hasUnusedParameters
public boolean hasUnusedParameters()
Description copied from interface:ParameterizationCheck for unused parameters- Specified by:
hasUnusedParametersin interfaceParameterization- Returns:
trueif at least one parameter was not consumed
-
reportError
public void reportError(ParameterException e)
Description copied from interface:ParameterizationReport a configuration error.- Specified by:
reportErrorin interfaceParameterization- Parameters:
e- Destination to report errors to
-
setValueForOption
public boolean setValueForOption(Parameter<?> opt) throws ParameterException
Description copied from interface:ParameterizationAssign a value for an option, but not using default values and throwing exceptions on error.- Specified by:
setValueForOptionin interfaceParameterization- Parameters:
opt- Parameter to set- Returns:
- Success code
- Throws:
ParameterException- on assignment errors.
-
getAllParameters
public java.util.Collection<TrackedParameter> getAllParameters()
Get all seen parameters, set or unset, along with their owner objects.- Returns:
- Parameters seen
-
descend
public Parameterization descend(java.lang.Object option)
Descend parameterization tree into sub-option.Note: this is done automatically by a
ClassParameter.instantiateClass(elki.utilities.optionhandling.parameterization.Parameterization). You only need to call this when you want to expose the tree structure without offering a class choice as parameter.Track parameters using a shared options list with parent tracker.
- Specified by:
descendin interfaceParameterization- Parameters:
option- Option subtree- Returns:
- Parameterization
-
registerChild
private void registerChild(java.lang.Object opt)
-
getParent
public java.lang.Object getParent(java.lang.Object pos)
Traverse the tree upwards.- Parameters:
pos- Current object- Returns:
- Parent object
-
-