Class ParameterSet

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Direct Known Subclasses:
    Configuration

    public class ParameterSet
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Represents a set of iink parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkNotClosed()  
      void close()  
      protected void finalize()  
      @NotNull java.lang.Boolean getBoolean​(@NotNull java.lang.String key)
      Returns the boolean value associated with key.
      @NotNull java.lang.Boolean getBoolean​(@NotNull java.lang.String key, boolean defaultValue)
      Returns the boolean value associated with key.
      @NotNull java.lang.Number getNumber​(@NotNull java.lang.String key)
      Returns the numeric value associated with key.
      @NotNull java.lang.Number getNumber​(@NotNull java.lang.String key, @NotNull java.lang.Number defaultValue)
      Returns the numeric value associated with key.
      @NotNull ParameterSet getSection​(@NotNull java.lang.String key)
      Returns a parameter set object representing the section associated with key.
      @NotNull java.lang.String getString​(@NotNull java.lang.String key)
      Returns the string value associated with key.
      @NotNull java.lang.String getString​(@NotNull java.lang.String key, @NotNull java.lang.String defaultValue)
      Returns the string value associated with key.
      @NotNull java.lang.String[] getStringArray​(@NotNull java.lang.String key)
      Returns the string array value associated with key.
      @NotNull java.lang.String[] getStringArray​(@NotNull java.lang.String key, @NotNull java.lang.String[] defaultValue)
      Returns the string array associated with key.
      void inject​(@NotNull java.lang.String json)
      Injects the content of a JSON values into this parameter set.
      boolean isClosed()
      Tells whether the close() method has been called.
      void setBoolean​(@NotNull java.lang.String key, java.lang.Boolean value)
      Sets the boolean value associated with key.
      void setNumber​(@NotNull java.lang.String key, @NotNull java.lang.Number value)
      Sets the numeric value associated with key.
      void setString​(@NotNull java.lang.String key, @NotNull java.lang.String value)
      Sets the string value associated with key.
      void setStringArray​(@NotNull java.lang.String key, @NotNull java.lang.String[] value)
      Sets the string array value associated with key.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • close

        public final void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • isClosed

        public final boolean isClosed()
        Tells whether the close() method has been called. Once an object is closed any method will throw IllegalStateException.
        Returns:
        true if this object is closed.
      • checkNotClosed

        protected final void checkNotClosed()
      • getSection

        @NotNull
        public final @NotNull ParameterSet getSection​(@NotNull
                                                      @NotNull java.lang.String key)
        Returns a parameter set object representing the section associated with key. Sections correspond to the hierarchical organization of keys according to their dots. For example, if you have keys "a.b.c" and "a.b.d" there is a section "a.b" that contains keys "c" and "d", as well as a section "a" containing "b.c" and "b.d".

        Note: make sure to close the returned object.

        Parameters:
        key - the key of the section to obtain.
        Returns:
        the section.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when key is not found.
        java.lang.IllegalStateException - when entry at key is not a section.
      • getString

        @NotNull
        public final @NotNull java.lang.String getString​(@NotNull
                                                         @NotNull java.lang.String key)
        Returns the string value associated with key.
        Parameters:
        key - the key of the value to obtain.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when key is not found.
        java.lang.IllegalStateException - when entry at key is not a string.
      • getString

        @NotNull
        public final @NotNull java.lang.String getString​(@NotNull
                                                         @NotNull java.lang.String key,
                                                         @NotNull
                                                         @NotNull java.lang.String defaultValue)
        Returns the string value associated with key.
        Parameters:
        key - the key of the value to obtain.
        defaultValue - the value to return when key is not present.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a string.
      • setString

        public final void setString​(@NotNull
                                    @NotNull java.lang.String key,
                                    @NotNull
                                    @NotNull java.lang.String value)
        Sets the string value associated with key.
        Parameters:
        key - the key of the value to set.
        value - the string value to set.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a string.
      • getBoolean

        @NotNull
        public final @NotNull java.lang.Boolean getBoolean​(@NotNull
                                                           @NotNull java.lang.String key)
        Returns the boolean value associated with key.
        Parameters:
        key - the key of the value to obtain.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when key is not found.
        java.lang.IllegalStateException - when entry at key is not a boolean.
      • getBoolean

        @NotNull
        public final @NotNull java.lang.Boolean getBoolean​(@NotNull
                                                           @NotNull java.lang.String key,
                                                           boolean defaultValue)
        Returns the boolean value associated with key.
        Parameters:
        key - the key of the value to obtain.
        defaultValue - the value to return when key is not present.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a boolean.
      • setBoolean

        public final void setBoolean​(@NotNull
                                     @NotNull java.lang.String key,
                                     java.lang.Boolean value)
        Sets the boolean value associated with key.
        Parameters:
        key - the key of the value to set.
        value - the boolean value to set.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a boolean.
      • getNumber

        @NotNull
        public final @NotNull java.lang.Number getNumber​(@NotNull
                                                         @NotNull java.lang.String key)
        Returns the numeric value associated with key.
        Parameters:
        key - the key of the value to obtain.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when key is not found.
        java.lang.IllegalStateException - when entry at key is not a number.
      • getNumber

        @NotNull
        public final @NotNull java.lang.Number getNumber​(@NotNull
                                                         @NotNull java.lang.String key,
                                                         @NotNull
                                                         @NotNull java.lang.Number defaultValue)
        Returns the numeric value associated with key.
        Parameters:
        key - the key of the value to obtain.
        defaultValue - the value to return when key is not present.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a number.
      • setNumber

        public final void setNumber​(@NotNull
                                    @NotNull java.lang.String key,
                                    @NotNull
                                    @NotNull java.lang.Number value)
        Sets the numeric value associated with key.
        Parameters:
        key - the key of the value to set.
        value - the number value to set.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a number.
      • getStringArray

        @NotNull
        public final @NotNull java.lang.String[] getStringArray​(@NotNull
                                                                @NotNull java.lang.String key)
        Returns the string array value associated with key.
        Parameters:
        key - the key of the value to obtain.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when key is not found.
        java.lang.IllegalStateException - when entry at key is not a string array.
      • getStringArray

        @NotNull
        public final @NotNull java.lang.String[] getStringArray​(@NotNull
                                                                @NotNull java.lang.String key,
                                                                @NotNull
                                                                @NotNull java.lang.String[] defaultValue)
        Returns the string array associated with key.
        Parameters:
        key - the key of the value to obtain.
        defaultValue - the value to return when key is not present.
        Returns:
        the value.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key is not a string array.
        Since:
        1.4
      • setStringArray

        public final void setStringArray​(@NotNull
                                         @NotNull java.lang.String key,
                                         @NotNull
                                         @NotNull java.lang.String[] value)
        Sets the string array value associated with key.
        Parameters:
        key - the key of the value to set.
        value - the value to set.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalStateException - when entry at key exists and is not a string array.
      • inject

        public final void inject​(@NotNull
                                 @NotNull java.lang.String json)
        Injects the content of a JSON values into this parameter set.
        Parameters:
        json - JSON parameter set values.
        Throws:
        java.lang.IllegalStateException - when this parameter set is closed.
        java.lang.IllegalArgumentException - when json is not valid JSON.