de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters
Class Flag

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter<Boolean,Boolean>
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Flag

public class Flag
extends Parameter<Boolean,Boolean>

Option class specifying a flag object.

A flag object is optional parameter which can be set (value "true") or not (value "false").


Field Summary
static String NOT_SET
          Constant indicating that the flag is not set.
static String SET
          Constant indicating that the flag is set.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter
constraints, defaultValue, givenValue, optionalParameter, optionid, shortDescription
 
Constructor Summary
Flag(OptionID optionID)
          Constructs a flag object with the given optionID.
 
Method Summary
 String getSyntax()
          A flag has no syntax, since it doesn't take extra options
 String getValueAsString()
          Get the value as string.
 boolean isFalse()
          Shorthand for isDefined() && getValue() == false
 boolean isTrue()
          Shorthand for isDefined() && getValue() == true
protected  Boolean parseValue(Object obj)
          Parse a given value into the destination type.
 void setValue(boolean val)
          Convenience function using a native boolean, that doesn't require error handling.
protected  boolean validate(Boolean obj)
          Validate a value after parsing (e.g. do constrain checks!)
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter
addConstraint, getDefaultValue, getDefaultValueAsString, getFullDescription, getGivenValue, getName, getOptionID, getShortDescription, getValue, getValuesDescription, hasDefaultValue, hasValuesDescription, 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

SET

public static final String SET
Constant indicating that the flag is set.

See Also:
Constant Field Values

NOT_SET

public static final String NOT_SET
Constant indicating that the flag is not set.

See Also:
Constant Field Values
Constructor Detail

Flag

public Flag(OptionID optionID)
Constructs a flag object with the given optionID.

If the flag is not set its value is "false".

Parameters:
optionID - the unique id of the option
Method Detail

parseValue

protected Boolean parseValue(Object obj)
                      throws ParameterException
Description copied from class: Parameter
Parse a given value into the destination type.

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

getSyntax

public String getSyntax()
A flag has no syntax, since it doesn't take extra options

Specified by:
getSyntax in class Parameter<Boolean,Boolean>
Returns:
a string representation of the parameter's type

getValueAsString

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

Specified by:
getValueAsString in class Parameter<Boolean,Boolean>
Returns:
Value as string

validate

protected boolean validate(Boolean obj)
                    throws ParameterException
Validate a value after parsing (e.g. do constrain checks!)

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

setValue

public void setValue(boolean val)
Convenience function using a native boolean, that doesn't require error handling.

Parameters:
val - boolean value

isTrue

public boolean isTrue()
Shorthand for isDefined() && getValue() == true

Returns:
true when defined and true.

isFalse

public boolean isFalse()
Shorthand for isDefined() && getValue() == false

Returns:
true when defined and true.

Release 0.4.0 (2011-09-20_1324)