Package fmpp.models
Class JSONObjectNode
java.lang.Object
fmpp.models.JSONNode
fmpp.models.JSONObjectNode
- All Implemented Interfaces:
freemarker.template.AdapterTemplateModel
,freemarker.template.TemplateHashModel
,freemarker.template.TemplateHashModelEx
,freemarker.template.TemplateHashModelEx2
,freemarker.template.TemplateModel
,freemarker.template.TemplateNodeModel
,Serializable
JSON "object" value; see http://www.json.org/.
This class is NOT thread safe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface freemarker.template.TemplateHashModelEx2
freemarker.template.TemplateHashModelEx2.KeyValuePair, freemarker.template.TemplateHashModelEx2.KeyValuePairIterator
-
Field Summary
FieldsFields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfreemarker.template.TemplateModel
getAdaptedObject
(Class<?> hint) Returns the plain Java object wrapped into this node.freemarker.template.TemplateSequenceModel
protected String
Returns the name of the node if it has no explicit name.boolean
isEmpty()
freemarker.template.TemplateCollectionModel
keys()
freemarker.template.TemplateHashModelEx2.KeyValuePairIterator
int
size()
freemarker.template.TemplateCollectionModel
values()
Returns the values from the key-value pairs of this JSON object, returning Javanull
for JSONnull
-s.Methods inherited from class fmpp.models.JSONNode
getNodeName, getNodeNamespace, getParentNode, nodeTypeToDefaultNodeName, wrap, wrap
-
Field Details
-
NODE_TYPE
- See Also:
-
DEFAULT_NODE_NAME
-
-
Constructor Details
-
JSONObjectNode
- Parameters:
map
- The JSON name-value pairs. The keys must beString
-s, and values must be of a type thatJSONNode.wrap(Object)
can wrap. The values should be plain Java objects, notJSONNode
-s, or elseAdapterTemplateModel.getAdaptedObject(Class)
won't work properly.
-
-
Method Details
-
getNodeType
- Specified by:
getNodeType
in interfacefreemarker.template.TemplateNodeModel
- Throws:
freemarker.template.TemplateModelException
-
get
public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException Returns theJSONNode
for the given key from this JSON object, using a Javanull
for JSONnull
-s. Note thatgetChildNodes()
treats JSONnull
-s differently.- Specified by:
get
in interfacefreemarker.template.TemplateHashModel
- Throws:
freemarker.template.TemplateModelException
-
isEmpty
public boolean isEmpty() throws freemarker.template.TemplateModelException- Specified by:
isEmpty
in interfacefreemarker.template.TemplateHashModel
- Throws:
freemarker.template.TemplateModelException
-
size
public int size() throws freemarker.template.TemplateModelException- Specified by:
size
in interfacefreemarker.template.TemplateHashModelEx
- Throws:
freemarker.template.TemplateModelException
-
getChildNodes
public freemarker.template.TemplateSequenceModel getChildNodes() throws freemarker.template.TemplateModelException- Specified by:
getChildNodes
in interfacefreemarker.template.TemplateNodeModel
- Throws:
freemarker.template.TemplateModelException
-
keys
public freemarker.template.TemplateCollectionModel keys() throws freemarker.template.TemplateModelException- Specified by:
keys
in interfacefreemarker.template.TemplateHashModelEx
- Throws:
freemarker.template.TemplateModelException
-
values
public freemarker.template.TemplateCollectionModel values() throws freemarker.template.TemplateModelExceptionReturns the values from the key-value pairs of this JSON object, returning Javanull
for JSONnull
-s. Note thatgetChildNodes()
treats JSONnull
-s differently.- Specified by:
values
in interfacefreemarker.template.TemplateHashModelEx
- Throws:
freemarker.template.TemplateModelException
-
keyValuePairIterator
public freemarker.template.TemplateHashModelEx2.KeyValuePairIterator keyValuePairIterator() throws freemarker.template.TemplateModelException- Specified by:
keyValuePairIterator
in interfacefreemarker.template.TemplateHashModelEx2
- Throws:
freemarker.template.TemplateModelException
-
getDefaultNodeName
Description copied from class:JSONNode
Returns the name of the node if it has no explicit name. This is normally called by theJSONNode(JSONNode, String)
constructor if its second argument isnull
.- Specified by:
getDefaultNodeName
in classJSONNode
- See Also:
-
getAdaptedObject
Returns the plain Java object wrapped into this node.- Specified by:
getAdaptedObject
in interfacefreemarker.template.AdapterTemplateModel
- Since:
- 0.9.16
-