public class JSONMap extends AbstractMap<String,Object> implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
JSONMap.JSONList |
static class |
JSONMap.ValueOutOfRangeException
Thrown to indicate that a value is either too large or too small to be represented by the
required type.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
JSONMap()
Constructs an empty
RoamingMap . |
JSONMap(Map<String,?> pMap)
Constructs a new
RoamingMap with the same mappings as the
specified Map . |
JSONMap(String pJSONString)
Constructs a new
RoamingMap with the specified JSON string. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object pKey) |
boolean |
containsValue(Object pValue) |
Set<Map.Entry<String,Object>> |
entrySet() |
Object |
get(Object pKey) |
<T> T |
getAs(Class<T> pType,
String pKey)
Convenience method to get the value as a typed object.
|
Boolean |
getAsBoolean(String pKey)
Convenience method to get the value as a
Boolean object. |
Double |
getAsDouble(String pKey)
Convenience method to get the value as a
Double object. |
Float |
getAsFloat(String pKey)
Convenience method to get the value as a
Float object. |
Integer |
getAsInteger(String pKey)
Convenience method to get the value as an
Integer object. |
JSONMap.JSONList |
getAsList(String pKey)
Convenience method to get the value as a
JSONList object. |
Long |
getAsLong(String pKey)
Convenience method to get the value as an
Long object. |
JSONMap |
getAsMap(String pKey)
Convenience method to get the value as a
JSONMap object. |
String |
getAsString(String pKey)
Convenience method to get the value as a
String object. |
boolean |
isEmpty() |
Set<String> |
keySet() |
Object |
put(String pKey,
Object pValue) |
void |
putAll(Map<? extends String,?> pMap) |
Object |
remove(Object pKey) |
int |
size() |
String |
toString() |
Collection<Object> |
values() |
clone, equals, hashCode
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public JSONMap()
RoamingMap
.public JSONMap(Map<String,?> pMap)
RoamingMap
with the same mappings as the
specified Map
.pMap
- the map whose mappings are to be placed in this mapNullPointerException
- if the specified map is nullIllegalArgumentException
- if the specified map violates the constraintspublic JSONMap(String pJSONString)
RoamingMap
with the specified JSON
string.pJSONString
- the JSON
string to useIllegalArgumentException
- if parsing of the JSON
string failspublic int size()
public boolean isEmpty()
public boolean containsKey(Object pKey)
containsKey
in interface Map<String,Object>
containsKey
in class AbstractMap<String,Object>
public boolean containsValue(Object pValue)
containsValue
in interface Map<String,Object>
containsValue
in class AbstractMap<String,Object>
public JSONMap getAsMap(String pKey)
JSONMap
object.pKey
- the key to get from the mapJSONMap
ClassCastException
- if the value for pKey
can't be cast to JSONMap
public JSONMap.JSONList getAsList(String pKey)
JSONList
object.pKey
- the key to get from the mapJSONList
ClassCastException
- if the value for pKey
can't be cast to JSONList
public String getAsString(String pKey)
String
object.pKey
- the key to get from the mapString
ClassCastException
- if the value for pKey
can't be cast to String
public Boolean getAsBoolean(String pKey)
Boolean
object.pKey
- the keyBoolean
ClassCastException
- if the value for pKey
can't be cast to Boolean
public final Integer getAsInteger(String pKey)
Integer
object.pKey
- the keyInteger
ClassCastException
- if the value for pKey
can't be cast to Number
JSONMap.ValueOutOfRangeException
- if the value is outside [Integer.MIN_VALUE
.. Integer.MAX_VALUE
]public final Long getAsLong(String pKey)
Long
object.pKey
- the keyLong
ClassCastException
- if the value for pKey
can't be cast to Number
JSONMap.ValueOutOfRangeException
- if the value is outside [Long.MIN_VALUE
.. Long.MAX_VALUE
]public final Float getAsFloat(String pKey)
Float
object.pKey
- the keyFloat
ClassCastException
- if the value for pKey
can't be cast to Number
JSONMap.ValueOutOfRangeException
- if the value is outside [-Float.MAX_VALUE
.. +Float.MAX_VALUE
]public final Double getAsDouble(String pKey)
Double
object.pKey
- the keyDouble
ClassCastException
- if the value for pKey
can't be cast to Number
JSONMap.ValueOutOfRangeException
- if the value is outside [-Double.MAX_VALUE
.. +Double.MAX_VALUE
]public <T> T getAs(Class<T> pType, String pKey)
pType
- the typepKey
- the keyClassCastException
- if the value for pKey
can't be cast to the type of pType
public Object put(String pKey, Object pValue)
put
in interface Map<String,Object>
put
in class AbstractMap<String,Object>
IllegalArgumentException
- if the key or value violates the contraintspublic void putAll(Map<? extends String,?> pMap)
putAll
in interface Map<String,Object>
putAll
in class AbstractMap<String,Object>
IllegalArgumentException
- if the map violates the contraintspublic void clear()
public Collection<Object> values()
public String toString()
toString
in class AbstractMap<String,Object>
© 1998- 2021 Escenic AS