public class Options extends Object implements Iterable<Option<?>>
Option
class.
If an instance of this class contains no pre-defined options, assigned options will
be added as free options.Modifier and Type | Class and Description |
---|---|
static class |
Options.YesNo
Yes/No enumeration.
|
static class |
Options.YesNoOmit
Yes/No/Omit enumeration.
|
Modifier and Type | Field and Description |
---|---|
protected TreeMap<String,Option<?>> |
options
Map with option names and definition.
|
Modifier | Constructor and Description |
---|---|
|
Options()
Default constructor.
|
protected |
Options(IOFile opts)
Constructor with options file.
|
protected |
Options(Options opts)
Constructor with options file.
|
Modifier and Type | Method and Description |
---|---|
static String |
allowed(Option<?> option,
Object... all)
Returns a list of allowed keys.
|
void |
assign(String name,
String val)
Assigns a value after casting it to the correct type.
|
boolean |
contains(Option<?> option)
Checks if a value was set for the specified option.
|
String |
error(String name)
Returns an error string for an unknown option.
|
HashMap<String,String> |
free()
Returns all name/value pairs without pre-defined option.
|
Boolean |
get(BooleanOption option)
Returns the requested boolean.
|
<V extends Enum<V>> |
get(EnumOption<V> option)
Returns the requested enum value.
|
Integer |
get(NumberOption option)
Returns the requested number.
|
int[] |
get(NumbersOption option)
Returns the original instance of the requested integer array.
|
Object |
get(Option<?> option)
Returns the value of the specified option.
|
<O extends Options> |
get(OptionsOption<O> option)
Returns the original instance of the requested options.
|
String |
get(StringOption option)
Returns the requested string.
|
String[] |
get(StringsOption option)
Returns the original instance of the requested string array.
|
static String |
getSystem(Option<?> option)
Returns a system property.
|
boolean |
invert(BooleanOption option)
Inverts the boolean value of an option.
|
Iterator<Option<?>> |
iterator() |
Option<?> |
option(String name)
Returns the option with the specified name.
|
static Option<?>[] |
options(Class<? extends Options> clz)
Returns all options from the specified class.
|
void |
parse(String string)
Parses an option string and sets the options accordingly.
|
void |
put(Option<?> option,
Object value)
Sets an option to a value without checking its type.
|
void |
set(BooleanOption option,
boolean value)
Sets the boolean value of an option.
|
<V extends Enum<V>> |
set(EnumOption<V> option,
Enum<V> value)
Sets the enumeration of an option.
|
<V extends Enum<V>> |
set(EnumOption<V> option,
String value)
Sets the enumeration of an option.
|
void |
set(NumberOption option,
int value)
Sets the integer value of an option.
|
void |
set(NumbersOption option,
int[] value)
Sets the integer array value of an option.
|
<O extends Options> |
set(OptionsOption<O> option,
O value)
Sets the options of an option.
|
void |
set(StringOption option,
String value)
Sets the string value of an option.
|
void |
set(StringsOption option,
String[] value)
Sets the string array value of an option.
|
void |
setSystem()
Overwrites the options with system properties.
|
static void |
setSystem(Option<?> option,
Object val)
Sets a system property if it has not been set before.
|
static void |
setSystem(String key,
Object val)
Sets a system property if it has not been set before.
|
String |
toString() |
void |
write()
Writes the options to disk.
|
public Options()
protected Options(IOFile opts)
opts
- options fileprotected Options(Options opts)
opts
- options filepublic final void write()
public final Option<?> option(String name)
name
- name of the optionnull
)public final Object get(Option<?> option)
option
- optionnull
)public final void put(Option<?> option, Object value)
option
- optionvalue
- value to be assignedpublic final boolean contains(Option<?> option)
option
- optionpublic final String get(StringOption option)
option
- option to be foundpublic final Integer get(NumberOption option)
option
- option to be foundpublic final Boolean get(BooleanOption option)
option
- option to be foundpublic final String[] get(StringsOption option)
option
- option to be foundpublic final int[] get(NumbersOption option)
option
- option to be foundpublic final <O extends Options> O get(OptionsOption<O> option)
O
- optionsoption
- option to be foundpublic final <V extends Enum<V>> V get(EnumOption<V> option)
V
- enumeration valueoption
- option to be foundpublic final void set(StringOption option, String value)
option
- option to be setvalue
- value to be writtenpublic final void set(NumberOption option, int value)
option
- option to be setvalue
- value to be writtenpublic final void set(BooleanOption option, boolean value)
option
- option to be setvalue
- value to be writtenpublic final void set(StringsOption option, String[] value)
option
- option to be setvalue
- value to be writtenpublic final void set(NumbersOption option, int[] value)
option
- option to be setvalue
- value to be writtenpublic final <O extends Options> void set(OptionsOption<O> option, O value)
O
- optionsoption
- option to be setvalue
- value to be setpublic final <V extends Enum<V>> void set(EnumOption<V> option, Enum<V> value)
V
- enumeration valueoption
- option to be setvalue
- value to be setpublic final <V extends Enum<V>> void set(EnumOption<V> option, String value)
V
- enumeration valueoption
- option to be setvalue
- string value, which will be converted to an enum value or null
public void assign(String name, String val) throws BaseXException
name
- name of optionval
- valueBaseXException
- database exceptionpublic final HashMap<String,String> free()
public final String error(String name)
name
- name of optionpublic final boolean invert(BooleanOption option)
option
- optionpublic final void setSystem()
org.basex.
will be assigned as options.public static String getSystem(Option<?> option)
Prop.DBPREFIX
string.option
- optionpublic static void setSystem(Option<?> option, Object val)
option
- optionval
- valuepublic static void setSystem(String key, Object val)
Prop.DBPREFIX
string.key
- keyval
- valuepublic static Option<?>[] options(Class<? extends Options> clz) throws IllegalAccessException
clz
- options classIllegalAccessException
- exceptionpublic static String allowed(Option<?> option, Object... all)
option
- optionall
- allowed valuespublic void parse(String string) throws BaseXException
string
- options stringBaseXException
- database exceptionCopyright © 2005–2015 BaseX Team. All rights reserved.