Package freemarker.template.utility
Class DeepUnwrap
- java.lang.Object
-
- freemarker.template.utility.DeepUnwrap
-
public class DeepUnwrap extends java.lang.ObjectUtility methods for unwrappingTemplateModel-s.
-
-
Constructor Summary
Constructors Constructor Description DeepUnwrap()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.ObjectpermissiveUnwrap(TemplateModel model)Same asunwrap(TemplateModel), but it doesn't throw exception if it doesn't know how to unwrap the model, but rather returns it as-is.static java.lang.ObjectpremissiveUnwrap(TemplateModel model)Deprecated.the name of this method is mistyped.static java.lang.Objectunwrap(TemplateModel model)UnwrapsTemplateModel-s recursively.
-
-
-
Method Detail
-
unwrap
public static java.lang.Object unwrap(TemplateModel model) throws TemplateModelException
UnwrapsTemplateModel-s recursively. The converting of theTemplateModelobject happens with the following rules:- If the object implements
AdapterTemplateModel, then the result ofAdapterTemplateModel.getAdaptedObject(Class)for Object.class is returned. - If the object implements
WrapperTemplateModel, then the result ofWrapperTemplateModel.getWrappedObject()is returned. - If the object is identical to the null model of the current object wrapper, null is returned.
- If the object implements
TemplateScalarModel, then the result ofTemplateScalarModel.getAsString()is returned. - If the object implements
TemplateNumberModel, then the result ofTemplateNumberModel.getAsNumber()is returned. - If the object implements
TemplateDateModel, then the result ofTemplateDateModel.getAsDate()is returned. - If the object implements
TemplateBooleanModel, then the result ofTemplateBooleanModel.getAsBoolean()is returned. - If the object implements
TemplateSequenceModelorTemplateCollectionModel, then ajava.util.ArrayListis constructed from the subvariables, and each subvariable is unwrapped with the rules described here (recursive unwrapping). - If the object implements
TemplateHashModelEx, then ajava.util.HashMapis 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 unwrap the object.
- Throws:
TemplateModelException
- If the object implements
-
permissiveUnwrap
public static java.lang.Object permissiveUnwrap(TemplateModel model) throws TemplateModelException
Same asunwrap(TemplateModel), but it doesn't throw exception if it doesn't know how to unwrap the model, but rather returns it as-is.- Throws:
TemplateModelException- Since:
- 2.3.14
-
premissiveUnwrap
@Deprecated public static java.lang.Object premissiveUnwrap(TemplateModel model) throws TemplateModelException
Deprecated.the name of this method is mistyped. UsepermissiveUnwrap(TemplateModel)instead.- Throws:
TemplateModelException
-
-