public class ParameterSet extends java.lang.Object implements IAutoCloseable
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotClosed() |
void |
close()
Deletes native counterpart of this auto closable object
|
java.lang.Boolean |
getBoolean(java.lang.String key)
Returns the boolean value associated with
key . |
java.lang.Boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Returns the boolean value associated with
key . |
java.lang.Number |
getNumber(java.lang.String key)
Returns the numeric value associated with
key . |
java.lang.Number |
getNumber(java.lang.String key,
java.lang.Number defaultValue)
Returns the numeric value associated with
key . |
ParameterSet |
getSection(java.lang.String key)
Returns a parameter set object representing the section associated with
key . |
java.lang.String |
getString(java.lang.String key)
Returns the string value associated with
key . |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Returns the string value associated with
key . |
java.lang.String[] |
getStringArray(java.lang.String key)
Returns the string array value associated with
key . |
java.lang.String[] |
getStringArray(java.lang.String key,
java.lang.String[] defaultValue)
Returns the string array associated with
key . |
void |
inject(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(java.lang.String key,
java.lang.Boolean value)
Sets the boolean value associated with
key . |
void |
setNumber(java.lang.String key,
java.lang.Number value)
Sets the numeric value associated with
key . |
void |
setString(java.lang.String key,
java.lang.String value)
Sets the string value associated with
key . |
void |
setStringArray(java.lang.String key,
java.lang.String[] value)
Sets the string array value associated with
key . |
public final void close()
IAutoCloseable
close
in interface IAutoCloseable
public final boolean isClosed()
close()
method has been called. Once an object
is closed any method will throw IllegalStateException
.true
if this object is closed.protected final void checkNotClosed()
public final ParameterSet getSection(java.lang.String key)
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.
key
- the key of the section to obtain.java.lang.IllegalStateException
- when this configuration is closed.java.lang.IllegalArgumentException
- when key
is not found.java.lang.IllegalStateException
- when entry at key
is not a
section.public final java.lang.String getString(java.lang.String key)
key
.key
- the key of the value to obtain.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.public final java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
key
.key
- the key of the value to obtain.defaultValue
- the value to return when key is not present.java.lang.IllegalStateException
- when entry at key
exists and is
not a string.public final void setString(java.lang.String key, java.lang.String value)
key
.key
- the key of the value to set.value
- the string value to set.java.lang.IllegalStateException
- when this parameter set is closed.java.lang.IllegalStateException
- when entry at key
exists and is
not a string.public final java.lang.Boolean getBoolean(java.lang.String key)
key
.key
- the key of the value to obtain.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.public final java.lang.Boolean getBoolean(java.lang.String key, boolean defaultValue)
key
.key
- the key of the value to obtain.defaultValue
- the value to return when key is not present.java.lang.IllegalStateException
- when entry at key
exists and is
not a boolean.public final void setBoolean(java.lang.String key, java.lang.Boolean value)
key
.key
- the key of the value to set.value
- the boolean value to set.java.lang.IllegalStateException
- when this parameter set is closed.java.lang.IllegalStateException
- when entry at key
exists and is
not a boolean.public final java.lang.Number getNumber(java.lang.String key)
key
.key
- the key of the value to obtain.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.public final java.lang.Number getNumber(java.lang.String key, java.lang.Number defaultValue)
key
.key
- the key of the value to obtain.defaultValue
- the value to return when key is not present.java.lang.IllegalStateException
- when entry at key
exists and is
not a number.public final void setNumber(java.lang.String key, java.lang.Number value)
key
.key
- the key of the value to set.value
- the number value to set.java.lang.IllegalStateException
- when this parameter set is closed.java.lang.IllegalStateException
- when entry at key
exists and is
not a number.public final java.lang.String[] getStringArray(java.lang.String key)
key
.key
- the key of the value to obtain.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.public final java.lang.String[] getStringArray(java.lang.String key, java.lang.String[] defaultValue)
key
.key
- the key of the value to obtain.defaultValue
- the value to return when key is not present.java.lang.IllegalStateException
- when entry at key
is not a
string array.public final void setStringArray(java.lang.String key, java.lang.String[] value)
key
.key
- the key of the value to set.value
- the value to set.java.lang.IllegalStateException
- when this parameter set is closed.java.lang.IllegalStateException
- when entry at key
exists and is
not a string array.public final void inject(java.lang.String json)
json
- JSON parameter set values.java.lang.IllegalStateException
- when this parameter set is closed.java.lang.IllegalArgumentException
- when json
is not valid JSON.