Package org.mapfish.print.wrapper.json
Class PJsonObject
java.lang.Object
org.mapfish.print.wrapper.PElement
org.mapfish.print.wrapper.PAbstractObject
org.mapfish.print.wrapper.json.PJsonObject
- All Implemented Interfaces:
PObject
Wrapper around the
JSONObject class to have a better error management.-
Constructor Summary
ConstructorsConstructorDescriptionPJsonObject(org.json.JSONObject obj, String contextName) Constructor.PJsonObject(PElement parent, org.json.JSONObject obj, String contextName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal org.json.JSONObjectGet the internal json object.final PJsonArraygetJSONArray(String key) Get a property as a json array or throw exception.final PJsonObjectgetJSONObject(String key) Get a property as a json object or throw exception.final booleanCheck if the object has a property with the key.inthashCode()final booleanIs the property an array.keys()Get an iterator of all keys in this objects.final ObjectGet the value for the key.final PArrayGet a property as a array or null.final BooleanGet a property as a boolean or null.final DoubleGet a property as a double or null.final FloatGet a property as a float or null.final IntegerGet a property as a int or null.final PJsonArrayoptJSONArray(String key) Get a property as a json array or null.final PJsonArrayoptJSONArray(String key, PJsonArray defaultValue) Get a property as a json array or default.final PJsonObjectoptJSONObject(String key) Get a property as a json object or null.final LongGet a property as a long or MIN_VALUE.final PObjectGet a property as a object or null.final StringGet a property as a string or null.final intsize()Get the number of properties in this object.final StringtoString()Methods inherited from class org.mapfish.print.wrapper.PAbstractObject
getArray, getBool, getDouble, getFloat, getInt, getLong, getObject, getString, optArray, optBool, optDouble, optFloat, optInt, optLong, optObject, optStringMethods inherited from class org.mapfish.print.wrapper.PElement
addPathTo, getContextName, getCurrentPath, getParent, getPathMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.mapfish.print.wrapper.PObject
getCurrentPath, getPath
-
Constructor Details
-
PJsonObject
Constructor.- Parameters:
obj- the internal json elementcontextName- the field name of this element in the parent.
-
PJsonObject
Constructor.- Parameters:
parent- the parent elementobj- the internal json elementcontextName- the field name of this element in the parent.
-
-
Method Details
-
opt
Description copied from interface:PObjectGet the value for the key.- Parameters:
key- the key identifying the value to obtain.
-
optString
Get a property as a string or null.- Parameters:
key- the property name
-
optInt
Get a property as a int or null.- Parameters:
key- the property name
-
optLong
Description copied from interface:PObjectGet a property as a long or MIN_VALUE.- Parameters:
key- the property name
-
optDouble
Get a property as a double or null.- Parameters:
key- the property name
-
optFloat
Get a property as a float or null.- Parameters:
key- the property name
-
optBool
Get a property as a boolean or null.- Parameters:
key- the property name
-
optObject
Get a property as a object or null.- Parameters:
key- the property name
-
optArray
Get a property as a array or null.- Parameters:
key- the property name
-
isArray
Description copied from interface:PObjectIs the property an array.- Parameters:
key- the property name
-
optJSONObject
Get a property as a json object or null.- Parameters:
key- the property name
-
getJSONObject
Get a property as a json object or throw exception.- Parameters:
key- the property name
-
getJSONArray
Get a property as a json array or throw exception.- Parameters:
key- the property name
-
optJSONArray
Get a property as a json array or null.- Parameters:
key- the property name
-
optJSONArray
Get a property as a json array or default.- Parameters:
key- the property namedefaultValue- default
-
keys
Get an iterator of all keys in this objects.- Returns:
- The keys iterator
-
size
public final int size()Get the number of properties in this object. -
hashCode
public int hashCode() -
equals
-
getInternalObj
public final org.json.JSONObject getInternalObj()Get the internal json object.- Returns:
- The internal object
-
has
Check if the object has a property with the key.- Parameters:
key- key to check for.
-
toString
-