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 void
final void
close()
protected void
finalize()
final @NotNull Boolean
getBoolean
(@NotNull String key) Returns the boolean value associated withkey
.final @NotNull Boolean
getBoolean
(@NotNull String key, boolean defaultValue) Returns the boolean value associated withkey
.final @NotNull Number
Returns the numeric value associated withkey
.final @NotNull Number
Returns 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 ParameterSet
getSection
(@NotNull String key) Returns a parameter set object representing the section associated withkey
.final @NotNull String
Returns the string value associated withkey
.final @NotNull String
Returns 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 void
Injects the content of a JSON values into this parameter set.final boolean
isClosed()
Tells whether theclose()
method has been called.final void
setBoolean
(@NotNull String key, Boolean value) Sets the boolean value associated withkey
.final void
Sets the numeric value associated withkey
.final void
setNumberArray
(@NotNull String key, @NotNull Number[] value) Sets the numeric array value associated withkey
.final void
Sets the string value associated withkey
.final void
setStringArray
(@NotNull String key, @NotNull String[] value) Sets the string array value associated withkey
.
-
Method Details
-
finalize
-
close
public final void close()- Specified by:
close
in interfaceAutoCloseable
-
isClosed
public final boolean isClosed()Tells whether theclose()
method has been called. Once an object is closed any method will throwIllegalStateException
.- Returns:
true
if 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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 atkey
exists 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 atkey
exists 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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 atkey
exists 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 atkey
exists 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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 atkey
exists 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 atkey
exists 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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 atkey
is 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 atkey
exists 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
- whenkey
is not found.IllegalStateException
- when entry atkey
is 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 atkey
is 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 atkey
exists 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
- whenjson
is not valid JSON.
-