freemarker.ext.beans2
Class EnumerationMethodWrapper

java.lang.Object
  extended by freemarker.ext.beans2.EnumerationMethodWrapper
All Implemented Interfaces:
TemplateListModel2, TemplateModel

public class EnumerationMethodWrapper
extends java.lang.Object
implements TemplateListModel2

Wraps a method that returns an enumeration. The enumeration is then wrapped in an EnumerationWrapper.

Since:
1.9
Version:
$Id: EnumerationMethodWrapper.java 1067 2011-06-06 10:55:28Z run2000 $
Author:
Nicholas Cull

Constructor Summary
EnumerationMethodWrapper()
          Default constructor where an enumeration method is not provided initially.
EnumerationMethodWrapper(java.lang.reflect.Method method, java.lang.Object[] paramValues)
          Constructor that takes a method and object parameters to be provided to the method call.
EnumerationMethodWrapper(java.lang.reflect.Method method, java.lang.Object[] paramValues, java.lang.Object object)
          Constructor that takes a method, the object target for the method, and object parameters to be provided to the method call.
 
Method Summary
 boolean isEmpty()
          Is the object empty?
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 void setMethod(java.lang.reflect.Method method)
          Sets the method to be called by this enumeration method wrapper.
 void setObject(java.lang.Object object)
          Sets the object target for the method to be called.
 void setParamValues(java.lang.Object[] paramValues)
          Sets the object values to be passed as parameters to the method call.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerationMethodWrapper

public EnumerationMethodWrapper()
Default constructor where an enumeration method is not provided initially.


EnumerationMethodWrapper

public EnumerationMethodWrapper(java.lang.reflect.Method method,
                                java.lang.Object[] paramValues)
Constructor that takes a method and object parameters to be provided to the method call.

Parameters:
method - the Method to be called
paramValues - parameters to be supplied to the method

EnumerationMethodWrapper

public EnumerationMethodWrapper(java.lang.reflect.Method method,
                                java.lang.Object[] paramValues,
                                java.lang.Object object)
Constructor that takes a method, the object target for the method, and object parameters to be provided to the method call.

Parameters:
method - the Method to be called
paramValues - parameters to be supplied to the method
object - the object that is the target of the method
Method Detail

setObject

public void setObject(java.lang.Object object)
Sets the object target for the method to be called.

Parameters:
object - the object target for the method

setMethod

public void setMethod(java.lang.reflect.Method method)
Sets the method to be called by this enumeration method wrapper.

Parameters:
method - the method to be called

setParamValues

public void setParamValues(java.lang.Object[] paramValues)
Sets the object values to be passed as parameters to the method call.

Parameters:
paramValues - the values to be passed to the method

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Description copied from interface: TemplateModel
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
true if this object is empty, otherwise false
Throws:
TemplateModelException

templateIterator

public TemplateIteratorModel templateIterator()
                                       throws TemplateModelException
Retrieves an iterator to iterate over this list. Can choose to return null if there are no elements in the list.

Specified by:
templateIterator in interface TemplateListModel2
Returns:
an iterator to iterate over the current list.
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. Implement this method when you want to use an object pool of TemplateIterator objects. Otherwise, leave the implementation of this method blank.

Note that if the iterator returned in templateIterator() is null, this method will not be called for the null iterator.

Specified by:
releaseIterator in interface TemplateListModel2
Parameters:
iterator - the iterator to be returned to the object pool, if any