|
|||||||||
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>
public abstract class ConfigKey<T>
Typed key for use in a ConfigMap.
As well as serving as a key in ConfigMap
,
this class has methods to allow a command-line or graphical interface
to be constructed for the corresponding values automatically.
Note that this class does not sport the
Equality
annotation. A ConfigKey is normally considered equal only to itself,
not to other similarly-named ConfigKeys.
Constructor Summary | |
---|---|
ConfigKey(ConfigMeta meta,
Class<T> clazz,
T dflt)
Constructor. |
Method Summary | |
---|---|
T |
cast(Object value)
Converts an object to the value type of this key. |
abstract Specifier<T> |
createSpecifier()
Constructs a graphical control with which the user can specify a suitable value for association with this key. |
T |
getDefaultValue()
Returns the default value associated with this key. |
ConfigMeta |
getMeta()
Returns metadata about this key. |
Class<T> |
getValueClass()
Returns the type of value described by this key. |
abstract T |
stringToValue(String txt)
Decodes a string value to the value type of this key. |
String |
toString()
|
abstract String |
valueToString(T value)
Reports a value as a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConfigKey(ConfigMeta meta, Class<T> clazz, T dflt)
meta
- metadata describing this keyclazz
- value type for the values indexed by this keydflt
- default value when key not present in mapMethod Detail |
---|
public ConfigMeta getMeta()
public Class<T> getValueClass()
public T getDefaultValue()
public T cast(Object value)
value
- untyped value
public abstract T stringToValue(String txt) throws ConfigException
txt
- string representation of value
ConfigException
public abstract String valueToString(T value)
stringToValue(valueToString(v)).equals(v)
.
A null value, if permitted, should be represented as an empty string.
value
- possible value associated with this key
public abstract Specifier<T> createSpecifier()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |