Class OptionConfigKey<T>
java.lang.Object
uk.ac.starlink.ttools.plot2.config.ConfigKey<T>
uk.ac.starlink.ttools.plot2.config.OptionConfigKey<T>
- Direct Known Subclasses:
MultiPointConfigKey, PerUnitConfigKey, SkySysConfigKey
Config key for use with items that can be chosen from a list of options.
The list is basically closed, though it may be possible programmatically
to supply an object of the required type.
For open lists of options see
ChoiceConfigKey.- Since:
- 23 Feb 2013
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionOptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options) Constructor that uses the first of the supplied options as a default.OptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options, T dflt) Constructor that specifies an explicit default and uses the default specifier type.OptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options, T dflt, boolean useRadio) Constructor that specifies an explicit default and specifier type. -
Method Summary
Modifier and TypeMethodDescriptionConvenience method to add the result ofgetOptionsXml()to the XML documentation of this key.Constructs a graphical control with which the user can specify a suitable value for association with this key.T[]Returns the available options for this key.Returns an XML list of the available options for this config key.abstract StringgetXmlDescription(T value) Returns a description in XML of the given option value.Sets the usage string based on the currently configured options.stringToValue(String txt) CallsvalueToStringrepeatedly looking for a match.valueToString(T value) Invokes thetoStringmethod of the supplied option.Methods inherited from class ConfigKey
cast, getDefaultValue, getMeta, getValueClass, toString
-
Constructor Details
-
OptionConfigKey
Constructor that specifies an explicit default and specifier type.- Parameters:
meta- metadataclazz- class to which all the possible options belongoptions- array of possible values for this keydflt- default option, should be one ofoptionsuseRadio- true to use radio buttons, false for a combo box
-
OptionConfigKey
Constructor that specifies an explicit default and uses the default specifier type.- Parameters:
meta- metadataclazz- class to which all the possible options belongoptions- array of possible values for this keydflt- default option, should be one ofoptions
-
OptionConfigKey
Constructor that uses the first of the supplied options as a default.- Parameters:
meta- metadataclazz- class to which all the possible options belongoptions- array of possible values for this key, first element is used as the default value
-
-
Method Details
-
valueToString
Invokes thetoStringmethod of the supplied option. May be overridden.- Specified by:
valueToStringin classConfigKey<T>- Parameters:
value- possible value associated with this key- Returns:
- string representation
-
getXmlDescription
Returns a description in XML of the given option value. This, along withvalueToString(T), is used by thegetOptionsXml()method to assemble a described list of the options.- Parameters:
value- possible value of this key- Returns:
- short snippet of XML (not wrapped in any outer element) describing the value; may be null if no description required or available
-
stringToValue
CallsvalueToStringrepeatedly looking for a match. This means that ifvalueToStringis overridden it is usually not necessary to override this method.- Specified by:
stringToValuein classConfigKey<T>- Parameters:
txt- string representation of value- Returns:
- value
- Throws:
ConfigException
-
getOptions
-
createSpecifier
-
setOptionUsage
Sets the usage string based on the currently configured options. This method calls setStringUsage.- Returns:
- this object, as a convenience
-
addOptionsXml
Convenience method to add the result ofgetOptionsXml()to the XML documentation of this key.- Returns:
- this object, as a convenience
-
getOptionsXml
Returns an XML list of the available options for this config key. Descriptions are not included.- Returns:
- p element
-