freemarker.ext.beans2
Class PropertiesWrapper<T extends java.util.Properties>

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

public class PropertiesWrapper<T extends java.util.Properties>
extends BeanWrapper<T>
implements TemplateMethodModel, TemplateListModel2, java.io.Serializable

Wrapper for a Properties object. Distinct from a Map wrapper because we can assume all keys and values are String objects.

Since:
1.9
Version:
$Id: PropertiesWrapper.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
PropertiesWrapper()
          Default constructor where an object is not provided initially.
PropertiesWrapper(T object)
          Constructor that takes a Properties object to be wrapped.
 
Method Summary
 TemplateModel exec(java.util.List<java.lang.String> arguments)
          Executes a method call.
 void releaseIterator(TemplateIteratorModel iterator)
          Returns the used iterator to the list model.
 TemplateIteratorModel templateIterator()
          Retrieves an iterator to iterate over this Properties object.
 
Methods inherited from class freemarker.ext.beans2.BeanWrapper
clone, get, getAsObject, getAsString, isEmpty, put, setObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface freemarker.template.TemplateModel
isEmpty
 

Constructor Detail

PropertiesWrapper

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


PropertiesWrapper

public PropertiesWrapper(T object)
Constructor that takes a Properties object to be wrapped.

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

exec

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

Specified by:
exec in interface TemplateMethodModel
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

templateIterator

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

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