Package freemarker.ext.rhino
Class RhinoWrapper
- java.lang.Object
-
- freemarker.ext.beans.BeansWrapper
-
- freemarker.ext.rhino.RhinoWrapper
-
- All Implemented Interfaces:
ObjectWrapper
,ObjectWrapperAndUnwrapper
,ObjectWrapperWithAPISupport
,RichObjectWrapper
,WriteProtectable
public class RhinoWrapper extends BeansWrapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class freemarker.ext.beans.BeansWrapper
BeansWrapper.MethodAppearanceDecision, BeansWrapper.MethodAppearanceDecisionInput
-
-
Field Summary
-
Fields inherited from class freemarker.ext.beans.BeansWrapper
EXPOSE_ALL, EXPOSE_NOTHING, EXPOSE_PROPERTIES_ONLY, EXPOSE_SAFE
-
Fields inherited from interface freemarker.template.ObjectWrapper
BEANS_WRAPPER, DEFAULT_WRAPPER, SIMPLE_WRAPPER
-
Fields inherited from interface freemarker.template.ObjectWrapperAndUnwrapper
CANT_UNWRAP_TO_TARGET_CLASS
-
-
Constructor Summary
Constructors Constructor Description RhinoWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ModelFactory
getModelFactory(Class clazz)
TemplateModel
wrap(Object obj)
Wraps the object with a template model that is most specific for the object's class.-
Methods inherited from class freemarker.ext.beans.BeansWrapper
checkModifiable, clearClassIntrospecitonCache, coerceBigDecimal, coerceBigDecimals, coerceBigDecimals, finalizeConstruction, finetuneMethodAppearance, getDefaultDateType, getDefaultInstance, getEnumModels, getExposureLevel, getIncompatibleImprovements, getInstance, getMethodAppearanceFineTuner, getOuterIdentity, getStaticModels, getUseCache, isClassIntrospectionCacheRestricted, isExposeFields, isSimpleMapWrapper, isStrict, isWriteProtected, newInstance, normalizeIncompatibleImprovementsVersion, removeFromClassIntrospectionCache, setDefaultDateType, setExposeFields, setExposureLevel, setMethodAppearanceFineTuner, setMethodsShadowItems, setNullModel, setOuterIdentity, setSimpleMapWrapper, setStrict, setUseCache, toPropertiesString, toString, tryUnwrapTo, unwrap, unwrap, wrap, wrapAsAPI, writeProtect
-
-
-
-
Method Detail
-
wrap
public TemplateModel wrap(Object obj) throws TemplateModelException
Description copied from class:BeansWrapper
Wraps the object with a template model that is most specific for the object's class. Specifically:- if the object is null, returns the
null model
, - if the object is a Number returns a
NumberModel
for it, - if the object is a Date returns a
DateModel
for it, - if the object is a Boolean returns
TemplateBooleanModel.TRUE
orTemplateBooleanModel.FALSE
- if the object is already a TemplateModel, returns it unchanged,
- if the object is an array, returns a
ArrayModel
for it - if the object is a Map, returns a
MapModel
for it - if the object is a Collection, returns a
CollectionModel
for it - if the object is an Iterator, returns a
IteratorModel
for it - if the object is an Enumeration, returns a
EnumerationModel
for it - if the object is a String, returns a
StringModel
for it - otherwise, returns a generic
StringModel
for it.
- Specified by:
wrap
in interfaceObjectWrapper
- Overrides:
wrap
in classBeansWrapper
- Parameters:
obj
- The object to wrap into aTemplateModel
. If it already implementsTemplateModel
, it should just return the object as is. If it'snull
, the method should returnnull
(however,BeansWrapper
, has a legacy option for returning a null model object instead, but it's not a good idea).- Returns:
- a
TemplateModel
wrapper of the object passed in. To support un-wrapping, you may consider the return value to implementWrapperTemplateModel
andAdapterTemplateModel
. The default expectation is that theTemplateModel
isn't less thread safe than the wrapped object. If theObjectWrapper
returns less thread safe objects, that should be clearly documented, as it restricts how it can be used, like, then it can't be used to wrap "shared variables" (Configuration.setSharedVaribles(Map)
). - Throws:
TemplateModelException
- if the object is null, returns the
-
getModelFactory
protected ModelFactory getModelFactory(Class clazz)
- Overrides:
getModelFactory
in classBeansWrapper
-
-