Package adams.core.option
Class AbstractOption
- java.lang.Object
-
- adams.core.option.AbstractOption
-
- All Implemented Interfaces:
CleanUpHandler
,Serializable
- Direct Known Subclasses:
AbstractArgumentOption
public abstract class AbstractOption extends Object implements Serializable, CleanUpHandler
The ancestor of all option classes.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Commandline
the commandline option, without the leading "-".protected boolean
m_Debug
whether debugging is enabled.protected Object
m_DefaultValue
the default value for this option.protected UserMode
m_MinUserMode
in what usermode to show this option.protected boolean
m_OutputDefaultValue
whether to output the default value for this option.protected OptionManager
m_Owner
the owning object.protected String
m_Property
the bean property to use for getting/setting.static String
TOOLTIP_SUFFIX
the tooltip suffix for properties.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractOption(OptionManager owner, String commandline, String property, Object defValue, boolean outputDefValue, UserMode minUserMode)
Initializes the option.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Cleans up data structures, frees up memory.String
getCommandline()
Returns the commandline options string, without the "-".Object
getCurrentValue()
Returns the current value for this option (obtained via the get-method).boolean
getDebug()
Returns whether debugging output is enabled.Object
getDefaultValue()
Returns the default value for this option.PropertyDescriptor
getDescriptor()
Returns the bean property descriptor for the get/set methods.UserMode
getMinUserMode()
Returns the minimum user mode before this option is displayed.OptionHandler
getOptionHandler()
Returns the option handler this option belongs to.boolean
getOutputDefaultValue()
Returns whether the default value is to be output or not in help strings, etc.OptionManager
getOwner()
Returns the owning object.String
getProperty()
Returns the property used for getting/setting the option.protected Method
getReadMethod()
Returns the read method for the property.Method
getToolTipMethod()
Returns the method for obtaining the tooltip.protected Method
getWriteMethod()
Returns the write method for the property.boolean
setCurrentValue(Object value)
Sets the current value.
-
-
-
Field Detail
-
TOOLTIP_SUFFIX
public static final String TOOLTIP_SUFFIX
the tooltip suffix for properties.- See Also:
- Constant Field Values
-
m_Owner
protected OptionManager m_Owner
the owning object.
-
m_Commandline
protected String m_Commandline
the commandline option, without the leading "-".
-
m_Property
protected String m_Property
the bean property to use for getting/setting.
-
m_DefaultValue
protected Object m_DefaultValue
the default value for this option.
-
m_OutputDefaultValue
protected boolean m_OutputDefaultValue
whether to output the default value for this option.
-
m_Debug
protected boolean m_Debug
whether debugging is enabled.
-
m_MinUserMode
protected UserMode m_MinUserMode
in what usermode to show this option.
-
-
Constructor Detail
-
AbstractOption
protected AbstractOption(OptionManager owner, String commandline, String property, Object defValue, boolean outputDefValue, UserMode minUserMode)
Initializes the option.- Parameters:
owner
- the owner of this optioncommandline
- the commandline string to identify the option (no leading dash)property
- the name of the bean propertydefValue
- the default value, if null then the owner's current state is usedoutputDefValue
- whether to output the default value or not when listing the optionsminUserMode
- the minimum user mode before showing this option
-
-
Method Detail
-
getDebug
public boolean getDebug()
Returns whether debugging output is enabled.- Returns:
- true if debugging output is enabled
-
getMinUserMode
public UserMode getMinUserMode()
Returns the minimum user mode before this option is displayed.- Returns:
- the minimum user mode
-
getOwner
public OptionManager getOwner()
Returns the owning object.- Returns:
- the owner of this option
-
getOptionHandler
public OptionHandler getOptionHandler()
Returns the option handler this option belongs to.- Returns:
- the owning OptionHandler
-
getCommandline
public String getCommandline()
Returns the commandline options string, without the "-".- Returns:
- the commandline string
-
getProperty
public String getProperty()
Returns the property used for getting/setting the option.- Returns:
- the property responsible for getting/setting
-
getDefaultValue
public Object getDefaultValue()
Returns the default value for this option.- Returns:
- the default value
-
getCurrentValue
public Object getCurrentValue()
Returns the current value for this option (obtained via the get-method).- Returns:
- the current value
-
setCurrentValue
public boolean setCurrentValue(Object value)
Sets the current value.- Parameters:
value
- the value to set- Returns:
- true if successfully set
-
getOutputDefaultValue
public boolean getOutputDefaultValue()
Returns whether the default value is to be output or not in help strings, etc.- Returns:
- true if the default value is to be output
-
getDescriptor
public PropertyDescriptor getDescriptor()
Returns the bean property descriptor for the get/set methods. Should never be null, unless the property cannot be found in the owner.- Returns:
- the bean property descriptor
-
getToolTipMethod
public Method getToolTipMethod()
Returns the method for obtaining the tooltip. Can be null, if no corresponding tooltip was found for the property.- Returns:
- the method for returning the tooltip, can be null
-
getReadMethod
protected Method getReadMethod()
Returns the read method for the property.- Returns:
- the method, null if no property descriptor available
-
getWriteMethod
protected Method getWriteMethod()
Returns the write method for the property.- Returns:
- the method, null if no property descriptor available
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-