freemarker.ext.misc
Class LiveMapList

java.lang.Object
  extended by freemarker.ext.misc.LiveMapList
All Implemented Interfaces:
TemplateMethodModel2, TemplateModel, java.io.Serializable

public final class LiveMapList
extends java.lang.Object
implements TemplateMethodModel2, java.io.Serializable

Behaves the same way as MapList, but results are returned "live", that is, evaluated on the fly. This is useful in situations where the underlying list model may be unbounded, and a loop over such a list is terminated by a break or return statement.

The method model supplied to the LiveMapList call should be idempotent, otherwise unexpected results may appear when re-evaluating list elements. For MapList, this is not such a problem, as long as the side effects are predictable over the contents of the underlying list.

Since:
1.9
Version:
$Id: LiveMapList.java 1090 2013-03-29 11:04:07Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Method Summary
 TemplateModel exec(java.util.List<TemplateModel> arguments)
          Executes a method call.
static LiveMapList getInstance()
          Retrieve a singleton instance of this class.
 boolean isEmpty()
          Is the object empty?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LiveMapList getInstance()
Retrieve a singleton instance of this class. Since there is no state information held between calls, there is only a need for one instance.

Returns:
an instance of this MapList class

isEmpty

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

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

exec

public TemplateModel exec(java.util.List<TemplateModel> arguments)
                   throws TemplateModelException
Executes a method call. Arguments are passed as a List of TemplateModel objects.

Specified by:
exec in interface TemplateMethodModel2
Parameters:
arguments - a List of TemplateModel objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException