Package adams.core.option
Class StringOption
- java.lang.Object
-
- adams.core.option.AbstractOption
-
- adams.core.option.AbstractArgumentOption
-
- adams.core.option.StringOption
-
- All Implemented Interfaces:
CleanUpHandler,VariableChangeListener,Serializable
public class StringOption extends AbstractArgumentOption
Handles options with string arguments.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractArgumentOption
m_BaseClass, m_Multiple, m_Variable, m_VariableModified, m_VariableReferencesObject
-
Fields inherited from class adams.core.option.AbstractOption
m_Commandline, m_Constraint, m_Debug, m_DefaultValue, m_MinUserMode, m_OutputDefaultValue, m_Owner, m_Property, TOOLTIP_SUFFIX
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStringOption(OptionManager owner, String commandline, String property, Object defValue)Initializes the option.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancompareValues(Object value, Object defValue)Compares the two values.protected booleanisParseable(String s)Allows additional checks whether to include that particular string represents a valid option, i.e., is parseable.StringtoString(Object obj)Returns a string representation of the specified object.StringvalueOf(String s)Turns the string into the appropriate object.-
Methods inherited from class adams.core.option.AbstractArgumentOption
cleanUp, getBaseClass, getVariable, getVariableName, hasBaseClass, isDefaultValue, isDefaultValue, isMultiple, isVariableAttached, isVariableModified, isVariableReferencingObject, setVariable, toArray, toString, updateVariable, updateVariable, updateVariable, variableChanged
-
Methods inherited from class adams.core.option.AbstractOption
dontOutputDefaultValue, getCommandline, getConstraint, getCurrentValue, getDebug, getDefaultValue, getDescriptor, getMinUserMode, getOptionHandler, getOutputDefaultValue, getOwner, getProperty, getReadMethod, getToolTipMethod, getWriteMethod, hasConstraint, isValid, noConstraint, setConstraint, setCurrentValue, setMinUserMode, setOutputDefaultValue
-
-
-
-
Constructor Detail
-
StringOption
protected StringOption(OptionManager owner, String commandline, String property, Object defValue)
Initializes the option. Will always output the default value.- Parameters:
owner- the owner of this optioncommandline- the commandline string to identify the option (no leading dash)property- the name of bean propertydefValue- the default value, if null then the owner's current state is used
-
-
Method Detail
-
compareValues
protected boolean compareValues(Object value, Object defValue)
Compares the two values.- Specified by:
compareValuesin classAbstractArgumentOption- Parameters:
value- the value to compare against the default valuedefValue- the default value to compare against- Returns:
- true if both are equal
-
valueOf
public String valueOf(String s) throws Exception
Turns the string into the appropriate object.- Specified by:
valueOfin classAbstractArgumentOption- Parameters:
s- the string to parse- Returns:
- the generated object
- Throws:
Exception- if parsing of string fails
-
isParseable
protected boolean isParseable(String s)
Allows additional checks whether to include that particular string represents a valid option, i.e., is parseable.
Any string is valid, even empty ones.- Parameters:
s- the option string to test.- Returns:
- always true
-
toString
public String toString(Object obj)
Returns a string representation of the specified object.- Specified by:
toStringin classAbstractArgumentOption- Parameters:
obj- the object to turn into a string- Returns:
- the string representation
-
-