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 theTemplateModelsub-interfaces (String,Mapand such). If it had to wrap other kind of objects, it will throw exception. It will also block?apicalls 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 TemplateModelhandleUnknownType(java.lang.Object obj)Called if a type other than the simple ones we know about is passed in.TemplateHashModelwrapAsAPI(java.lang.Object obj)Wraps an object to aTemplateModelthat exposes the object's "native" (usually, Java) API.-
Methods inherited from class freemarker.template.DefaultObjectWrapper
convertArray, getDOMNodeSupport, getForceLegacyNonListCollections, getIterableSupport, getJythonSupport, getUseAdaptersForContainers, normalizeIncompatibleImprovementsVersion, setDOMNodeSupport, setForceLegacyNonListCollections, setIterableSupport, setJythonSupport, setUseAdaptersForContainers, toPropertiesString, wrap, wrapDomNode
-
Methods inherited from class freemarker.ext.beans.BeansWrapper
checkModifiable, clearClassIntrospecitonCache, clearClassIntrospectionCache, coerceBigDecimal, coerceBigDecimals, coerceBigDecimals, finalizeConstruction, finetuneMethodAppearance, getDefaultDateType, getDefaultInstance, getEnumModels, getExposureLevel, getIncompatibleImprovements, getInstance, getMemberAccessPolicy, getMethodAppearanceFineTuner, getModelFactory, getOuterIdentity, getPreferIndexedReadMethod, getStaticModels, getTreatDefaultMethodsAsBeanMembers, getUseCache, invokeMethod, isClassIntrospectionCacheRestricted, isExposeFields, isSimpleMapWrapper, isStrict, isWriteProtected, newInstance, readField, removeFromClassIntrospectionCache, setDefaultDateType, setExposeFields, setExposureLevel, setMemberAccessPolicy, setMethodAppearanceFineTuner, setMethodsShadowItems, setNullModel, setOuterIdentity, setPreferIndexedReadMethod, setSimpleMapWrapper, setStrict, setTreatDefaultMethodsAsBeanMembers, setUseCache, toString, tryUnwrapTo, unwrap, unwrap, wrap, writeProtect
-
-
-
-
Constructor Detail
-
SimpleObjectWrapper
@Deprecated 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(java.lang.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:
handleUnknownTypein classDefaultObjectWrapper- Throws:
TemplateModelException
-
wrapAsAPI
public TemplateHashModel wrapAsAPI(java.lang.Object obj) throws TemplateModelException
Description copied from interface:ObjectWrapperWithAPISupportWraps an object to aTemplateModelthat exposes the object's "native" (usually, Java) API.- Specified by:
wrapAsAPIin interfaceObjectWrapperWithAPISupport- Overrides:
wrapAsAPIin classBeansWrapper- Parameters:
obj- The object for which the API model has to be returned. Shouldn't benull.- Returns:
- The
TemplateModelthrough which the API of the object can be accessed. Can't benull. - Throws:
TemplateModelException
-
-