Package gnu.text
Class Options
- java.lang.Object
-
- gnu.text.Options
-
public class Options extends Object
Mananges a table of named options, Can inherit from another table of "default" options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Options.OptionInfo
-
Field Summary
Fields Modifier and Type Field Description static int
BOOLEAN_OPTION
Bit indicating option value is a boolean.static int
INT_OPTION
static int
STRING_OPTION
static String
UNKNOWN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Options.OptionInfo
add(String key, int kind, Object defaultValue, String documentation)
Options.OptionInfo
add(String key, int kind, String documentation)
Create a new option and enters it in this table.static Boolean
booleanValue(String argument)
Object
get(Options.OptionInfo key)
Object
get(Options.OptionInfo key, Object defaultValue)
Object
get(String key, Object defaultValue)
Get the value for the option.boolean
getBoolean(Options.OptionInfo key)
boolean
getBoolean(Options.OptionInfo key, boolean defaultValue)
boolean
getBoolean(String key)
boolean
getBoolean(String key, boolean defaultValue)
String
getDoc(String key)
Options.OptionInfo
getInfo(String key)
int
getInt(Options.OptionInfo key, int defaultValue)
Object
getLocal(String key)
Get current option value.ArrayList<String>
keys()
Return the list of option keys.void
popOptionValues(Vector options)
Restore a list of options, as set by pushOptionValuesvoid
pushOptionValues(Vector options)
Set a list of options, remember the old value.void
reset(String key, Object oldValue)
Reset the value of a named option.void
set(String key, Object value)
Set the value of a named option.Object
set(String key, Object value, SourceMessages messages)
Set the value of a named option.String
set(String key, String argument)
Set the value of the key to the argument, appropriate parsed.
-
-
-
Field Detail
-
BOOLEAN_OPTION
public static final int BOOLEAN_OPTION
Bit indicating option value is a boolean.- See Also:
- Constant Field Values
-
STRING_OPTION
public static final int STRING_OPTION
- See Also:
- Constant Field Values
-
INT_OPTION
public static final int INT_OPTION
- See Also:
- Constant Field Values
-
UNKNOWN
public static final String UNKNOWN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Options
public Options()
-
Options
public Options(Options previous)
-
-
Method Detail
-
add
public Options.OptionInfo 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.
-
add
public Options.OptionInfo add(String key, int kind, Object defaultValue, String documentation)
-
set
public Object set(String key, Object value, SourceMessages messages)
Set the value of a named option. Return old value, in form suitable for reset.
-
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.
-
getInfo
public Options.OptionInfo getInfo(String key)
-
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.
-
get
public Object get(Options.OptionInfo key, Object defaultValue)
-
get
public Object get(Options.OptionInfo 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 exception on an unknown option).
-
getBoolean
public boolean getBoolean(String key)
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue)
-
getBoolean
public boolean getBoolean(Options.OptionInfo key, boolean defaultValue)
-
getBoolean
public boolean getBoolean(Options.OptionInfo key)
-
getInt
public int getInt(Options.OptionInfo key, int defaultValue)
-
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 value is ignored and is used to store the old value; and a new value for the option.
-
popOptionValues
public void popOptionValues(Vector options)
Restore a list of options, as set by pushOptionValues
-
-