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.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 withkey
.@NotNull java.lang.Boolean
getBoolean(@NotNull java.lang.String key, boolean defaultValue)
Returns the boolean value associated withkey
.@NotNull java.lang.Number
getNumber(@NotNull java.lang.String key)
Returns the numeric value associated withkey
.@NotNull java.lang.Number
getNumber(@NotNull java.lang.String key, @NotNull java.lang.Number defaultValue)
Returns the numeric value associated withkey
.@NotNull ParameterSet
getSection(@NotNull java.lang.String key)
Returns a parameter set object representing the section associated withkey
.@NotNull java.lang.String
getString(@NotNull java.lang.String key)
Returns the string value associated withkey
.@NotNull java.lang.String
getString(@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
.void
inject(@NotNull java.lang.String json)
Injects the content of a JSON values into this parameter set.boolean
isClosed()
Tells whether theclose()
method has been called.void
setBoolean(@NotNull java.lang.String key, java.lang.Boolean value)
Sets the boolean value associated withkey
.void
setNumber(@NotNull java.lang.String key, @NotNull java.lang.Number value)
Sets the numeric value associated withkey
.void
setString(@NotNull java.lang.String key, @NotNull java.lang.String value)
Sets the string value associated withkey
.void
setStringArray(@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:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
close
public final void close()
- Specified by:
close
in 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:
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 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
- whenkey
is not found.java.lang.IllegalStateException
- when entry atkey
is 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
- whenkey
is not found.java.lang.IllegalStateException
- when entry atkey
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 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 atkey
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 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 atkey
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 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
- whenkey
is not found.java.lang.IllegalStateException
- when entry atkey
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 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 atkey
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 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 atkey
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 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
- whenkey
is not found.java.lang.IllegalStateException
- when entry atkey
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 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 atkey
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 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 atkey
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 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
- whenkey
is not found.java.lang.IllegalStateException
- when entry atkey
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 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 atkey
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 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 atkey
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
- whenjson
is not valid JSON.
-
-