Package org.basex.util.options
Class Options
java.lang.Object
org.basex.util.options.Options
- Direct Known Subclasses:
BaseXCollationOptions,CreateOptions,CsvOptions,FTDistanceOptions,FtIndexOptions,FTScopeOptions,FtTokenizeOptions,FTWindowOptions,GUIOptions,HtmlOptions,JobsOptions,JobsStop.StopOptions,JsonOptions,MainOptions,MapMerge.MergeOptions,ProcOptions,ProfTrack.TrackOptions,SerializerOptions,SqlExecute.StatementOptions,StaticOptions,TextOptions,UCAOptions,XQueryEval.XQueryOptions,XQueryParse.XQueryOptions,XsltTransform.XsltOptions
This class provides methods for accessing, reading and storing options.
Options (name/value pairs) may either be instances of the
Option class.
If an instance of this class contains no pre-defined options, assigned options will
be added as free options.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumYes/No enumeration.static enumYes/No/Omit enumeration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns a message with allowed keys.final voidParses and assigns options string from the specified string.voidAssigns a value after casting it to the correct type.voidAssigns a value after casting it to the correct type.final voidParses and assigns options from the specified map.final voidParses the specified options.final booleanChecks if a value was set for the specified option.final StringReturns an error string for an unknown option.free()Returns all name/value pairs without pre-defined option.final Booleanget(BooleanOption option) Returns the requested boolean.final <E extends Enum<E>>
Eget(EnumOption<E> option) Returns the requested enum value.final FuncItemget(FuncOption option) Returns the requested function.final Integerget(NumberOption option) Returns the requested number.final int[]get(NumbersOption option) Returns the requested integer array.final ObjectReturns the value of the specified option.final <O extends Options>
Oget(OptionsOption<O> option) Returns the requested options.final Stringget(StringOption option) Returns the requested string.final String[]get(StringsOption option) Returns the requested string array.final booleaninvert(BooleanOption option) Inverts the boolean value of an option.iterator()final String[]names()Returns the names of all options.final Option<?>Returns the option with the specified name.final voidSets an option to a value without checking its type.final voidset(BooleanOption option, boolean value) Sets the boolean value of an option.final <V extends Enum<V>>
voidset(EnumOption<V> option, Enum<V> value) Sets the enumeration of an option.final <V extends Enum<V>>
voidset(EnumOption<V> option, String value) Sets the enumeration of an option.final voidset(NumberOption option, int value) Sets the integer value of an option.final voidset(NumbersOption option, int[] value) Sets the integer array value of an option.final <O extends Options>
voidset(OptionsOption<O> option, O value) Sets the options of an option.final voidset(StringOption option, String value) Sets the string value of an option.final voidset(StringsOption option, String[] value) Sets the string array value of an option.voidOverwrites the options with global options and system properties.Returns a map representation of the comma-separated options string.toMap(StringOption option) Returns a map representation of the entries of the requested string (separated by commas).final StringtoString()final voidwrite()Writes the options to disk.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Options
public Options()Default constructor. -
Options
Constructor with options file.- Parameters:
opts- options file
-
Options
Constructor with options to be copied.- Parameters:
opts- options
-
-
Method Details
-
write
public final void write()Writes the options to disk. -
option
Returns the option with the specified name.- Parameters:
name- name of the option- Returns:
- value (may be
null)
-
get
Returns the value of the specified option.- Parameters:
option- option- Returns:
- value (may be
null)
-
put
Sets an option to a value without checking its type.- Parameters:
option- optionvalue- value to be assigned
-
contains
Checks if a value was set for the specified option.- Parameters:
option- option- Returns:
- result of check
-
get
Returns the requested string.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested number.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested boolean.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested function.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested string array.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested integer array.- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested options.- Type Parameters:
O- options- Parameters:
option- option to be found- Returns:
- value
-
get
Returns the requested enum value.- Type Parameters:
E- enumeration value- Parameters:
option- option to be found- Returns:
- value
-
set
Sets the string value of an option.- Parameters:
option- option to be setvalue- value to be written
-
set
Sets the integer value of an option.- Parameters:
option- option to be setvalue- value to be written
-
set
Sets the boolean value of an option.- Parameters:
option- option to be setvalue- value to be written
-
set
Sets the string array value of an option.- Parameters:
option- option to be setvalue- value to be written
-
set
Sets the integer array value of an option.- Parameters:
option- option to be setvalue- value to be written
-
set
Sets the options of an option.- Type Parameters:
O- options- Parameters:
option- option to be setvalue- value to be set
-
set
Sets the enumeration of an option.- Type Parameters:
V- enumeration value- Parameters:
option- option to be setvalue- value to be set
-
set
Sets the enumeration of an option.- Type Parameters:
V- enumeration value- Parameters:
option- option to be setvalue- string value, which will be converted to an enum value ornull
-
assign
Assigns a value after casting it to the correct type. If the option is unknown, it will be added as free option.- Parameters:
name- name of optionvalue- value- Throws:
BaseXException- database exception
-
assign
public void assign(Item name, Value value, boolean error, InputInfo ii) throws BaseXException, QueryException Assigns a value after casting it to the correct type. If the option is unknown, it will be added as free option.- Parameters:
name- name of optionvalue- value to be assignederror- errorii- input info- Throws:
BaseXException- database exceptionQueryException- query exception
-
free
Returns all name/value pairs without pre-defined option.- Returns:
- options
-
toMap
Returns a map representation of the entries of the requested string (separated by commas).- Parameters:
option- option to be found- Returns:
- map
-
toMap
Returns a map representation of the comma-separated options string.- Parameters:
opts- options string- Returns:
- map
-
error
Returns an error string for an unknown option.- Parameters:
name- name of option- Returns:
- error string
-
invert
Inverts the boolean value of an option.- Parameters:
option- option- Returns:
- new value
-
setSystem
public void setSystem()Overwrites the options with global options and system properties. All properties starting withorg.basex.will be assigned as options. -
assign
Parses the specified options.- Parameters:
type- media type- Throws:
BaseXException- database exception
-
assign
Parses and assigns options string from the specified string.- Parameters:
string- options string- Throws:
BaseXException- database exception
-
assign
public final void assign(XQMap map, boolean error, InputInfo ii) throws BaseXException, QueryException Parses and assigns options from the specified map.- Parameters:
map- maperror- raise error if option is unknownii- input info- Throws:
BaseXException- database exceptionQueryException- query exception
-
names
Returns the names of all options.- Returns:
- names
-
iterator
-
toString
-
allowed
Returns a message with allowed keys.- Parameters:
option- optionvalue- supplied valueall- allowed values- Returns:
- exception
-