Class DefaultObjectWrapper

  • All Implemented Interfaces:
    ObjectWrapper
    Direct Known Subclasses:
    SimpleObjectWrapper

    public class DefaultObjectWrapper
    extends freemarker.ext.beans.BeansWrapper

    The default implementation of the ObjectWrapper interface.

    • Constructor Detail

      • DefaultObjectWrapper

        public DefaultObjectWrapper()
    • Method Detail

      • wrap

        public TemplateModel wrap​(Object obj)
                           throws TemplateModelException
        Description copied from class: freemarker.ext.beans.BeansWrapper
        Wraps the object with a template model that is most specific for the object's class. Specifically:
        • if the object is null, returns TemplateModel.JAVA_NULL
        • if the object is already a TemplateModel, returns it unchanged,
        • if the object is a TemplateModelAdapter, returns its underlying model,
        • if the object is a Map, returns a MapModel for it
        • if the object is a Collection, returns a CollectionModel for it
        • if the object is an array, returns a ArrayModel for it
        • if the object is a Number returns a NumberModel for it,
        • if the object is a Date returns a DateModel for it,
        • if the object is a Boolean returns TemplateBooleanModel.TRUE or TemplateBooleanModel.FALSE
        • if the object is a ResourceBundle returns a ResourceBundleModel for it,
        • if the object is an Iterator, returns a IteratorModel for it
        • if the object is an Enumeration, returns a EnumerationModel for it
        • otherwise, returns a generic StringModel for it.
        Specified by:
        wrap in interface ObjectWrapper
        Overrides:
        wrap in class freemarker.ext.beans.BeansWrapper
        Returns:
        a TemplateModel wrapper of the object passed in.
        Throws:
        TemplateModelException
      • convertArray

        protected Object convertArray​(Object arr)
        Converts an array to a java.util.List