Package freemarker.template.utility
Class DeepUnwrap
- java.lang.Object
-
- freemarker.template.utility.DeepUnwrap
-
public class DeepUnwrap extends Object
Utility 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 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.
-
-
-
Method Detail
-
unwrap
public static Object unwrap(TemplateModel model) throws TemplateModelException
UnwrapsTemplateModel
-s recursively. The converting of theTemplateModel
object 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
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
public static 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
public static Object premissiveUnwrap(TemplateModel model) throws TemplateModelException
Deprecated.the name of this method is mistyped. UsepermissiveUnwrap(TemplateModel)
instead.- Throws:
TemplateModelException
-
-