Package freemarker.template
Class SimpleObjectWrapper
- java.lang.Object
-
- freemarker.ext.beans.BeansWrapper
-
- freemarker.template.DefaultObjectWrapper
-
- freemarker.template.SimpleObjectWrapper
-
- All Implemented Interfaces:
ObjectWrapper
,ObjectWrapperAndUnwrapper
,ObjectWrapperWithAPISupport
,RichObjectWrapper
,WriteProtectable
public class SimpleObjectWrapper extends DefaultObjectWrapper
A restricted object wrapper that will not expose arbitrary object, just those that directly correspond to theTemplateModel
sub-interfaces (String
,Map
and such). If it had to wrap other kind of objects, it will throw exception. It will also block?api
calls on the values it wraps.
-
-
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 SimpleObjectWrapper()
Deprecated.UseSimpleObjectWrapper(Version)
instead.SimpleObjectWrapper(Version incompatibleImprovements)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TemplateModel
handleUnknownType(Object obj)
Called if a type other than the simple ones we know about is passed in.TemplateHashModel
wrapAsAPI(Object obj)
Wraps an object to aTemplateModel
that exposes the object's "native" (usually, Java) API.-
Methods inherited from class freemarker.template.DefaultObjectWrapper
convertArray, getForceLegacyNonListCollections, getUseAdaptersForContainers, normalizeIncompatibleImprovementsVersion, setForceLegacyNonListCollections, setUseAdaptersForContainers, toPropertiesString, wrap, wrapDomNode
-
Methods inherited from class freemarker.ext.beans.BeansWrapper
checkModifiable, clearClassIntrospecitonCache, coerceBigDecimal, coerceBigDecimals, coerceBigDecimals, finalizeConstruction, finetuneMethodAppearance, getDefaultDateType, getDefaultInstance, getEnumModels, getExposureLevel, getIncompatibleImprovements, getInstance, getMethodAppearanceFineTuner, getModelFactory, getOuterIdentity, getStaticModels, getUseCache, isClassIntrospectionCacheRestricted, isExposeFields, isSimpleMapWrapper, isStrict, isWriteProtected, newInstance, removeFromClassIntrospectionCache, setDefaultDateType, setExposeFields, setExposureLevel, setMethodAppearanceFineTuner, setMethodsShadowItems, setNullModel, setOuterIdentity, setSimpleMapWrapper, setStrict, setUseCache, toString, tryUnwrapTo, unwrap, unwrap, wrap, writeProtect
-
-
-
-
Constructor Detail
-
SimpleObjectWrapper
public SimpleObjectWrapper()
Deprecated.UseSimpleObjectWrapper(Version)
instead.
-
SimpleObjectWrapper
public SimpleObjectWrapper(Version incompatibleImprovements)
- Parameters:
incompatibleImprovements
- see inBeansWrapper(Version)
.- Since:
- 2.3.21
-
-
Method Detail
-
handleUnknownType
protected TemplateModel handleUnknownType(Object obj) throws TemplateModelException
Called if a type other than the simple ones we know about is passed in. In this implementation, this just throws an exception.- Overrides:
handleUnknownType
in classDefaultObjectWrapper
- Throws:
TemplateModelException
-
wrapAsAPI
public TemplateHashModel wrapAsAPI(Object obj) throws TemplateModelException
Description copied from interface:ObjectWrapperWithAPISupport
Wraps an object to aTemplateModel
that exposes the object's "native" (usually, Java) API.- Specified by:
wrapAsAPI
in interfaceObjectWrapperWithAPISupport
- Overrides:
wrapAsAPI
in classBeansWrapper
- Parameters:
obj
- The object for which the API model has to be returned. Shouldn't benull
.- Returns:
- The
TemplateModel
through which the API of the object can be accessed. Can't benull
. - Throws:
TemplateModelException
-
-