info.magnolia.freemarker.models
Class MagnoliaObjectWrapper

java.lang.Object
  extended by freemarker.ext.beans.BeansWrapper
      extended by freemarker.template.DefaultObjectWrapper
          extended by info.magnolia.freemarker.models.MagnoliaObjectWrapper
All Implemented Interfaces:
freemarker.template.ObjectWrapper

public class MagnoliaObjectWrapper
extends freemarker.template.DefaultObjectWrapper

A FreeMarker ObjectWrapper that knows about Magnolia specific objects.

Version:
$Revision: $ ($Author: $)
Author:
Chris Miner, gjoseph

Field Summary
 
Fields inherited from class freemarker.ext.beans.BeansWrapper
CAN_NOT_UNWRAP, EXPOSE_ALL, EXPOSE_NOTHING, EXPOSE_PROPERTIES_ONLY, EXPOSE_SAFE
 
Fields inherited from interface freemarker.template.ObjectWrapper
BEANS_WRAPPER, DEFAULT_WRAPPER, SIMPLE_WRAPPER
 
Constructor Summary
MagnoliaObjectWrapper(FreemarkerConfig freemarkerConfig)
           
 
Method Summary
protected  freemarker.ext.util.ModelFactory getModelFactory(Class clazz)
          Checks the ModelFactory instances registered in FreemarkerConfig, then the default ones.
protected  freemarker.template.SimpleDate handleCalendar(Calendar cal)
          Deprecated. since 4.3 use CalendarModel instead.
 Object unwrap(freemarker.template.TemplateModel model, Class hint)
          Unwraps our custom wrappers, let the default wrapper do the rest.
 freemarker.template.TemplateModel wrap(Object obj)
           
 
Methods inherited from class freemarker.template.DefaultObjectWrapper
convertArray, handleUnknownType, wrapDomNode
 
Methods inherited from class freemarker.ext.beans.BeansWrapper
coerceBigDecimal, coerceBigDecimals, coerceBigDecimals, getDefaultDateType, getDefaultInstance, getEnumModels, getInstance, getOuterIdentity, getStaticModels, isExposeFields, isSimpleMapWrapper, isStrict, newInstance, setDefaultDateType, setExposeFields, setExposureLevel, setMethodsShadowItems, setNullModel, setOuterIdentity, setSimpleMapWrapper, setStrict, setUseCache, unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MagnoliaObjectWrapper

public MagnoliaObjectWrapper(FreemarkerConfig freemarkerConfig)
Method Detail

unwrap

public Object unwrap(freemarker.template.TemplateModel model,
                     Class hint)
              throws freemarker.template.TemplateModelException
Unwraps our custom wrappers, let the default wrapper do the rest.

Overrides:
unwrap in class freemarker.ext.beans.BeansWrapper
Throws:
freemarker.template.TemplateModelException

wrap

public freemarker.template.TemplateModel wrap(Object obj)
                                       throws freemarker.template.TemplateModelException
Specified by:
wrap in interface freemarker.template.ObjectWrapper
Overrides:
wrap in class freemarker.template.DefaultObjectWrapper
Throws:
freemarker.template.TemplateModelException

getModelFactory

protected freemarker.ext.util.ModelFactory getModelFactory(Class clazz)
Checks the ModelFactory instances registered in FreemarkerConfig, then the default ones. If no appropriate ModelFactory was found, delegates to Freemarker's implementation. This is called by BeansModelCache, which is itself called by BeansWrapper.wrap(java.lang.Object). These factories are cached by Freemarker, so this method only gets called once per type of object.

Overrides:
getModelFactory in class freemarker.ext.beans.BeansWrapper
See Also:
DEFAULT_MODEL_FACTORIES, FreemarkerConfig

handleCalendar

protected freemarker.template.SimpleDate handleCalendar(Calendar cal)
Deprecated. since 4.3 use CalendarModel instead.

Exposes a Calendar as a SimpleDate.



Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.