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
-
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected ModelFactory
getModelFactory(Class clazz)
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, clearClassIntrospectionCache, coerceBigDecimal, coerceBigDecimals, coerceBigDecimals, finalizeConstruction, finetuneMethodAppearance, getDefaultDateType, getDefaultInstance, getDefaultZeroArgumentNonVoidMethodPolicy, getEnumModels, getExposureLevel, getIncompatibleImprovements, getInstance, getMemberAccessPolicy, getMethodAppearanceFineTuner, getOuterIdentity, getPreferIndexedReadMethod, getRecordZeroArgumentNonVoidMethodPolicy, getStaticModels, getTreatDefaultMethodsAsBeanMembers, getUseCache, invokeMethod, isClassIntrospectionCacheRestricted, isExposeFields, isSimpleMapWrapper, isStrict, isWriteProtected, newInstance, normalizeIncompatibleImprovementsVersion, readField, removeFromClassIntrospectionCache, setDefaultDateType, setDefaultZeroArgumentNonVoidMethodPolicy, setExposeFields, setExposureLevel, setMemberAccessPolicy, setMethodAppearanceFineTuner, setMethodsShadowItems, setNullModel, setOuterIdentity, setPreferIndexedReadMethod, setRecordZeroArgumentNonVoidMethodPolicy, setSimpleMapWrapper, setStrict, setTreatDefaultMethodsAsBeanMembers, setUseCache, toPropertiesString, toString, tryUnwrapTo, unwrap, unwrap, wrap, wrapAsAPI, writeProtect
-
Constructor Details
-
RhinoWrapper
public RhinoWrapper()
-
-
Method Details
-
wrap
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
GenericObjectModel
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
- Overrides:
getModelFactory
in classBeansWrapper
-