Interface TemplateHashModelEx
-
- All Superinterfaces:
TemplateHashModel,TemplateModel
- All Known Subinterfaces:
Scope
- All Known Implementing Classes:
AbstractScope,BaseScope,BlockScope,Configuration,Environment,IncludedTemplateNamespace,LoopContext,MacroContext,MacroInvocationBodyContext,SimpleHash,TemplateNamespace
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?valuescan be applied to its instances in the template.As of version 2.2.2, the engine will automatically wrap the collections returned by
keysandvaluesto present them as sequences to the template. For performance, you may wish to return objects that implement both TemplateCollectionModel andTemplateSequenceModel. Note that the wrapping to sequence happens on demand; if the template does not try to use the variable returned by?keysor?valuesas sequence (theKeys?size, ortheKeys[x], ortheKeys?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.- See Also:
SimpleHash
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface freemarker.template.TemplateModel
TemplateModel.InvalidExpressionModel, TemplateModel.JavaNull
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
INVALID_EXPRESSION, JAVA_NULL, NOTHING
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TemplateCollectionModelkeys()intsize()TemplateCollectionModelvalues()-
Methods inherited from interface freemarker.template.TemplateHashModel
get, isEmpty
-
-
-
-
Method Detail
-
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
-
-