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

java.lang.Object
  extended by freemarker.ext.beans2.StaticClassWrapper<T>
      extended by freemarker.ext.beans2.StaticEnumWrapper<T>
All Implemented Interfaces:
TemplateHashModel, TemplateListModel2, TemplateModel, TemplateScalarModel, TemplateWriteableHashModel, java.io.Serializable

public class StaticEnumWrapper<T extends java.lang.Enum>
extends StaticClassWrapper<T>
implements TemplateListModel2

Wraps a static Enum class. Subclasses StaticClassWrapper to provide an Iterator model for all values of the enum.

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

Field Summary
 
Fields inherited from class freemarker.ext.beans2.StaticClassWrapper
clazz
 
Constructor Summary
StaticEnumWrapper()
          Default constructor where a class is not provided initially.
StaticEnumWrapper(java.lang.Class<T> clazz)
          Constructor that takes am enum to be wrapped.
 
Method Summary
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the enumeration.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this enumeration.
 
Methods inherited from class freemarker.ext.beans2.StaticClassWrapper
get, getAsString, isEmpty, put, setClazz
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Constructor Detail

StaticEnumWrapper

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


StaticEnumWrapper

public StaticEnumWrapper(java.lang.Class<T> clazz)
Constructor that takes am enum to be wrapped.

Parameters:
clazz - the enum class to be wrapped
Method Detail

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over this enumeration.

Specified by:
templateIterator in interface TemplateListModel2
Returns:
an iterator to iterate over the current enumeration.
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 enumeration.

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