public class JSONObjectNode extends JSONNode implements freemarker.template.TemplateHashModelEx2
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NODE_NAME |
static java.lang.String |
NODE_TYPE |
Constructor and Description |
---|
JSONObjectNode(JSONNode parentNode,
java.lang.String nodeName,
java.util.Map map) |
Modifier and Type | Method and Description |
---|---|
freemarker.template.TemplateModel |
get(java.lang.String key)
|
java.util.Map<java.lang.String,java.lang.Object> |
getAdaptedObject(java.lang.Class<?> hint)
Returns the plain Java object wrapped into this node.
|
freemarker.template.TemplateSequenceModel |
getChildNodes() |
protected java.lang.String |
getDefaultNodeName()
Returns the name of the node if it has no explicit name.
|
java.lang.String |
getNodeType() |
boolean |
isEmpty() |
freemarker.template.TemplateCollectionModel |
keys() |
freemarker.template.TemplateHashModelEx2.KeyValuePairIterator |
keyValuePairIterator() |
int |
size() |
freemarker.template.TemplateCollectionModel |
values()
Returns the values from the key-value pairs of this JSON object, returning Java
null for JSON
null -s. |
getNodeName, getNodeNamespace, getParentNode, nodeTypeToDefaultNodeName, wrap, wrap
public static final java.lang.String NODE_TYPE
public static final java.lang.String DEFAULT_NODE_NAME
public JSONObjectNode(JSONNode parentNode, java.lang.String nodeName, java.util.Map map)
map
- The JSON name-value pairs. The keys must be String
-s, and values must be of a type that
JSONNode.wrap(Object)
can wrap. The values should be plain Java objects, not JSONNode
-s,
or else AdapterTemplateModel.getAdaptedObject(Class)
won't work properly.public java.lang.String getNodeType() throws freemarker.template.TemplateModelException
getNodeType
in interface freemarker.template.TemplateNodeModel
freemarker.template.TemplateModelException
public freemarker.template.TemplateModel get(java.lang.String key) throws freemarker.template.TemplateModelException
JSONNode
for the given key from this JSON object, using a Java null
for JSON
null
-s. Note that getChildNodes()
treats JSON null
-s differently.get
in interface freemarker.template.TemplateHashModel
freemarker.template.TemplateModelException
public boolean isEmpty() throws freemarker.template.TemplateModelException
isEmpty
in interface freemarker.template.TemplateHashModel
freemarker.template.TemplateModelException
public int size() throws freemarker.template.TemplateModelException
size
in interface freemarker.template.TemplateHashModelEx
freemarker.template.TemplateModelException
public freemarker.template.TemplateSequenceModel getChildNodes() throws freemarker.template.TemplateModelException
getChildNodes
in interface freemarker.template.TemplateNodeModel
freemarker.template.TemplateModelException
public freemarker.template.TemplateCollectionModel keys() throws freemarker.template.TemplateModelException
keys
in interface freemarker.template.TemplateHashModelEx
freemarker.template.TemplateModelException
public freemarker.template.TemplateCollectionModel values() throws freemarker.template.TemplateModelException
null
for JSON
null
-s. Note that getChildNodes()
treats JSON null
-s differently.values
in interface freemarker.template.TemplateHashModelEx
freemarker.template.TemplateModelException
public freemarker.template.TemplateHashModelEx2.KeyValuePairIterator keyValuePairIterator() throws freemarker.template.TemplateModelException
keyValuePairIterator
in interface freemarker.template.TemplateHashModelEx2
freemarker.template.TemplateModelException
protected java.lang.String getDefaultNodeName()
JSONNode
JSONNode.JSONNode(JSONNode, String)
constructor if its second argument is null
.getDefaultNodeName
in class JSONNode
JSONNode.nodeTypeToDefaultNodeName(String)
public java.util.Map<java.lang.String,java.lang.Object> getAdaptedObject(java.lang.Class<?> hint)
getAdaptedObject
in interface freemarker.template.AdapterTemplateModel