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 TypeMethodDescriptionboolean
final org.json.JSONObject
Get the internal json object.final PJsonArray
getJSONArray
(String key) Get a property as a json array or throw exception.final PJsonObject
getJSONObject
(String key) Get a property as a json object or throw exception.final boolean
Check if the object has a property with the key.int
hashCode()
final boolean
Is the property an array.keys()
Get an iterator of all keys in this objects.final Object
Get the value for the key.final PArray
Get a property as a array or null.final Boolean
Get a property as a boolean or null.final Double
Get a property as a double or null.final Float
Get a property as a float or null.final Integer
Get a property as a int or null.final PJsonArray
optJSONArray
(String key) Get a property as a json array or null.final PJsonArray
optJSONArray
(String key, PJsonArray defaultValue) Get a property as a json array or default.final PJsonObject
optJSONObject
(String key) Get a property as a json object or null.final Long
Get a property as a long or MIN_VALUE.final PObject
Get a property as a object or null.final String
Get a property as a string or null.final int
size()
Get the number of properties in this object.final String
toString()
Methods inherited from class org.mapfish.print.wrapper.PAbstractObject
getArray, getBool, getDouble, getFloat, getInt, getLong, getObject, getString, optArray, optBool, optDouble, optFloat, optInt, optLong, optObject, optString
Methods inherited from class org.mapfish.print.wrapper.PElement
addPathTo, getContextName, getCurrentPath, getParent, getPath
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:PObject
Get 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:PObject
Get 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:PObject
Is 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
-