SimpleObjectWrapper (FreeMarker 2.3.23 API)
Date: 2015-07-05

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.ObjectWrapperAndUnwrapper

      `CANT_UNWRAP_TO_TARGET_CLASS`

    - ### Fields inherited from interface freemarker.template.ObjectWrapper

      `BEANS_WRAPPER, DEFAULT_WRAPPER, SIMPLE_WRAPPER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleObjectWrapper()` Deprecated. Use `SimpleObjectWrapper(Version)` instead.
    `SimpleObjectWrapper(Version incompatibleImprovements)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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, 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`

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

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

- - ### Constructor Detail

    - #### SimpleObjectWrapper

          public SimpleObjectWrapper()

      Deprecated. Use `SimpleObjectWrapper(Version)` instead.

    - #### SimpleObjectWrapper

          public SimpleObjectWrapper(Version incompatibleImprovements)

      Parameters:
        `incompatibleImprovements` - see in `BeansWrapper.BeansWrapper(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 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`