|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.beans.BeansWrapper
Wrapper
and Unwrapper
classes
public final class BeansWrapper
Utility class that provides generic services to reflection classes.
It handles all polymorphism issues in the wrap(Object)
and
unwrap(Object)
methods.
Field Summary | |
---|---|
static boolean |
WRAP_AS_OBJECT
Deprecated. Use in the wrap() method to override logic for determining whether the parameter should be wrapped as a TemplateScalarModel or as a TemplateHashModel, and force wrapping into hash model. |
static boolean |
WRAP_AS_SCALAR
Deprecated. Use in the wrap() method to override logic for determining whether the parameter should be wrapped as a TemplateScalarModel or as a TemplateHashModel, and force wrapping into scalar. |
Method Summary | |
---|---|
static boolean |
isScalar(java.lang.Class clazz)
Deprecated. Determines whether the object of this class should be wrapped into a FastScalar (true), or into a descendant of ObjectModelBase (false). |
static boolean |
isScalar(java.lang.Object object)
Deprecated. Determines whether the object should be wrapped into a SimpleScalar
(true), or into a descendant of ObjectModelBase (false). |
static java.lang.Object |
unwrap(java.lang.Object model)
Deprecated. Attempts to unwrap a model into underlying object. |
static java.lang.Object |
unwrap(java.lang.Object model,
java.lang.Class type)
Deprecated. Attempts to unwrap a model into underlying object. |
static TemplateModel |
wrap(java.lang.Object object)
Deprecated. Wraps the object with a template model that is most specific for the object's class. |
static TemplateModel |
wrap(java.lang.Object object,
boolean asScalar)
Deprecated. Wraps the object with a template model that is most specific for the object's class, just as wrap(Object) would, however it can force wrapping into
scalar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean WRAP_AS_SCALAR
public static final boolean WRAP_AS_OBJECT
Method Detail |
---|
public static final boolean isScalar(java.lang.Class clazz)
FastScalar
(true), or into a descendant of ObjectModelBase
(false).
All classes representing primitive types, as well as Number, String and Boolean qualify.
public static final boolean isScalar(java.lang.Object object)
SimpleScalar
(true), or into a descendant of ObjectModelBase
(false).
Convenience method for isScalar(Class)
that deals with object being
null.
All classes representing primitive types, as well as String and Boolean qualify.
public static final TemplateModel wrap(java.lang.Object object)
Models.EMPTY_SCALAR
,FastScalar
for it,FastBoolean
for it,TemplateModel
, returns it unchanged,ArrayModel
for it
MapModel
for it
CollectionModel
for it
IteratorModel
for it
EnumerationModel
for it
ObjectModel
for it
public static final TemplateModel wrap(java.lang.Object object, boolean asScalar)
wrap(Object)
would, however it can force wrapping into
scalar. (I.e. MethodModel uses this when it knows that its return type
is a primitive type wrapper).
object
- the object to wrapasScalar
- If WRAP_AS_SCALAR
, the object will be wrapped into
a scalar (in case it is neither a Boolean nor a String, its toString()
value is wrapped). If WRAP_AS_OBJECT
, the object will be wrapped into
ObjectModel
even if it is a String or Boolean.public static final java.lang.Object unwrap(java.lang.Object model) throws TemplateModelException
TemplateObjectModel
instances into their
underlying objects, generic TemplateScalarModel
into a String,
and generic TemplateNumberModel
into a Long. All other
objects are returned unchanged.
TemplateModelException
public static final java.lang.Object unwrap(java.lang.Object model, java.lang.Class type) throws TemplateModelException
TemplateObjectModel
instances into their
underlying objects, generic TemplateScalarModel
into a String,
and generic TemplateNumberModel
into various Number objects.
All other objects are returned unchanged.
TemplateModelException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |