freemarker.ext.beans2
Class EnumerationWrapper<T extends java.util.Enumeration>

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

public class EnumerationWrapper<T extends java.util.Enumeration>
extends BeanWrapper<T>
implements TemplateIteratorModel, java.io.Serializable

Wraps an Enumeration object as an Iterator model. Also provides support for any additional methods provided by the enumeration.

Since:
1.9
Version:
$Id: EnumerationWrapper.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
EnumerationWrapper()
          Default constructor where an object is not provided initially.
EnumerationWrapper(T enumeration)
          Constructor that takes an Enumeration object to be wrapped.
 
Method Summary
 boolean hasNext()
          Do we have another item in the list?
 boolean isEmpty()
          Is the object empty?
 TemplateModel next()
          Retrieve the next item in the list.
 
Methods inherited from class freemarker.ext.beans2.BeanWrapper
clone, get, getAsObject, getAsString, put, setObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerationWrapper

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


EnumerationWrapper

public EnumerationWrapper(T enumeration)
Constructor that takes an Enumeration object to be wrapped.

Parameters:
enumeration - the enumeration object to be wrapped
Method Detail

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Overrides:
isEmpty in class BeanWrapper<T extends java.util.Enumeration>
Returns:
true if this object is empty, otherwise false
Throws:
TemplateModelException

hasNext

public boolean hasNext()
                throws TemplateModelException
Do we have another item in the list?

Specified by:
hasNext in interface TemplateIteratorModel
Returns:
true if there are more items to be iterated over, otherwise false
Throws:
TemplateModelException - there was a problem determining the next item in the list

next

public TemplateModel next()
                   throws TemplateModelException
Retrieve the next item in the list. The item will be a TemplateModel containing the underlying value.

Specified by:
next in interface TemplateIteratorModel
Returns:
the next item in the list
Throws:
TemplateModelException - the next item couldn't be retrieved, or we're at the end of the list