freemarker.template.utility
Class DeepUnwrap
java.lang.Objectfreemarker.template.utility.DeepUnwrap
public class DeepUnwrap
extends java.lang.Object
$Id: DeepUnwrap.java,v 1.6 2005/06/16 18:13:58 ddekany Exp $
unwrap
public static Object unwrap(TemplateModel model)
throws TemplateModelException Unwraps
TemplateModel-s recursively.
The converting of the
TemplateModel object happens with the following rules:
- If the object implements
AdapterTemplateModel, then the result
of AdapterTemplateModel.getAdaptedObject(Class) for Object.class is returned.
- If the object implements
WrapperTemplateModel, then the result
of WrapperTemplateModel.getWrappedObject() is returned.
- If the object implements
TemplateScalarModel, then the result
of TemplateScalarModel.getAsString() is returned.
- If the object implements
TemplateNumberModel, then the result
of TemplateNumberModel.getAsNumber() is returned.
- If the object implements
TemplateDateModel, then the result
of TemplateDateModel.getAsDate() is returned.
- If the object implements
TemplateBooleanModel, then the result
of TemplateBooleanModel.getAsBoolean() is returned.
- If the object implements
TemplateSequenceModel or
TemplateCollectionModel, then a java.util.ArrayList is
constructed from the subvariables, and each subvariable is unwrapped with
the rules described here (recursive unwrapping).
- If the object implements
TemplateHashModelEx, then a
java.util.HashMap is constructed from the subvariables, and each
subvariable is unwrapped with the rules described here (recursive unwrapping).
- Throw a
TemplateModelException, because it doesn't know how to
unwrapp the object.