Package com.myscript.iink
Class ParameterSet
java.lang.Object
com.myscript.iink.ParameterSet
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
Configuration
Represents a set of iink parameters.
-
Method Summary
Modifier and TypeMethodDescriptionprotected final voidfinal voidclose()protected voidfinalize()final @NotNull BooleangetBoolean(@NotNull String key) Returns the boolean value associated withkey.final @NotNull BooleangetBoolean(@NotNull String key, boolean defaultValue) Returns the boolean value associated withkey.final @NotNull NumberReturns the numeric value associated withkey.final @NotNull NumberReturns the numeric value associated withkey.final @NotNull Number[]getNumberArray(@NotNull String key) Returns the numeric array value associated withkey.final @NotNull Number[]getNumberArray(@NotNull String key, @NotNull Number[] defaultValue) Returns the numeric array associated withkey.final @NotNull ParameterSetgetSection(@NotNull String key) Returns a parameter set object representing the section associated withkey.final @NotNull StringReturns the string value associated withkey.final @NotNull StringReturns the string value associated withkey.final @NotNull String[]getStringArray(@NotNull String key) Returns the string array value associated withkey.final @NotNull String[]getStringArray(@NotNull String key, @NotNull String[] defaultValue) Returns the string array associated withkey.final voidInjects the content of a JSON values into this parameter set.final booleanisClosed()Tells whether theclose()method has been called.final voidsetBoolean(@NotNull String key, Boolean value) Sets the boolean value associated withkey.final voidSets the numeric value associated withkey.final voidsetNumberArray(@NotNull String key, @NotNull Number[] value) Sets the numeric array value associated withkey.final voidSets the string value associated withkey.final voidsetStringArray(@NotNull String key, @NotNull String[] value) Sets the string array value associated withkey.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
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
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:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a section.
-
getString
Returns the string value associated withkey.- Parameters:
key- the key of the value to obtain.- Returns:
- the value.
- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a string.
-
getString
@NotNull public final @NotNull String getString(@NotNull @NotNull String key, @NotNull @NotNull 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:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a string.
-
setString
Sets the string value associated withkey.- Parameters:
key- the key of the value to set.value- the string value to set.- Throws:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a string.
-
getBoolean
Returns the boolean value associated withkey.- Parameters:
key- the key of the value to obtain.- Returns:
- the value.
- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a boolean.
-
getBoolean
@NotNull public final @NotNull Boolean getBoolean(@NotNull @NotNull 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:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a boolean.
-
setBoolean
Sets the boolean value associated withkey.- Parameters:
key- the key of the value to set.value- the boolean value to set.- Throws:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a boolean.
-
getNumber
Returns the numeric value associated withkey.- Parameters:
key- the key of the value to obtain.- Returns:
- the value.
- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a number.
-
getNumber
@NotNull public final @NotNull Number getNumber(@NotNull @NotNull String key, @NotNull @NotNull 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:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a number.
-
setNumber
Sets the numeric value associated withkey.- Parameters:
key- the key of the value to set.value- the number value to set.- Throws:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a number.
-
getStringArray
Returns the string array value associated withkey.- Parameters:
key- the key of the value to obtain.- Returns:
- the value.
- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a string array.
-
getStringArray
@NotNull public final @NotNull String[] getStringArray(@NotNull @NotNull String key, @NotNull @NotNull 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:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyis not a string array.- Since:
- 1.4
-
setStringArray
Sets the string array value associated withkey.- Parameters:
key- the key of the value to set.value- the value to set.- Throws:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a string array.
-
getNumberArray
Returns the numeric array value associated withkey.- Parameters:
key- the key of the value to obtain.- Returns:
- the value.
- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenkeyis not found.IllegalStateException- when entry atkeyis not a Number array.- Since:
- 3.1
-
getNumberArray
@NotNull public final @NotNull Number[] getNumberArray(@NotNull @NotNull String key, @NotNull @NotNull Number[] defaultValue) Returns the numeric 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:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyis not a Number array.- Since:
- 3.1
-
setNumberArray
Sets the numeric array value associated withkey.- Parameters:
key- the key of the value to set.value- the value to set.- Throws:
IllegalStateException- when this parameter set is closed.IllegalStateException- when entry atkeyexists and is not a Number array.- Since:
- 3.1
-
inject
Injects the content of a JSON values into this parameter set.- Parameters:
json- JSON parameter set values.- Throws:
IllegalStateException- when this parameter set is closed.IllegalArgumentException- whenjsonis not valid JSON.
-