Package freemarker.ext.beans
The default object wrapper of FreeMarker uses
this to expose Java Beans and POJO-s to templates, but it can also be used in itself as a
better alternative ObjectWrapper.
Most of the issues dealing with beans are handled by the
BeansWrapper.wrap(Object)and BeansWrapper.getStaticModels() methods. In normal cases,
these are the only methods
you should use to turn an arbitrary Java object into a
FreeMarker TemplateModel. Additionally, you can manually create
instance of any wrapper class using its constructors.
Note, however that in such cases you bypass the eventual model caching
of the wrapper.
-
Interface Summary Interface Description MethodAppearanceFineTuner Used for customizing how the methods are visible from templates, viaBeansWrapper.setMethodAppearanceFineTuner(MethodAppearanceFineTuner).SingletonCustomizer Marker interface useful when used together withMethodAppearanceFineTunerand such customizer objects, to indicate that it doesn't contain reference to theObjectWrapper(so beware with non-static inner classes) and can be and should be used in call introspection cache keys. -
Class Summary Class Description ArrayModel A class that will wrap an arbitrary array intoTemplateCollectionModelandTemplateSequenceModelinterfaces.BeanModel A class that will wrap an arbitrary object intoTemplateHashModelinterface allowing calls to arbitrary property getters and invocation of accessible methods on the object from a template using the object.foo to access properties and object.bar(arg1, arg2) to invoke methods on it.BeansModelCache BeansWrapper ObjectWrapperthat is able to expose the Java API of arbitrary Java objects.BeansWrapper.MethodAppearanceDecision Experimental class; subject to change! Used forMethodAppearanceFineTuner.process(freemarker.ext.beans.BeansWrapper.MethodAppearanceDecisionInput, freemarker.ext.beans.BeansWrapper.MethodAppearanceDecision)to store the results; see there.BeansWrapper.MethodAppearanceDecisionInput Experimental class; subject to change! Used forMethodAppearanceFineTuner.process(freemarker.ext.beans.BeansWrapper.MethodAppearanceDecisionInput, freemarker.ext.beans.BeansWrapper.MethodAppearanceDecision)as input parameter; see there.BeansWrapperBuilder Gets/creates aBeansWrappersingleton instance that's already configured as specified in the properties of this object; this is recommended over using theBeansWrapperconstructors.BeansWrapperConfiguration HoldsBeansWrapperconfiguration settings and defines their defaults.BooleanModel A class that will wrap instances ofBooleaninto aTemplateBooleanModel.CollectionModel A special case ofBeanModelthat can wrap Java collections and that implements theTemplateCollectionModelin order to be usable in a <#list> block.DateModel Wraps arbitrary subclass ofDateinto a reflective model.EnumerationModel A class that addsTemplateModelIteratorfunctionality to theEnumerationinterface implementers.HashAdapter IteratorModel A class that addsTemplateModelIteratorfunctionality to theIteratorinterface implementers.MapModel A special case ofBeanModelthat adds implementation forTemplateMethodModelExon map objects that is a shortcut for the Map.get() method.NumberModel Wraps arbitrary subclass ofNumberinto a reflective model.OverloadedMethodsModel Wraps a set of same-name overloaded methods behindTemplateMethodModelinterface, like if it was a single method, chooses among them behind the scenes on call-time based on the argument values.ResourceBundleModel A hash model that wraps a resource bundle.SimpleMapModel Model used byBeansWrapperwhen simpleMapWrapper mode is enabled.SimpleMethodModel A class that will wrap a reflected method call into aTemplateMethodModelinterface.StringModel Subclass ofBeanModelthat exposes the return value of theObject.toString()method through theTemplateScalarModelinterface. -
Exception Summary Exception Description InvalidPropertyException An exception thrown when there is an attempt to access an invalid bean property when we are in a "strict bean" mode