freemarker.template
Interface TemplateHashModelEx
- All Superinterfaces:
- TemplateHashModel, TemplateModel
- All Known Implementing Classes:
- AllHttpScopesHashModel, ArrayModel, BeanModel, BooleanModel, CollectionModel, DateModel, EnumerationModel, Environment.Namespace, HttpRequestHashModel, HttpRequestParametersHashModel, IteratorModel, JythonHashModel, MapModel, NumberModel, ResourceBundleModel, RhinoFunctionModel, RhinoScriptableModel, SimpleHash, SimpleMapModel, StringModel
public interface TemplateHashModelEx
- extends TemplateHashModel
An extended hash interface with a couple of extra hooks. If a class
implements this interface, then the built-in operators ?size
,
?keys
, and ?values
can be applied to its
instances in the template.
As of version 2.2.2, the engine will automatically wrap the
collections returned by keys
and values
to
present them as sequences to the template. For performance, you may
wish to return objects that implement both TemplateCollectionModel
and TemplateSequenceModel
. Note that the wrapping to sequence happens
on demand; if the template does not try to use the variable returned by
?keys
or ?values
as sequence (theKeys?size
, or theKeys[x]
,
or theKeys?sort
, etc.), just iterates over the variable
(<#list foo?keys as k>...
), then no wrapping to
sequence will happen, thus there will be no overhead.
- Version:
- $Id: TemplateHashModelEx.java,v 1.13 2003/06/08 00:58:15 herbyderby Exp $
- Author:
- Jonathan Revusky
- See Also:
SimpleHash
size
int size()
throws TemplateModelException
- Returns:
- the number of key/value mappings in the hash.
- Throws:
TemplateModelException
keys
TemplateCollectionModel keys()
throws TemplateModelException
- Returns:
- a collection containing the keys in the hash. Every element of
the returned collection must implement the
TemplateScalarModel
(as the keys of hashes are always strings).
- Throws:
TemplateModelException
values
TemplateCollectionModel values()
throws TemplateModelException
- Returns:
- a collection containing the values in the hash.
- Throws:
TemplateModelException