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

public class JSONObjectNode extends JSONNode implements freemarker.template.TemplateHashModelEx2
JSON "object" value; see http://www.json.org/. This class is NOT thread safe.
See Also:
  • Field Details

  • Constructor Details

    • JSONObjectNode

      public JSONObjectNode(JSONNode parentNode, String nodeName, Map map)
      Parameters:
      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.
  • Method Details

    • getNodeType

      public String getNodeType() throws freemarker.template.TemplateModelException
      Specified by:
      getNodeType in interface freemarker.template.TemplateNodeModel
      Throws:
      freemarker.template.TemplateModelException
    • get

      public freemarker.template.TemplateModel get(String key) throws freemarker.template.TemplateModelException
      Returns the 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.
      Specified by:
      get in interface freemarker.template.TemplateHashModel
      Throws:
      freemarker.template.TemplateModelException
    • isEmpty

      public boolean isEmpty() throws freemarker.template.TemplateModelException
      Specified by:
      isEmpty in interface freemarker.template.TemplateHashModel
      Throws:
      freemarker.template.TemplateModelException
    • size

      public int size() throws freemarker.template.TemplateModelException
      Specified by:
      size in interface freemarker.template.TemplateHashModelEx
      Throws:
      freemarker.template.TemplateModelException
    • getChildNodes

      public freemarker.template.TemplateSequenceModel getChildNodes() throws freemarker.template.TemplateModelException
      Specified by:
      getChildNodes in interface freemarker.template.TemplateNodeModel
      Throws:
      freemarker.template.TemplateModelException
    • keys

      public freemarker.template.TemplateCollectionModel keys() throws freemarker.template.TemplateModelException
      Specified by:
      keys in interface freemarker.template.TemplateHashModelEx
      Throws:
      freemarker.template.TemplateModelException
    • values

      public freemarker.template.TemplateCollectionModel values() throws freemarker.template.TemplateModelException
      Returns the values from the key-value pairs of this JSON object, returning Java null for JSON null-s. Note that getChildNodes() treats JSON null-s differently.
      Specified by:
      values in interface freemarker.template.TemplateHashModelEx
      Throws:
      freemarker.template.TemplateModelException
    • keyValuePairIterator

      public freemarker.template.TemplateHashModelEx2.KeyValuePairIterator keyValuePairIterator() throws freemarker.template.TemplateModelException
      Specified by:
      keyValuePairIterator in interface freemarker.template.TemplateHashModelEx2
      Throws:
      freemarker.template.TemplateModelException
    • getDefaultNodeName

      protected String getDefaultNodeName()
      Description copied from class: JSONNode
      Returns the name of the node if it has no explicit name. This is normally called by the JSONNode(JSONNode, String) constructor if its second argument is null.
      Specified by:
      getDefaultNodeName in class JSONNode
      See Also:
    • getAdaptedObject

      public Map<String,Object> getAdaptedObject(Class<?> hint)
      Returns the plain Java object wrapped into this node.
      Specified by:
      getAdaptedObject in interface freemarker.template.AdapterTemplateModel
      Since:
      0.9.16