freemarker.template

## Class WrappingTemplateModel

- java.lang.Object
- - freemarker.template.WrappingTemplateModel

Direct Known Subclasses:
  DefaultArrayAdapter, DefaultIterableAdapter, DefaultIteratorAdapter, DefaultListAdapter, DefaultMapAdapter, DefaultNonListCollectionAdapter, SimpleCollection, SimpleHash, SimpleMapModel, SimpleSequence

    public abstract class WrappingTemplateModel
    extends Object

Convenience base-class for containers that wrap their contained arbitrary Java objects into `TemplateModel` instances.

### Constructor Summary

Constructors
`protected` `WrappingTemplateModel()` Deprecated. Use `WrappingTemplateModel(ObjectWrapper)` instead; this method uses the deprecated.
`protected` `WrappingTemplateModel(ObjectWrapper objectWrapper)` Protected constructor that creates a new wrapping template model using the specified object wrapper.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`static ObjectWrapper` `getDefaultObjectWrapper()` Deprecated. Don't depend on this object, as it can be replace by anybody in the same JVM.
`ObjectWrapper` `getObjectWrapper()` 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` `wrap(Object obj)` Wraps the passed object into a template model using this object's object wrapper.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### WrappingTemplateModel

    @Deprecated
    protected WrappingTemplateModel()

Deprecated. Use `WrappingTemplateModel(ObjectWrapper)` instead; this method uses the deprecated.
Protected constructor that creates a new wrapping template model using the default object wrapper.

#### WrappingTemplateModel

    protected WrappingTemplateModel(ObjectWrapper objectWrapper)

Protected constructor that creates a new wrapping template model using the specified object wrapper.

Parameters:
  `objectWrapper` - the wrapper to use. Passing `null` to it is allowed but deprecated. If `null` is passed, the deprecated default object wrapper is used.

### Method Detail

#### setDefaultObjectWrapper

    @Deprecated
    public 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.
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 is `ObjectWrapper.SIMPLE_WRAPPER`. Note that `Configuration.setSharedVariable(String, Object)` and `Template.process(Object, java.io.Writer)` don't use this setting, they rather use whatever object wrapper their `Configurable.getObjectWrapper()` method returns.

#### getDefaultObjectWrapper

    @Deprecated
    public static ObjectWrapper 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 that `Configuration.setSharedVariable(String, Object)` and `Template.process(Object, java.io.Writer)` don't use this setting, they rather use whatever object wrapper their `Configurable.getObjectWrapper()` method returns.

#### getObjectWrapper

    public ObjectWrapper getObjectWrapper()

Returns the object wrapper instance used by this wrapping template model.

#### setObjectWrapper

    public void setObjectWrapper(ObjectWrapper objectWrapper)

#### wrap

    protected final TemplateModel wrap(Object obj)
                                throws TemplateModelException

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.