Package freemarker.template
Class WrappingTemplateModel
java.lang.Object
freemarker.template.WrappingTemplateModel
- Direct Known Subclasses:
DefaultArrayAdapter
,DefaultEnumerationAdapter
,DefaultIterableAdapter
,DefaultIteratorAdapter
,DefaultListAdapter
,DefaultMapAdapter
,DefaultNonListCollectionAdapter
,SimpleCollection
,SimpleHash
,SimpleMapModel
,SimpleSequence
Convenience base-class for containers that wrap their contained arbitrary Java objects into
TemplateModel
instances.-
Constructor Summary
ModifierConstructorDescriptionprotected
Deprecated.protected
WrappingTemplateModel(ObjectWrapper objectWrapper)
Protected constructor that creates a new wrapping template model using the specified object wrapper. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectWrapper
Deprecated.Don't depend on this object, as it can be replace by anybody in the same JVM.Returns the object wrapper instance used by this wrapping template model.static void
setDefaultObjectWrapper(ObjectWrapper objectWrapper)
Deprecated.This method has VM-wide effect, which makes it unsuitable for application where multiple components might use FreeMarker internally.void
setObjectWrapper(ObjectWrapper objectWrapper)
protected TemplateModel
Wraps the passed object into a template model using this object's object wrapper.
-
Constructor Details
-
WrappingTemplateModel
Deprecated.UseWrappingTemplateModel(ObjectWrapper)
instead; this method uses the deprecated.Protected constructor that creates a new wrapping template model using the default object wrapper. -
WrappingTemplateModel
Protected constructor that creates a new wrapping template model using the specified object wrapper.- Parameters:
objectWrapper
- the wrapper to use. Passingnull
to it is allowed but deprecated. Ifnull
is passed, the deprecated default object wrapper is used.
-
-
Method Details
-
setDefaultObjectWrapper
Deprecated.This method has VM-wide effect, which makes it unsuitable for application where multiple components might use FreeMarker internally.Sets the default object wrapper that is used when a wrapping template model is constructed without being passed an explicit object wrapper. The default value isObjectWrapper.SIMPLE_WRAPPER
. Note thatConfiguration.setSharedVariable(String, Object)
andTemplate.process(Object, java.io.Writer)
don't use this setting, they rather use whatever object wrapper theirConfigurable.getObjectWrapper()
method returns. -
getDefaultObjectWrapper
Deprecated.Don't depend on this object, as it can be replace by anybody in the same JVM.Returns the default object wrapper that is used when a wrapping template model is constructed without being passed an explicit object wrapper. Note thatConfiguration.setSharedVariable(String, Object)
andTemplate.process(Object, java.io.Writer)
don't use this setting, they rather use whatever object wrapper theirConfigurable.getObjectWrapper()
method returns. -
getObjectWrapper
Returns the object wrapper instance used by this wrapping template model. -
setObjectWrapper
-
wrap
Wraps the passed object into a template model using this object's object wrapper.- Parameters:
obj
- the object to wrap- Returns:
- the template model that wraps the object
- Throws:
TemplateModelException
- if the wrapper does not know how to wrap the passed object.
-
WrappingTemplateModel(ObjectWrapper)
instead; this method uses the deprecated.