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 ModelFactorygetModelFactory(Class clazz)TemplateModelwrap(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:BeansWrapperWraps 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
NumberModelfor it, - if the object is a Date returns a
DateModelfor it, - if the object is a Boolean returns
TemplateBooleanModel.TRUEorTemplateBooleanModel.FALSE - if the object is already a TemplateModel, returns it unchanged,
- if the object is an array, returns a
ArrayModelfor it - if the object is a Map, returns a
MapModelfor it - if the object is a Collection, returns a
CollectionModelfor it - if the object is an Iterator, returns a
IteratorModelfor it - if the object is an Enumeration, returns a
EnumerationModelfor it - if the object is a String, returns a
StringModelfor it - otherwise, returns a generic
StringModelfor it.
- Specified by:
wrapin interfaceObjectWrapper- Overrides:
wrapin 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
TemplateModelwrapper of the object passed in. To support un-wrapping, you may consider the return value to implementWrapperTemplateModelandAdapterTemplateModel. The default expectation is that theTemplateModelisn't less thread safe than the wrapped object. If theObjectWrapperreturns 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:
getModelFactoryin classBeansWrapper
-
-