public abstract class JSONNode extends Object implements TemplateNodeModel, Serializable
NOTHING
Modifier | Constructor and Description |
---|---|
protected |
JSONNode(JSONNode parentNode,
String nodeName) |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getDefaultNodeName()
Returns the name of the node if it has no explicit name.
|
String |
getNodeName()
Returns the same as
TemplateNodeModel.getNodeType() , except when the node is the value in a key-value pair in a
JSON object, in which case it returns the key value. |
String |
getNodeNamespace() |
TemplateNodeModel |
getParentNode()
Returns the JSON "object" or JSON "array" that contains this value.
|
protected static String |
nodeTypeToDefaultNodeName(String nodeType)
Returns the FTL node name for a node that has otherwise no name.
|
static JSONNode |
wrap(Object jsonPOJO)
|
protected static JSONNode |
wrap(Object obj,
JSONNode parentNode,
String nodeName,
boolean wrapNullAsJSONNullNode) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildNodes, getNodeType
protected JSONNode(JSONNode parentNode, String nodeName)
parentNode
- the JSON "object" or JSON "array" that contains this value.nodeName
- null
, unless this is the value in a key-value pair, in which case it's the key.
When it's null
, the actual node name will be getDefaultNodeName()
.protected static String nodeTypeToDefaultNodeName(String nodeType)
protected abstract String getDefaultNodeName()
JSONNode(JSONNode, String)
constructor if its second argument is null
.nodeTypeToDefaultNodeName(String)
public final TemplateNodeModel getParentNode() throws TemplateModelException
getParentNode
in interface TemplateNodeModel
TemplateModelException
public final String getNodeName() throws TemplateModelException
TemplateNodeModel.getNodeType()
, except when the node is the value in a key-value pair in a
JSON object, in which case it returns the key value.getNodeName
in interface TemplateNodeModel
TemplateModelException
public final String getNodeNamespace() throws TemplateModelException
getNodeNamespace
in interface TemplateNodeModel
TemplateModelException
public static JSONNode wrap(Object jsonPOJO) throws TemplateModelException
List
, a Map
with string keys, a String
, a Number
or a Boolean
into a JSONNode
. The values in the List
or Map
must be also be one of the previously
listed types. The resulting object is NOT thread safe. Also, the wrapped objects shouldn't be changed after the
wrapping. The wrapping of the contained values is possibly lazy.null
for JSON null values, not a
JSONNullNode
instance.TemplateModelException
- If obj
can't be wrapped into JSON node.protected static JSONNode wrap(Object obj, JSONNode parentNode, String nodeName, boolean wrapNullAsJSONNullNode) throws TemplateModelException
parentNode
- Same as the similar parameter of JSONNode(JSONNode, String)
.nodeName
- Same as the similar parameter of JSONNode(JSONNode, String)
.TemplateModelException
- If obj
can't be wrapped into JSON node.