Package com.myscript.iink
Class ParameterSet
- java.lang.Object
-
- com.myscript.iink.ParameterSet
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
Configuration
public class ParameterSet extends java.lang.Object implements java.lang.AutoCloseableRepresents a set of iink parameters.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckNotClosed()voidclose()protected voidfinalize()@NotNull java.lang.BooleangetBoolean(@NotNull java.lang.String key)Returns the boolean value associated withkey.@NotNull java.lang.BooleangetBoolean(@NotNull java.lang.String key, boolean defaultValue)Returns the boolean value associated withkey.@NotNull java.lang.NumbergetNumber(@NotNull java.lang.String key)Returns the numeric value associated withkey.@NotNull java.lang.NumbergetNumber(@NotNull java.lang.String key, @NotNull java.lang.Number defaultValue)Returns the numeric value associated withkey.@NotNull ParameterSetgetSection(@NotNull java.lang.String key)Returns a parameter set object representing the section associated withkey.@NotNull java.lang.StringgetString(@NotNull java.lang.String key)Returns the string value associated withkey.@NotNull java.lang.StringgetString(@NotNull java.lang.String key, @NotNull java.lang.String defaultValue)Returns the string value associated withkey.@NotNull java.lang.String[]getStringArray(@NotNull java.lang.String key)Returns the string array value associated withkey.@NotNull java.lang.String[]getStringArray(@NotNull java.lang.String key, @NotNull java.lang.String[] defaultValue)Returns the string array associated withkey.voidinject(@NotNull java.lang.String json)Injects the content of a JSON values into this parameter set.booleanisClosed()Tells whether theclose()method has been called.voidsetBoolean(@NotNull java.lang.String key, java.lang.Boolean value)Sets the boolean value associated withkey.voidsetNumber(@NotNull java.lang.String key, @NotNull java.lang.Number value)Sets the numeric value associated withkey.voidsetString(@NotNull java.lang.String key, @NotNull java.lang.String value)Sets the string value associated withkey.voidsetStringArray(@NotNull java.lang.String key, @NotNull java.lang.String[] value)Sets the string array value associated withkey.
-
-
-
Method Detail
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
close
public final void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
isClosed
public final boolean isClosed()
Tells whether theclose()method has been called. Once an object is closed any method will throwIllegalStateException.- Returns:
trueif 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 withkey. 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- whenkeyis not found.java.lang.IllegalStateException- when entry atkeyis not a section.
-
getString
@NotNull public final @NotNull java.lang.String getString(@NotNull @NotNull java.lang.String key)Returns the string value associated withkey.- 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- whenkeyis not found.java.lang.IllegalStateException- when entry atkeyis 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 withkey.- 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 atkeyexists 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 withkey.- 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 atkeyexists 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 withkey.- 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- whenkeyis not found.java.lang.IllegalStateException- when entry atkeyis 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 withkey.- 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 atkeyexists 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 withkey.- 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 atkeyexists 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 withkey.- 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- whenkeyis not found.java.lang.IllegalStateException- when entry atkeyis 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 withkey.- 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 atkeyexists 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 withkey.- 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 atkeyexists 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 withkey.- 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- whenkeyis not found.java.lang.IllegalStateException- when entry atkeyis 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 withkey.- 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 atkeyis 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 withkey.- 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 atkeyexists 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- whenjsonis not valid JSON.
-
-