SimpleObjectWrapper (FreeMarker 2.3.35 API)
Description: declaration: package: freemarker.template, class: SimpleObjectWrapper

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 the `TemplateModel` 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.
  Use `SimpleObjectWrapper(Version)` instead.
  `SimpleObjectWrapper​(Version incompatibleImprovements)`

- ## Method Summary

  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 a `TemplateModel` that 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, getDefaultZeroArgumentNonVoidMethodPolicy, getEnumModels, getExposureLevel, getIncompatibleImprovements, getInstance, getMemberAccessPolicy, getMethodAppearanceFineTuner, getModelFactory, getOuterIdentity, getPreferIndexedReadMethod, getRecordZeroArgumentNonVoidMethodPolicy, getStaticModels, getTreatDefaultMethodsAsBeanMembers, getUseCache, invokeMethod, isClassIntrospectionCacheRestricted, isExposeFields, isSimpleMapWrapper, isStrict, isWriteProtected, newInstance, readField, removeFromClassIntrospectionCache, setDefaultDateType, setDefaultZeroArgumentNonVoidMethodPolicy, setExposeFields, setExposureLevel, setMemberAccessPolicy, setMethodAppearanceFineTuner, setMethodsShadowItems, setNullModel, setOuterIdentity, setPreferIndexedReadMethod, setRecordZeroArgumentNonVoidMethodPolicy, setSimpleMapWrapper, setStrict, setTreatDefaultMethodsAsBeanMembers, setUseCache, toString, tryUnwrapTo, unwrap, unwrap, wrap, writeProtect`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### SimpleObjectWrapper

    @Deprecated public SimpleObjectWrapper()
    Deprecated.
    Use `SimpleObjectWrapper(Version)` instead.

  - ### SimpleObjectWrapper

    public SimpleObjectWrapper​(Version incompatibleImprovements)
    Parameters:
      `incompatibleImprovements` - see in `BeansWrapper(Version)`.
    Since:
      2.3.21

- ## Method Details

  - ### 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 class `DefaultObjectWrapper`
    Throws:
      `TemplateModelException`

  - ### wrapAsAPI

    public TemplateHashModel wrapAsAPI​(Object obj) throws TemplateModelException
    Description copied from interface: `ObjectWrapperWithAPISupport`
    Wraps an object to a `TemplateModel` that exposes the object's "native" (usually, Java) API.
    Specified by:
      `wrapAsAPI` in interface `ObjectWrapperWithAPISupport`
    Overrides:
      `wrapAsAPI` in class `BeansWrapper`
    Parameters:
      `obj` - The object for which the API model has to be returned. Shouldn't be `null`.
    Returns:
      The `TemplateModel` through which the API of the object can be accessed. Can't be `null`.
    Throws:
      `TemplateModelException`