Interface TemplateModel
-
- All Known Subinterfaces:
AdapterTemplateModel
,TemplateBooleanModel
,TemplateCollectionModel
,TemplateCollectionModelEx
,TemplateDateModel
,TemplateDirectiveModel
,TemplateHashModel
,TemplateHashModelEx
,TemplateMethodModel
,TemplateMethodModelEx
,TemplateModelWithAPISupport
,TemplateNodeModel
,TemplateNumberModel
,TemplateScalarModel
,TemplateSequenceModel
,TemplateTransformModel
,WrapperTemplateModel
- All Known Implementing Classes:
AllHttpScopesHashModel
,ArrayModel
,BeanModel
,BooleanModel
,CaptureOutput
,CollectionModel
,DateModel
,DefaultArrayAdapter
,DefaultIteratorAdapter
,DefaultListAdapter
,DefaultMapAdapter
,DefaultNonListCollectionAdapter
,DOMNodeModel
,EnumerationModel
,Environment.Namespace
,Execute
,HtmlEscape
,HttpRequestHashModel
,HttpRequestParametersHashModel
,HttpSessionHashModel
,IncludePage
,IteratorModel
,JythonHashModel
,JythonModel
,JythonNumberModel
,JythonRuntime
,JythonSequenceModel
,LocalizedString
,MapModel
,NodeListModel
,NodeListModel
,NodeModel
,NormalizeNewlines
,NumberModel
,ObjectConstructor
,OverloadedMethodsModel
,ResourceBundleLocalizedString
,ResourceBundleModel
,RhinoFunctionModel
,RhinoScriptableModel
,ServletContextHashModel
,SimpleCollection
,SimpleDate
,SimpleHash
,SimpleList
,SimpleMapModel
,SimpleMethodModel
,SimpleNumber
,SimpleScalar
,SimpleSequence
,StandardCompress
,StringModel
,TaglibFactory
,TemplateModelListSequence
,XmlEscape
public interface TemplateModel
The common super-interface of the interfaces that stand for the FreeMarker Template Language (FTL) data types. The template language only deals withTemplateModel
-s, not directly with plain Java objects. (For example, it doesn't understandNumber
, butTemplateNumberModel
.) This is why the data-model (aka. the "template context" in other languages) is (automatically) mapped to a tree ofTemplateModel
-s.Mapping the plain Java objects to
TemplateModel
-s (or the other way around sometimes) is the responsibility of theObjectWrapper
(can be set viaConfiguration.setObjectWrapper(ObjectWrapper)
). But not allTemplateModel
-s are for wrapping a plain object. For example, a value created within a template is not made to wrap an earlier existing object; it's a value that has always existed in the template language's domain. Users can also writeTemplateModel
implementations and put them directly into the data-model for full control over how that object is seen from the template. CertainTemplateModel
interfaces doesn't even have equivalent in Java. For example the directive type (TemplateDirectiveModel
) is like that.Because
TemplateModel
"subclasses" are all interfaces, a value in the template language can have multiple types. However, to prevent ambiguous situations, it's not recommended to make values that implement more than one of these types: string, number, boolean, date. The intended applications are like string+hash, string+method, hash+sequence, etc.
-
-
Field Summary
Fields Modifier and Type Field Description static TemplateModel
NOTHING
A general-purpose object to represent nothing.
-
-
-
Field Detail
-
NOTHING
static final TemplateModel NOTHING
A general-purpose object to represent nothing. It acts as an empty string, false, empty sequence, empty hash, and null-returning method model.
-
-