freemarker.ext.beans
Class BeansWrapper

java.lang.Object
  extended by freemarker.ext.beans.BeansWrapper

Deprecated. this class is deprecated in favour of the Wrapper and Unwrapper classes

public final class BeansWrapper
extends java.lang.Object

Utility class that provides generic services to reflection classes. It handles all polymorphism issues in the wrap(Object) and unwrap(Object) methods.

Version:
$Id: BeansWrapper.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Attila Szegedi, attila@szegedi.org

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

WRAP_AS_SCALAR

public static final 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.

See Also:
Constant Field Values

WRAP_AS_OBJECT

public static final 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.

See Also:
Constant Field Values
Method Detail

isScalar

public static final 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). All classes representing primitive types, as well as Number, String and Boolean qualify.


isScalar

public static final 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). Convenience method for isScalar(Class) that deals with object being null. All classes representing primitive types, as well as String and Boolean qualify.


wrap

public static final TemplateModel wrap(java.lang.Object object)
Deprecated. 
Wraps the object with a template model that is most specific for the object's class. Specifically:


wrap

public static final 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. (I.e. MethodModel uses this when it knows that its return type is a primitive type wrapper).

Parameters:
object - the object to wrap
asScalar - 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.

unwrap

public static final java.lang.Object unwrap(java.lang.Object model)
                                     throws TemplateModelException
Deprecated. 
Attempts to unwrap a model into underlying object. It can unwrap TemplateObjectModel instances into their underlying objects, generic TemplateScalarModel into a String, and generic TemplateNumberModel into a Long. All other objects are returned unchanged.

Throws:
TemplateModelException

unwrap

public static final java.lang.Object unwrap(java.lang.Object model,
                                            java.lang.Class type)
                                     throws TemplateModelException
Deprecated. 
Attempts to unwrap a model into underlying object. It can unwrap TemplateObjectModel instances into their underlying objects, generic TemplateScalarModel into a String, and generic TemplateNumberModel into various Number objects. All other objects are returned unchanged.

Throws:
TemplateModelException