de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters
Class ClassListParameter<C>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter<List<T>,List<T>>
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ListParameter<Class<? extends C>>
          extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ClassListParameter<C>
Type Parameters:
C - Class type
Direct Known Subclasses:
ObjectListParameter

public class ClassListParameter<C>
extends ListParameter<Class<? extends C>>

Parameter class for a parameter specifying a list of class names.


Field Summary
protected  Class<C> restrictionClass
          The restriction class for the list of class names.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ListParameter
LIST_SEP, SPLIT, VECTOR_SEP, VECTOR_SPLIT
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter
constraints, defaultValue, givenValue, optionalParameter, optionid, shortDescription
 
Constructor Summary
ClassListParameter(OptionID optionID, Class<?> restrictionClass)
          Constructs a class list parameter with the given optionID and restriction class.
ClassListParameter(OptionID optionID, Class<?> restrictionClass, boolean optional)
          Constructs a class list parameter with the given optionID and restriction class.
 
Method Summary
 IterableIterator<Class<?>> getKnownImplementations()
          Get an iterator over all known implementations of the class restriction.
 Class<C> getRestrictionClass()
          Returns the restriction class of this class parameter.
 String[] getRestrictionClasses()
          Returns the class names allowed according to the restriction class of this parameter.
 String getSyntax()
          Returns a string representation of the parameter's type.
 String getValueAsString()
          Get the value as string.
 String getValuesDescription()
          Return a description of known valid classes.
 boolean hasValuesDescription()
          This class sometimes provides a list of value descriptions.
 List<C> instantiateClasses(Parameterization config)
          Returns a list of new instances for the value (i.e., the class name) of this class list parameter.
protected  List<Class<? extends C>> parseValue(Object obj)
          Parse a given value into the destination type.
 String restrictionString()
          Provides a description string listing all classes for the given superclass or interface as specified in the properties.
protected  boolean validate(List<Class<? extends C>> obj)
          Validate a value after parsing (e.g. do constrain checks!)
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.ListParameter
asString, getListSize
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter
addConstraint, getDefaultValue, getDefaultValueAsString, getFullDescription, getGivenValue, getName, getOptionID, getShortDescription, getValue, hasDefaultValue, isDefined, isOptional, isValid, setDefaultValue, setOptional, setShortDescription, setValue, setValueInternal, tookDefaultValue, tryDefaultValue, useDefaultValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

restrictionClass

protected Class<C> restrictionClass
The restriction class for the list of class names.

Constructor Detail

ClassListParameter

public ClassListParameter(OptionID optionID,
                          Class<?> restrictionClass,
                          boolean optional)
Constructs a class list parameter with the given optionID and restriction class.

Parameters:
optionID - the unique id of this parameter
restrictionClass - the restriction class of the list of class names
optional - specifies if this parameter is an optional parameter

ClassListParameter

public ClassListParameter(OptionID optionID,
                          Class<?> restrictionClass)
Constructs a class list parameter with the given optionID and restriction class.

Parameters:
optionID - the unique id of this parameter
restrictionClass - the restriction class of the list of class names
Method Detail

getValueAsString

public String getValueAsString()
Get the value as string. May return null

Specified by:
getValueAsString in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Returns:
Value as string

parseValue

protected List<Class<? extends C>> parseValue(Object obj)
                                       throws ParameterException
Parse a given value into the destination type.

Specified by:
parseValue in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Parameters:
obj - Object to parse (may be a string representation!)
Returns:
Parsed object
Throws:
ParameterException - when the object cannot be parsed.

validate

protected boolean validate(List<Class<? extends C>> obj)
                    throws ParameterException
Validate a value after parsing (e.g. do constrain checks!)

Overrides:
validate in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Parameters:
obj - Object to validate
Returns:
true iff the object is valid for this parameter.
Throws:
ParameterException - when the object is not valid.

getRestrictionClass

public Class<C> getRestrictionClass()
Returns the restriction class of this class parameter.

Returns:
the restriction class of this class parameter.

getKnownImplementations

public IterableIterator<Class<?>> getKnownImplementations()
Get an iterator over all known implementations of the class restriction.

Returns:
Iterable and Iterator object

getRestrictionClasses

public String[] getRestrictionClasses()
Returns the class names allowed according to the restriction class of this parameter.

Returns:
class names allowed according to the restriction class defined.

getSyntax

public String getSyntax()
Returns a string representation of the parameter's type.

Specified by:
getSyntax in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Returns:
"<class_1,...,class_n>"

instantiateClasses

public List<C> instantiateClasses(Parameterization config)
Returns a list of new instances for the value (i.e., the class name) of this class list parameter. The instances have the type of the restriction class of this class list parameter.

If the Class for the class names is not found, the instantiation is tried using the package of the restriction class as package of the class name.

Parameters:
config - Parameterization to use (if Parameterizable))
Returns:
a list of new instances for the value of this class list parameter

restrictionString

public String restrictionString()
Provides a description string listing all classes for the given superclass or interface as specified in the properties.

Returns:
a description string listing all classes for the given superclass or interface as specified in the properties

hasValuesDescription

public boolean hasValuesDescription()
This class sometimes provides a list of value descriptions.

Overrides:
hasValuesDescription in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Returns:
whether the class has a description of valid values.
See Also:
Parameter.hasValuesDescription()

getValuesDescription

public String getValuesDescription()
Return a description of known valid classes.

Overrides:
getValuesDescription in class Parameter<List<Class<? extends C>>,List<Class<? extends C>>>
Returns:
String explaining valid values (e.g. a class list)
See Also:
Parameter.getValuesDescription()

Release 0.4.0 (2011-09-20_1324)