public interface ObjectWrapper
TemplateModelinterfaces). Thus this is what decides what parts of the Java objects will be accessible in the templates and how.
For example, with a
BeansWrapper both the items of
Map and the JavaBean properties (the getters)
of an object are accessible in template uniformly with the
myObject.foo syntax, where "foo" is the map key or
the property name. This is because both kind of object is wrapped by
BeansWrapper into a
TemplateHashModel implementation that will call
Map.get(Object) or the getter method, transparently
to the template language.
|Modifier and Type||Field and Description|
The default object wrapper implementation, focusing on backward compatibility and out-of-the box extra features.
Object wrapper that uses
static final ObjectWrapper BEANS_WRAPPER
ObjectWrapperthat exposes the object methods and JavaBeans properties as hash elements, and has custom handling for Java
ResourceBundle-s, etc. It doesn't treat
Node-s and Jython objects specially, however.
static final ObjectWrapper DEFAULT_WRAPPER
BeansWrapperwith the special handling of
Node-s (for XML processing) and Jython objects. However, for backward compatibility, it also somewhat downgrades
List-s and collections/arrays. Furthermore it uses
Number-s, although this is not considered to be harmful.
static final ObjectWrapper SIMPLE_WRAPPER
SimpleXXXwrappers only. It behaves like the
DEFAULT_WRAPPER, but for objects that it does not know how to wrap as a
SimpleXXXit throws an exception. It makes no use of reflection-based exposure of anything, which may makes it a good candidate for security-restricted applications.
TemplateModel wrap(java.lang.Object obj) throws TemplateModelException
TemplateModelout of a non-
TemplateModelobject, usually by "wrapping" it into a
TemplateModelimplementation that delegates to the original object.
obj- The object to wrap into a
TemplateModel. If the it already implements
TemplateModel, it should just return the object as is.
TemplateModelwrapper of the object passed in. To support un-wrapping, you may consider the return value to implement