org.joda.beans.integrate.freemarker
Class FreemarkerTemplateModel

java.lang.Object
  extended by freemarker.template.WrappingTemplateModel
      extended by org.joda.beans.integrate.freemarker.FreemarkerTemplateModel
All Implemented Interfaces:
freemarker.template.AdapterTemplateModel, freemarker.template.TemplateHashModel, freemarker.template.TemplateHashModelEx, freemarker.template.TemplateModel

public class FreemarkerTemplateModel
extends freemarker.template.WrappingTemplateModel
implements freemarker.template.TemplateHashModelEx, freemarker.template.AdapterTemplateModel

Template model converting a Joda-Bean to a Freemarker model.

Although this class is public, it should not normally be use directly. Follow the instructions in FreemarkerObjectWrapper to use this class.


Field Summary
 
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
 
Constructor Summary
FreemarkerTemplateModel(Bean bean, FreemarkerObjectWrapper wrapper)
          Creates an instance of the model.
 
Method Summary
 freemarker.template.TemplateModel get(String key)
          Gets the value for the specified key, wrapping the result in another model.
 Object getAdaptedObject(Class hint)
          Unwraps the model, returning the bean.
 boolean isEmpty()
          Checks if there are no properties.
 freemarker.template.TemplateCollectionModel keys()
          Gets the full set of property names, allowing the bean to be accessed as a sequence.
 int size()
          Gets the number of properties.
 freemarker.template.TemplateCollectionModel values()
          Gets the full set of property values, allowing the bean to be accessed as a sequence.
 
Methods inherited from class freemarker.template.WrappingTemplateModel
getDefaultObjectWrapper, getObjectWrapper, setDefaultObjectWrapper, setObjectWrapper, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreemarkerTemplateModel

public FreemarkerTemplateModel(Bean bean,
                               FreemarkerObjectWrapper wrapper)
Creates an instance of the model.

Parameters:
bean - the bean being wrapped, not null
wrapper - the default wrapper for further wrapping, not null
Method Detail

get

public freemarker.template.TemplateModel get(String key)
                                      throws freemarker.template.TemplateModelException
Gets the value for the specified key, wrapping the result in another model.

Specified by:
get in interface freemarker.template.TemplateHashModel
Parameters:
key - the property name, not null
Returns:
the model, null if not found
Throws:
freemarker.template.TemplateModelException

isEmpty

public boolean isEmpty()
Checks if there are no properties.

Specified by:
isEmpty in interface freemarker.template.TemplateHashModel
Returns:
true if no properties

size

public int size()
Gets the number of properties.

Specified by:
size in interface freemarker.template.TemplateHashModelEx
Returns:
the number of properties

keys

public freemarker.template.TemplateCollectionModel keys()
Gets the full set of property names, allowing the bean to be accessed as a sequence.

Specified by:
keys in interface freemarker.template.TemplateHashModelEx
Returns:
the property names, not null

values

public freemarker.template.TemplateCollectionModel values()
Gets the full set of property values, allowing the bean to be accessed as a sequence.

Specified by:
values in interface freemarker.template.TemplateHashModelEx
Returns:
the wrapped property values, not null

getAdaptedObject

public Object getAdaptedObject(Class hint)
Unwraps the model, returning the bean.

Specified by:
getAdaptedObject in interface freemarker.template.AdapterTemplateModel
Parameters:
hint - the class hint
Returns:
the underlying bean, not null


Copyright © 2007–2013 Joda.org. All rights reserved.