public abstract class OptionConfigKey<T> extends ConfigKey<T>
ChoiceConfigKey
.Constructor and Description |
---|
OptionConfigKey(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.
|
Modifier and Type | Method and Description |
---|---|
OptionConfigKey<T> |
addOptionsXml()
Convenience method to add the result of
getOptionsXml()
to the XML documentation of this key. |
Specifier<T> |
createSpecifier()
Constructs a graphical control with which the user can
specify a suitable value for association with this key.
|
T[] |
getOptions()
Returns the available options for this key.
|
String |
getOptionsXml()
Returns an XML list of the available options for this config key.
|
abstract String |
getXmlDescription(T value)
Returns a description in XML of the given option value.
|
OptionConfigKey<T> |
setOptionUsage()
Sets the usage string based on the currently configured options.
|
T |
stringToValue(String txt)
Calls
valueToString repeatedly looking for a match. |
String |
valueToString(T value)
Invokes the
toString method of the supplied option. |
cast, getDefaultValue, getMeta, getValueClass, toString
public OptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options, T dflt, boolean useRadio)
meta
- metadataclazz
- class to which all the possible options belongoptions
- array of possible values for this keydflt
- default option, should be one of options
useRadio
- true to use radio buttons, false for a combo boxpublic OptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options, T dflt)
meta
- metadataclazz
- class to which all the possible options belongoptions
- array of possible values for this keydflt
- default option, should be one of options
public OptionConfigKey(ConfigMeta meta, Class<T> clazz, T[] options)
meta
- metadataclazz
- class to which all the possible options belongoptions
- array of possible values for this key,
first element is used as the default valuepublic String valueToString(T value)
toString
method of the supplied option.
May be overridden.valueToString
in class ConfigKey<T>
value
- possible value associated with this keypublic abstract String getXmlDescription(T value)
valueToString(T)
,
is used by the getOptionsXml()
method to assemble
a described list of the options.value
- possible value of this keypublic T stringToValue(String txt) throws ConfigException
valueToString
repeatedly looking for a match.
This means that if valueToString
is overridden it
is usually not necessary to override this method.stringToValue
in class ConfigKey<T>
txt
- string representation of valueConfigException
public T[] getOptions()
public Specifier<T> createSpecifier()
ConfigKey
createSpecifier
in class ConfigKey<T>
public OptionConfigKey<T> setOptionUsage()
public OptionConfigKey<T> addOptionsXml()
getOptionsXml()
to the XML documentation of this key.public String getOptionsXml()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.