|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<java.lang.String,java.lang.Object>
org.pfsw.text.json.JsonObject
public class JsonObject
The Java representation of a JSON object. A typed map that has string keys.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
| Field Summary |
|---|
| Fields inherited from interface org.pfsw.bif.text.IJSONConvertible |
|---|
JSON_ARRAY_END, JSON_ARRAY_START, JSON_ELEMENT_SEPARATOR, JSON_LITERAL_FALSE, JSON_LITERAL_NULL, JSON_LITERAL_TRUE, JSON_OBJECT_END, JSON_OBJECT_START, JSON_PAIR_SEPARATOR, JSON_STRING_DELIMITER, JSON_STRING_ESCAPE |
| Constructor Summary | |
|---|---|
JsonObject()
|
|
JsonObject(int initialCapacity)
|
|
JsonObject(int initialCapacity,
float loadFactor)
|
|
JsonObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
|
|
| Method Summary | ||
|---|---|---|
void |
appendAsJSONString(java.lang.Appendable output)
|
|
java.lang.String |
asString()
Returns the JSON string representation of this object. |
|
java.math.BigDecimal |
getBigDecimal(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as BigDecimal (if it is one). |
|
java.math.BigDecimal |
getBigDecimal(java.lang.String name)
Returns the value for the given name as BigDecimal (if it is one). |
|
java.lang.Boolean |
getBoolean(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as Boolean (if it is one). |
|
java.lang.Boolean |
getBoolean(java.lang.String name)
Returns the value for the given name as Boolean (if it is one). |
|
java.lang.Integer |
getInteger(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as Integer (if it is one). |
|
java.lang.Integer |
getInteger(java.lang.String name)
Returns the value for the given name as Integer (if it is one). |
|
JsonArray |
getJsonArray(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as JsonArray (if it is one). |
|
JsonArray |
getJsonArray(java.lang.String name)
Returns the value for the given name as JsonArray (if it is one). |
|
JsonObject |
getJsonObject(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as JsonObject (if it is one). |
|
JsonObject |
getJsonObject(java.lang.String name)
Returns the value for the given name as JsonObject (if it is one). |
|
java.lang.Long |
getLong(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as Long (if it is one). |
|
java.lang.Long |
getLong(java.lang.String name)
Returns the value for the given name as Long (if it is one). |
|
java.util.Collection<java.lang.String> |
getNames()
|
|
java.lang.Number |
getNumber(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as Number (if it is one). |
|
java.lang.Number |
getNumber(java.lang.String name)
Returns the value for the given name as Number (if it is one). |
|
java.lang.String |
getString(org.pfsw.bif.text.IStringConstant name)
Returns the value for the given name as String (if it is one). |
|
java.lang.String |
getString(java.lang.String name)
Returns the value for the given name as String (if it is one). |
|
protected
|
getTypedElement(java.lang.String name,
java.lang.Class<T> type)
|
|
java.lang.Object |
getValue(org.pfsw.bif.text.IStringConstant name)
|
|
java.lang.Object |
getValue(java.lang.String name)
|
|
|
getValueOfType(org.pfsw.bif.text.IStringConstant name,
java.lang.Class<T> type)
Returns the value for the given name as type of the given class. |
|
|
getValueOfType(java.lang.String name,
java.lang.Class<T> type)
Returns the value for the given name as type of the given class. |
|
boolean |
isArray()
Returns false because this is no JSON array representation (in Java). |
|
boolean |
isObject()
Returns true because this is a JSON object representation (in Java). |
|
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
Adds the given element if it is a valid JSON object type. |
|
JsonObject |
setField(org.pfsw.bif.text.IStringConstant name,
java.lang.Object value)
Adds the given element if it is a valid JSON object type. |
|
java.lang.String |
toJSON()
|
|
| Methods inherited from class java.util.LinkedHashMap |
|---|
clear, containsValue, get, removeEldestEntry |
| Methods inherited from class java.util.HashMap |
|---|
clone, containsKey, entrySet, isEmpty, keySet, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.pfsw.bif.facet.IReadOnlyNamedValues |
|---|
isEmpty |
| Methods inherited from interface java.util.Map |
|---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, putAll, remove, size, values |
| Constructor Detail |
|---|
public JsonObject()
public JsonObject(int initialCapacity,
float loadFactor)
public JsonObject(int initialCapacity)
public JsonObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
| Method Detail |
|---|
public java.lang.Object put(java.lang.String key,
java.lang.Object value)
Valid types are:
put in interface java.util.Map<java.lang.String,java.lang.Object>put in class java.util.HashMap<java.lang.String,java.lang.Object>java.lang.IllegalArgumentException - If the given object is not of a valid JSON type.
public JsonObject setField(org.pfsw.bif.text.IStringConstant name,
java.lang.Object value)
Valid types are:
java.lang.IllegalArgumentException - If the given object is not of a valid JSON type.public JsonObject getJsonObject(java.lang.String name)
name - The name of the object to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no JsonObject.public JsonObject getJsonObject(org.pfsw.bif.text.IStringConstant name)
name - The name of the object to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no JsonObject.public JsonArray getJsonArray(java.lang.String name)
name - The name of the array to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no JsonArray.public JsonArray getJsonArray(org.pfsw.bif.text.IStringConstant name)
name - The name of the array to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no JsonArray.public java.lang.String getString(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no String.public java.lang.String getString(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no String.public java.lang.Boolean getBoolean(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Boolean.public java.lang.Boolean getBoolean(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Boolean.public java.lang.Number getNumber(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Number.public java.lang.Number getNumber(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Number.public java.lang.Integer getInteger(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Integer.public java.lang.Integer getInteger(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Integer.public java.lang.Long getLong(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Long.public java.lang.Long getLong(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no Long.public java.math.BigDecimal getBigDecimal(java.lang.String name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no BigDecimal.public java.math.BigDecimal getBigDecimal(org.pfsw.bif.text.IStringConstant name)
name - The name of the value to look for (must not be null).
java.lang.ClassCastException - If the object associated to the given name is no BigDecimal.
public <T> T getValueOfType(java.lang.String name,
java.lang.Class<T> type)
name - The name of the value to look for (must not be null).
java.lang.IllegalArgumentException - If the specified type is no valid JSON type.
java.lang.ClassCastException - If the object associated to the given name is not of the specified type.
public <T> T getValueOfType(org.pfsw.bif.text.IStringConstant name,
java.lang.Class<T> type)
name - The name of the value to look for (must not be null).
java.lang.IllegalArgumentException - If the specified type is no valid JSON type.
java.lang.ClassCastException - If the object associated to the given name is not of the specified type.public boolean isObject()
isObject in interface JsonTypepublic boolean isArray()
isArray in interface JsonTypepublic java.util.Collection<java.lang.String> getNames()
getNames in interface org.pfsw.bif.facet.IReadOnlyNamedValues<java.lang.Object>public java.lang.Object getValue(java.lang.String name)
getValue in interface org.pfsw.bif.facet.IReadOnlyNamedValues<java.lang.Object>public java.lang.Object getValue(org.pfsw.bif.text.IStringConstant name)
public java.lang.String asString()
asString in interface org.pfsw.bif.text.IStringRepresentationpublic void appendAsJSONString(java.lang.Appendable output)
appendAsJSONString in interface org.pfsw.bif.text.IJSONConvertiblepublic java.lang.String toJSON()
toJSON in interface org.pfsw.bif.text.IJSONConvertible
protected <T> T getTypedElement(java.lang.String name,
java.lang.Class<T> type)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||