Class Options

java.lang.Object
org.basex.util.options.Options
All Implemented Interfaces:
Iterable<Option<?>>
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

public class Options extends Object implements Iterable<Option<?>>
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
  • Constructor Details

    • Options

      public Options()
      Default constructor.
    • Options

      protected Options(IOFile opts)
      Constructor with options file.
      Parameters:
      opts - options file
    • Options

      protected Options(Options opts)
      Constructor with options to be copied.
      Parameters:
      opts - options
  • Method Details

    • write

      public final void write()
      Writes the options to disk.
    • option

      public final Option<?> option(String name)
      Returns the option with the specified name.
      Parameters:
      name - name of the option
      Returns:
      value (may be null)
    • get

      public final Object get(Option<?> option)
      Returns the value of the specified option.
      Parameters:
      option - option
      Returns:
      value (may be null)
    • put

      public final void put(Option<?> option, Object value)
      Sets an option to a value without checking its type.
      Parameters:
      option - option
      value - value to be assigned
    • contains

      public final boolean contains(Option<?> option)
      Checks if a value was set for the specified option.
      Parameters:
      option - option
      Returns:
      result of check
    • get

      public final String get(StringOption option)
      Returns the requested string.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final Integer get(NumberOption option)
      Returns the requested number.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final Boolean get(BooleanOption option)
      Returns the requested boolean.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final FuncItem get(FuncOption option)
      Returns the requested function.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final String[] get(StringsOption option)
      Returns the requested string array.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final int[] get(NumbersOption option)
      Returns the requested integer array.
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final <O extends Options> O get(OptionsOption<O> option)
      Returns the requested options.
      Type Parameters:
      O - options
      Parameters:
      option - option to be found
      Returns:
      value
    • get

      public final <E extends Enum<E>> E get(EnumOption<E> option)
      Returns the requested enum value.
      Type Parameters:
      E - enumeration value
      Parameters:
      option - option to be found
      Returns:
      value
    • set

      public final void set(StringOption option, String value)
      Sets the string value of an option.
      Parameters:
      option - option to be set
      value - value to be written
    • set

      public final void set(NumberOption option, int value)
      Sets the integer value of an option.
      Parameters:
      option - option to be set
      value - value to be written
    • set

      public final void set(BooleanOption option, boolean value)
      Sets the boolean value of an option.
      Parameters:
      option - option to be set
      value - value to be written
    • set

      public final void set(StringsOption option, String[] value)
      Sets the string array value of an option.
      Parameters:
      option - option to be set
      value - value to be written
    • set

      public final void set(NumbersOption option, int[] value)
      Sets the integer array value of an option.
      Parameters:
      option - option to be set
      value - value to be written
    • set

      public final <O extends Options> void set(OptionsOption<O> option, O value)
      Sets the options of an option.
      Type Parameters:
      O - options
      Parameters:
      option - option to be set
      value - value to be set
    • set

      public final <V extends Enum<V>> void set(EnumOption<V> option, Enum<V> value)
      Sets the enumeration of an option.
      Type Parameters:
      V - enumeration value
      Parameters:
      option - option to be set
      value - value to be set
    • set

      public final <V extends Enum<V>> void set(EnumOption<V> option, String value)
      Sets the enumeration of an option.
      Type Parameters:
      V - enumeration value
      Parameters:
      option - option to be set
      value - string value, which will be converted to an enum value or null
    • assign

      public void assign(String name, String value) throws BaseXException
      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 option
      value - 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 option
      value - value to be assigned
      error - error
      ii - input info
      Throws:
      BaseXException - database exception
      QueryException - query exception
    • free

      public final HashMap<String,String> free()
      Returns all name/value pairs without pre-defined option.
      Returns:
      options
    • toMap

      public final Map<String,String> toMap(StringOption option)
      Returns a map representation of the entries of the requested string (separated by commas).
      Parameters:
      option - option to be found
      Returns:
      map
    • toMap

      public static Map<String,String> toMap(String opts)
      Returns a map representation of the comma-separated options string.
      Parameters:
      opts - options string
      Returns:
      map
    • error

      public final String error(String name)
      Returns an error string for an unknown option.
      Parameters:
      name - name of option
      Returns:
      error string
    • invert

      public final boolean invert(BooleanOption option)
      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 with org.basex. will be assigned as options.
    • assign

      public final void assign(MediaType type) throws BaseXException
      Parses the specified options.
      Parameters:
      type - media type
      Throws:
      BaseXException - database exception
    • assign

      public final void assign(String string) throws BaseXException
      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 - map
      error - raise error if option is unknown
      ii - input info
      Throws:
      BaseXException - database exception
      QueryException - query exception
    • names

      public final String[] names()
      Returns the names of all options.
      Returns:
      names
    • iterator

      public final Iterator<Option<?>> iterator()
      Specified by:
      iterator in interface Iterable<Option<?>>
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • allowed

      public static String allowed(Option<?> option, String value, Object... all)
      Returns a message with allowed keys.
      Parameters:
      option - option
      value - supplied value
      all - allowed values
      Returns:
      exception