public class State extends Object implements WritableShim
Properties.| Constructor and Description |
|---|
State() |
State(Properties properties) |
State(State otherState) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAll(Properties properties)
Populates this instance with values of a
Properties instance. |
void |
addAll(State otherState)
Populates this instance with properties of the other instance.
|
void |
addAllIfNotExist(Properties properties)
Add properties in a
Properties instance that are not in the current instance. |
void |
addAllIfNotExist(State otherState)
Add properties in a
State instance that are not in the current instance. |
void |
appendToListProp(String key,
String value)
Appends the input value to a list property that can be retrieved with
getPropAsList(java.lang.String). |
void |
appendToSetProp(String key,
String value)
Appends the input value to a set property that can be retrieved with
getPropAsSet(java.lang.String). |
boolean |
contains(String key)
Check if a property is set.
|
String |
getId()
Get the id of this instance.
|
String |
getProp(String key)
Get the value of a property.
|
String |
getProp(String key,
String def)
Get the value of a property, using the given default value if the property is not set.
|
boolean |
getPropAsBoolean(String key)
Get the value of a property as a boolean.
|
boolean |
getPropAsBoolean(String key,
boolean def)
Get the value of a property as a boolean, using the given default value if the property is not set.
|
Set<String> |
getPropAsCaseInsensitiveSet(String key)
Get the value of a property as a case insensitive
Set of strings. |
Set<String> |
getPropAsCaseInsensitiveSet(String key,
String def)
Get the value of a property as a case insensitive
Set of strings, using the given default value if the property is not set. |
double |
getPropAsDouble(String key)
Get the value of a property as a double.
|
double |
getPropAsDouble(String key,
double def)
Get the value of a property as a double, using the given default value if the property is not set.
|
int |
getPropAsInt(String key)
Get the value of a property as an integer.
|
int |
getPropAsInt(String key,
int def)
Get the value of a property as an integer, using the given default value if the property is not set.
|
com.google.gson.JsonArray |
getPropAsJsonArray(String key)
Get the value of a property as a
JsonArray. |
List<String> |
getPropAsList(String key)
Get the value of a comma separated property as a
List of strings. |
List<String> |
getPropAsList(String key,
String def)
Get the value of a property as a list of strings, using the given default value if the property is not set.
|
long |
getPropAsLong(String key)
Get the value of a property as a long integer.
|
long |
getPropAsLong(String key,
long def)
Get the value of a property as a long integer, using the given default value if the property is not set.
|
Set<String> |
getPropAsSet(String key)
Get the value of a comma separated property as a
Set of strings. |
Set<String> |
getPropAsSet(String key,
String def)
Get the value of a comma separated property as a
Set of strings. |
short |
getPropAsShort(String key)
Get the value of a property as a short.
|
short |
getPropAsShort(String key,
short def)
Get the value of a property as an short, using the given default value if the property is not set.
|
short |
getPropAsShortWithRadix(String key,
int radix)
Get the value of a property as a short.
|
short |
getPropAsShortWithRadix(String key,
short def,
int radix)
Get the value of a property as an short, using the given default value if the property is not set.
|
Properties |
getProperties()
Return a copy of the underlying
Properties object. |
protected String |
getProperty(String key)
Deprecated.
Use
getProp(String) |
protected String |
getProperty(String key,
String def)
Deprecated.
|
Set<String> |
getPropertyNames()
Get the names of all the properties set in a
Set. |
void |
overrideWith(Properties properties)
Add properties in a
Properties instance that are in the current instance. |
void |
overrideWith(State otherState)
Add properties in a
State instance that are in the current instance. |
void |
readFields(DataInput in) |
void |
removeProp(String key)
Remove a property if it exists.
|
void |
removePropsWithPrefix(String prefix)
Remove all properties with a certain keyPrefix
|
void |
setId(String id)
Set the id used for state persistence and logging.
|
void |
setProp(String key,
Object value)
Set a property.
|
void |
setProps(Properties commonProperties,
Properties specProperties)
Override existing
commonProperties and specProperties. |
String |
toString() |
void |
write(DataOutput out) |
public State()
public State(Properties properties)
public State(State otherState)
public Properties getProperties()
Properties object.Properties object.public void addAll(State otherState)
otherState - the other State instancepublic void addAll(Properties properties)
Properties instance.properties - a Properties instancepublic void addAllIfNotExist(State otherState)
State instance that are not in the current instance.otherState - a State instancepublic void addAllIfNotExist(Properties properties)
Properties instance that are not in the current instance.properties - a Properties instancepublic void overrideWith(State otherState)
State instance that are in the current instance.otherState - a State instancepublic void overrideWith(Properties properties)
Properties instance that are in the current instance.properties - a Properties instancepublic void setId(String id)
id - id of this instancepublic String getId()
public void setProp(String key, Object value)
Both key and value are stored as strings.
key - property keyvalue - property valuepublic void setProps(Properties commonProperties, Properties specProperties)
commonProperties and specProperties.commonProperties - specProperties - public void appendToListProp(String key, String value)
getPropAsList(java.lang.String).
List properties are internally stored as comma separated strings. Adding a value that contains commas (for
example "a,b,c") will essentially add multiple values to the property ("a", "b", and "c"). This is
similar to the way that Configuration works.
key - property keyvalue - property value (if it includes commas, it will be split by the commas).public void appendToSetProp(String key, String value)
getPropAsSet(java.lang.String).
Set properties are internally stored as comma separated strings. Adding a value that contains commas (for
example "a,b,c") will essentially add multiple values to the property ("a", "b", and "c"). This is
similar to the way that Configuration works.
key - property keyvalue - property value (if it includes commas, it will be split by the commas).public String getProp(String key)
key - property keynull if the property is not setpublic String getProp(String key, String def)
key - property keydef - default valuepublic List<String> getPropAsList(String key)
List of strings.key - property keyList of stringspublic List<String> getPropAsList(String key, String def)
key - property keydef - default valuepublic Set<String> getPropAsSet(String key)
Set of strings.key - property keySet of stringspublic Set<String> getPropAsSet(String key, String def)
Set of strings.key - property keydef - default valueSet of stringspublic Set<String> getPropAsCaseInsensitiveSet(String key)
Set of strings.key - property keySet of stringspublic Set<String> getPropAsCaseInsensitiveSet(String key, String def)
Set of strings, using the given default value if the property is not set.key - property keydef - default valueSet of stringspublic long getPropAsLong(String key)
key - property keypublic long getPropAsLong(String key, long def)
key - property keydef - default valuepublic int getPropAsInt(String key)
key - property keypublic int getPropAsInt(String key, int def)
key - property keydef - default valuepublic short getPropAsShort(String key)
key - property keypublic short getPropAsShortWithRadix(String key, int radix)
key - property keyradix - radix used to parse the valuepublic short getPropAsShort(String key, short def)
key - property keydef - default valuepublic short getPropAsShortWithRadix(String key, short def, int radix)
key - property keydef - default valueradix - radix used to parse the valuepublic double getPropAsDouble(String key)
key - property keypublic double getPropAsDouble(String key, double def)
key - property keydef - default valuepublic boolean getPropAsBoolean(String key)
key - property keypublic boolean getPropAsBoolean(String key, boolean def)
key - property keydef - default valuepublic com.google.gson.JsonArray getPropAsJsonArray(String key)
JsonArray.key - property keyJsonArray value associated with the keypublic void removeProp(String key)
key - property keypublic void removePropsWithPrefix(String prefix)
prefix - key prefix@Deprecated protected String getProperty(String key)
getProp(String)@Deprecated protected String getProperty(String key, String def)
getProp(String, String)public Set<String> getPropertyNames()
Set.Setpublic boolean contains(String key)
key - property keytrue if the property is set or false otherwisepublic void readFields(DataInput in) throws IOException
readFields in interface WritableShimIOExceptionpublic void write(DataOutput out) throws IOException
write in interface WritableShimIOException