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>>
children
Tree information: child links(package private) Parameterization
inner
Inner parameterization(package private) java.util.List<TrackedParameter>
options
Tracking storage(package private) java.lang.Object
owner
Current parent for nested parameterization(package private) java.util.Map<java.lang.Object,java.lang.Object>
parents
Tree information: parent links
-
Constructor Summary
Constructors Modifier Constructor Description TrackParameters(Parameterization inner)
Constructor.TrackParameters(Parameterization inner, java.lang.Object owner)
Constructor.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Parameterization
descend(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.Object
getParent(java.lang.Object pos)
Traverse the tree upwards.boolean
grab(Parameter<?> opt)
Get the option value from the Parameterization.boolean
hasUnusedParameters()
Check for unused parametersprivate void
registerChild(java.lang.Object opt)
void
reportError(ParameterException e)
Report a configuration error.boolean
setValueForOption(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:Parameterization
Get the configuration errors thrown inParameterization.grab(elki.utilities.optionhandling.parameters.Parameter<?>)
- Specified by:
getErrors
in interfaceParameterization
- Returns:
- Configuration errors encountered
-
grab
public 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(elki.utilities.optionhandling.parameters.Parameter<?>)
can returntrue
whenFlag.getValue()
returnsfalse
! Instead the semantics ofgrab
are those ofParameter#isDefined()
.This method will catch
ParameterException
s and store them to be retrieved byParameterization.getErrors()
.- Specified by:
grab
in interfaceParameterization
- Parameters:
opt
- Option to add- Returns:
- if the value is available (= readable)
-
hasUnusedParameters
public boolean hasUnusedParameters()
Description copied from interface:Parameterization
Check for unused parameters- Specified by:
hasUnusedParameters
in interfaceParameterization
- Returns:
true
if at least one parameter was not consumed
-
reportError
public void reportError(ParameterException e)
Description copied from interface:Parameterization
Report a configuration error.- Specified by:
reportError
in interfaceParameterization
- Parameters:
e
- Destination to report errors to
-
setValueForOption
public boolean setValueForOption(Parameter<?> opt) throws ParameterException
Description copied from interface:Parameterization
Assign a value for an option, but not using default values and throwing exceptions on error.- Specified by:
setValueForOption
in 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:
descend
in 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
-
-