|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.ext.beans.BeanModel
freemarker.ext.beans.EnumerationModel
public class EnumerationModel
A class that adds TemplateModelIterator
functionality to the
Enumeration
interface implementers.
Using the model as a collection model is NOT thread-safe, as
enumerations are inherently not thread-safe.
Further, you can iterate over it only once. Attempts to call the
iterator()
method after it was already driven to the end once will
throw an exception.
Field Summary |
---|
Fields inherited from class freemarker.ext.beans.BeanModel |
---|
object, wrapper |
Fields inherited from interface freemarker.template.TemplateModel |
---|
NOTHING |
Constructor Summary | |
---|---|
EnumerationModel(java.util.Enumeration enumeration,
BeansWrapper wrapper)
Creates a new model that wraps the specified enumeration object. |
Method Summary | |
---|---|
boolean |
getAsBoolean()
Returns Enumeration.hasMoreElements() . |
boolean |
hasNext()
Calls underlying Enumeration.nextElement() . |
TemplateModelIterator |
iterator()
This allows the enumeration to be used in a <foreach> block. |
TemplateModel |
next()
Calls underlying Enumeration.nextElement() and wraps the result. |
Methods inherited from class freemarker.ext.beans.BeanModel |
---|
get, getAdaptedObject, getWrappedObject, hasPlainGetMethod, invokeGenericGet, isEmpty, keys, keySet, size, toString, unwrap, values, wrap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EnumerationModel(java.util.Enumeration enumeration, BeansWrapper wrapper)
enumeration
- the enumeration object to wrap into a model.wrapper
- the BeansWrapper
associated with this model.
Every model has to have an associated BeansWrapper
instance. The
model gains many attributes from its wrapper, including the caching
behavior, method exposure level, method-over-item shadowing policy etc.Method Detail |
---|
public TemplateModelIterator iterator() throws TemplateModelException
iterator
in interface TemplateCollectionModel
TemplateModelException
public boolean hasNext()
Enumeration.nextElement()
.
hasNext
in interface TemplateModelIterator
public TemplateModel next() throws TemplateModelException
Enumeration.nextElement()
and wraps the result.
next
in interface TemplateModelIterator
TemplateModelException
- if the next model can not be retrieved
(i.e. because the iterator is exhausted).public boolean getAsBoolean()
Enumeration.hasMoreElements()
. Therefore, an
enumeration that has no more element evaluates to false, and an
enumeration that has further elements evaluates to true.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |