at.newmedialab.ldpath.template.model.freemarker
Class TemplateNodeModel<Node>

java.lang.Object
  extended by at.newmedialab.ldpath.template.model.freemarker.TemplateNodeModel<Node>
All Implemented Interfaces:
freemarker.template.AdapterTemplateModel, freemarker.template.TemplateHashModel, freemarker.template.TemplateModel

public class TemplateNodeModel<Node>
extends Object
implements freemarker.template.TemplateModel, freemarker.template.TemplateHashModel, freemarker.template.AdapterTemplateModel

A custom freemarker model to represent RDF nodes (implementation independent, generic)

Author: Sebastian Schaffert


Field Summary
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Constructor Summary
TemplateNodeModel(Node node, RDFBackend<Node> backend)
           
 
Method Summary
 freemarker.template.TemplateModel get(String key)
          Gets a TemplateModel from the hash.
 Object getAdaptedObject(Class hint)
          Retrieves the underlying object, or some other object semantically equivalent to its value narrowed by the class hint.
 Node getNode()
           
 boolean isEmpty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateNodeModel

public TemplateNodeModel(Node node,
                         RDFBackend<Node> backend)
Method Detail

getNode

public Node getNode()

get

public freemarker.template.TemplateModel get(String key)
                                      throws freemarker.template.TemplateModelException
Gets a TemplateModel from the hash.

Specified by:
get in interface freemarker.template.TemplateHashModel
Parameters:
key - the name by which the TemplateModel is identified in the template.
Returns:
the TemplateModel referred to by the key, or null if not found.
Throws:
freemarker.template.TemplateModelException

isEmpty

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

getAdaptedObject

public Object getAdaptedObject(Class hint)
Retrieves the underlying object, or some other object semantically equivalent to its value narrowed by the class hint.

Specified by:
getAdaptedObject in interface freemarker.template.AdapterTemplateModel
Parameters:
hint - the desired class of the returned value. An implementation should make reasonable effort to retrieve an object of the requested class, but if that is impossible, it must at least return the underlying object as-is. As a minimal requirement, an implementation must always return the exact underlying object when hint.isInstance(underlyingObject) == true holds. When called with java.lang.Object.class, it should return a generic Java object (i.e. if the model is wrapping a scripting lanugage object that is further wrapping a Java object, the deepest underlying Java object should be returned).
Returns:
the underlying object, or its value accommodated for the hint class.


Copyright © 2012 Salzburg Research. All Rights Reserved.