freemarker.ext.beans2
Class EnumWrapper<T extends java.lang.Enum>

java.lang.Object
  extended by freemarker.ext.beans2.BeanWrapper<T>
      extended by freemarker.ext.beans2.EnumWrapper<T>
All Implemented Interfaces:
ObjectWrapper, TemplateHashModel, TemplateListModel2, TemplateModel, TemplateObjectModel, TemplateScalarModel, TemplateWriteableHashModel, java.io.Serializable, java.lang.Cloneable

public class EnumWrapper<T extends java.lang.Enum>
extends BeanWrapper<T>
implements TemplateListModel2, java.io.Serializable

Wraps an Enum object. Subclasses BeanWrapper to provide an Iterator model for all values of the enum.

Since:
1.9
Version:
$Id: EnumWrapper.java 1067 2011-06-06 10:55:28Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Field Summary
 
Fields inherited from class freemarker.ext.beans2.BeanWrapper
emptyParams, object
 
Constructor Summary
EnumWrapper()
          Default constructor where an object is not provided initially.
EnumWrapper(T t)
          Constructor that takes an enum object to be wrapped.
 
Method Summary
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over the elements of the enum.
 
Methods inherited from class freemarker.ext.beans2.BeanWrapper
clone, get, getAsObject, getAsString, isEmpty, put, setObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Constructor Detail

EnumWrapper

public EnumWrapper()
Default constructor where an object is not provided initially. This allows the wrapper to be used as a prototype.


EnumWrapper

public EnumWrapper(T t)
Constructor that takes an enum object to be wrapped.

Parameters:
t - the enum object to be wrapped
Method Detail

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over the elements of the enum.

Specified by:
templateIterator in interface TemplateListModel2
Returns:
an iterator to iterate over the current enum elements
Throws:
TemplateModelException - the next item in the list can't be retrieved, or no next item exists.

releaseIterator

public void releaseIterator(TemplateIteratorModel iterator)

Returns the used iterator to the list model.

Specified by:
releaseIterator in interface TemplateListModel2
Parameters:
iterator - the iterator to be returned