Package freemarker.template.utility
Class DeepUnwrap
java.lang.Object
freemarker.template.utility.DeepUnwrap
Utility methods for unwrapping
TemplateModel
-s.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
permissiveUnwrap(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 Object
premissiveUnwrap(TemplateModel model)
Deprecated.the name of this method is mistyped.static Object
unwrap(TemplateModel model)
UnwrapsTemplateModel
-s recursively.
-
Constructor Details
-
DeepUnwrap
public DeepUnwrap()
-
-
Method Details
-
unwrap
UnwrapsTemplateModel
-s recursively. The converting of theTemplateModel
object happens with the following rules:- If the object implements
AdapterTemplateModel
, then the result ofAdapterTemplateModel.getAdaptedObject(Class)
forObject.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
TemplateSequenceModel
orTemplateCollectionModel
, then ajava.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 ajava.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 unwrap the object.
- Throws:
TemplateModelException
- If the object implements
-
permissiveUnwrap
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 Object premissiveUnwrap(TemplateModel model) throws TemplateModelExceptionDeprecated.the name of this method is mistyped. UsepermissiveUnwrap(TemplateModel)
instead.- Throws:
TemplateModelException
-