|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ttools.plot2.config.ConfigKey<T>
uk.ac.starlink.ttools.plot2.config.ChoiceConfigKey<T>
public abstract class ChoiceConfigKey<T>
ConfigKey that allows named choices from a given list, and optionally provides other ways of specifying values from string descriptions.
Constructor Summary | |
---|---|
ChoiceConfigKey(ConfigMeta meta,
Class<T> clazz,
T dflt,
boolean nullPermitted)
Constructor. |
Method Summary | |
---|---|
void |
addOption(T option)
Adds an option to the permitted list. |
abstract T |
decodeString(String sval)
Takes a string, and attempts to turn it into an object which may be a value for this key. |
Map<String,T> |
getOptionMap()
Returns a mutable map giving the currently available known options and their string values. |
abstract String |
stringifyValue(T value)
Takes an object which may be a value of this key, and attempts to turn it into a string for reporting purposes. |
T |
stringToValue(String sval)
Decodes a string value to the value type of this key. |
String |
valueToString(T value)
Reports a value as a string. |
Methods inherited from class uk.ac.starlink.ttools.plot2.config.ConfigKey |
---|
cast, createSpecifier, getDefaultValue, getMeta, getValueClass, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChoiceConfigKey(ConfigMeta meta, Class<T> clazz, T dflt, boolean nullPermitted)
meta
- metadataclazz
- value classdflt
- default valuenullPermitted
- true iff null is a permitted valueMethod Detail |
---|
public void addOption(T option)
stringifyValue(T)
method,
which must return a non-null value.
For more flexibility, you can manipulate the return value of
getOptionMap()
directly.
option
- option to addpublic Map<String,T> getOptionMap()
public abstract T decodeString(String sval)
This method should be the opposite of stringifyValue(T)
,
but does not need to be consistent with
stringToValue
or
valueToString
.
sval
- string representation
public abstract String stringifyValue(T value)
This method should if possible
be the opposite of decodeString(java.lang.String)
,
but does not need to be consistent with
stringToValue
or
valueToString
.
If no round-trippable value is available, null should be returned.
value
- typed object
public T stringToValue(String sval) throws ConfigException
ConfigKey
stringToValue
in class ConfigKey<T>
sval
- string representation of value
ConfigException
public String valueToString(T value)
ConfigKey
stringToValue(valueToString(v)).equals(v)
.
A null value, if permitted, should be represented as an empty string.
valueToString
in class ConfigKey<T>
value
- possible value associated with this key
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |