gnu.text

Class Options

public class Options extends Object

Mananges a table of named options, Can inherit from another table of "default" options.
Field Summary
static intBOOLEAN_OPTION
Bit indicating option value is a boolean.
static intSTRING_OPTION
static StringUNKNOWN
Constructor Summary
Options()
Options(Options previous)
Method Summary
voidadd(String key, int kind, String documentation)
Create a new option and enters it in this table.
Objectget(String key, Object defaultValue)
Get the value for the option.
booleangetBoolean(String key)
booleangetBoolean(String key, boolean defaultValue)
StringgetDoc(String key)
OptionInfogetInfo(String key)
ObjectgetLocal(String key)
Get current option value.
Vectorkeys()
Return the list of option keys.
voidpopOptionValues(Vector options)
Restore a list of options, as set by pushOptionValues
voidpushOptionValues(Vector options)
Set a list of options, remember the old value.
voidreset(String key, Object oldValue)
Reset the value of a named option.
voidset(String key, Object value)
Set the value of a named option.
voidset(String key, Object value, SourceMessages messages)
Set the value of a named option.
Stringset(String key, String argument)
Set the value of the key to the argument, appropriate parsed. return null on success or a String error message.

Field Detail

BOOLEAN_OPTION

public static final int BOOLEAN_OPTION
Bit indicating option value is a boolean.

STRING_OPTION

public static final int STRING_OPTION

UNKNOWN

public static final String UNKNOWN

Constructor Detail

Options

public Options()

Options

public Options(Options previous)

Method Detail

add

public void add(String key, int kind, String documentation)
Create a new option and enters it in this table. A duplicate option throws a RuntimeException.

Parameters: key the options name (key). kind type and other flag bits of the option. documentation a String describing what the option does.

get

public Object get(String key, Object defaultValue)
Get the value for the option. Throws an except if there is no option by that name, Returns defaultValue if there is such an option, but it hasn't been set.

getBoolean

public boolean getBoolean(String key)

getBoolean

public boolean getBoolean(String key, boolean defaultValue)

getDoc

public String getDoc(String key)

getInfo

public OptionInfo getInfo(String key)

getLocal

public Object getLocal(String key)
Get current option value. Only look in local table, not in inherited Options. Return null if there is no binding (even when get would throw an except on an unknonw option).

keys

public Vector keys()
Return the list of option keys.

popOptionValues

public void popOptionValues(Vector options)
Restore a list of options, as set by pushOptionValues

pushOptionValues

public void pushOptionValues(Vector options)
Set a list of options, remember the old value.

Parameters: options is vector of triples, echo of which is consisting of: a String option key; an entry whose valus is ignores and is used to store the old value; and a new value for the options.

reset

public void reset(String key, Object oldValue)
Reset the value of a named option.

set

public void set(String key, Object value)
Set the value of a named option.

set

public void set(String key, Object value, SourceMessages messages)
Set the value of a named option.

set

public String set(String key, String argument)
Set the value of the key to the argument, appropriate parsed. return null on success or a String error message. If the option key is invalid, return UNKNOWN.