net.sf.morph
Class Morph

java.lang.Object
  extended by net.sf.morph.Morph

public abstract class Morph
extends java.lang.Object

A convenient static API for basic use of the Morph framework. This class does not provide any means for customizing/changing its behavior so that components can be guaranteed that calls to this static class will behave consistently regardless of the environment they are executed in. If you need customized behavior, use a SimpleDelegatingTransformer or other customized Morph objects. This class is just a static facade for accessing those classes directly. They are particularly easy to configure using an Inversion of Control framework such as Spring.

Since:
Nov 28, 2004
Author:
Matt Sgarlata
See Also:
net.sf.morph.transform.copiers.DelegatingCopier, net.sf.morph.transform.converters.DelegatingConverter, SimpleLanguage

Method Summary
static boolean add(java.lang.Object container, java.lang.Object value)
          Adds a new value to the end of a container.
static java.lang.Object convert(java.lang.Class destinationClass, java.lang.Object source)
          Converts the given source into an object of class destinationClass.
static java.lang.Object convert(java.lang.Class destinationClass, java.lang.Object source, java.util.Locale locale)
          Converts the given source into an object of class destinationClass.
static java.math.BigDecimal convertToBigDecimal(java.lang.Object source)
          Converts the given source into a BigDecimal.
static java.math.BigDecimal convertToBigDecimal(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a BigDecimal.
static java.math.BigInteger convertToBigInteger(java.lang.Object source)
          Converts the given source into a BigInteger.
static java.math.BigInteger convertToBigInteger(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a BigInteger.
static boolean convertToBoolean(java.lang.Object source)
          Converts the given source into a boolean.
static java.lang.Boolean convertToBooleanObject(java.lang.Object source)
          Converts the given source into a Boolean.
static byte convertToByte(java.lang.Object source)
          Converts the given source into a byte.
static byte convertToByte(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a byte.
static java.lang.Byte convertToByteObject(java.lang.Object source)
          Converts the given source into a Byte.
static java.lang.Byte convertToByteObject(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Byte.
static java.util.Calendar convertToCalendar(java.lang.Object source)
          Converts the given source into a Calendar.
static java.util.Calendar convertToCalendar(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Calendar.
static java.util.Date convertToDate(java.lang.Object source)
          Converts the given source into a Date.
static java.util.Date convertToDate(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Date.
static double convertToDouble(java.lang.Object source)
          Converts the given source into a double.
static double convertToDouble(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a double.
static java.lang.Double convertToDoubleObject(java.lang.Object source)
          Converts the given source into a Double.
static java.lang.Double convertToDoubleObject(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Double.
static float convertToFloat(java.lang.Object source)
          Converts the given source into a float.
static float convertToFloat(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a float.
static java.lang.Float convertToFloatObject(java.lang.Object source)
          Converts the given source into a Float.
static java.lang.Float convertToFloatObject(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Float.
static int convertToInt(java.lang.Object source)
          Converts the given source into a int.
static int convertToInt(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a int.
static java.lang.Integer convertToIntegerObject(java.lang.Object source)
          Converts the given source into a Integer.
static java.lang.Integer convertToIntegerObject(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Integer.
static long convertToLong(java.lang.Object source)
          Converts the given source into a long.
static long convertToLong(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a long.
static java.lang.Long convertToLongObject(java.lang.Object source)
          Converts the given source into a Long.
static java.lang.Long convertToLongObject(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a Long.
static java.lang.String convertToPrettyString(java.lang.Object source)
          Converts the given source into a String that displays the information contained in the object in a format good for debugging.
static java.lang.String convertToString(java.lang.Object source)
          Converts the given source into a String.
static java.lang.String convertToString(java.lang.Object source, java.util.Locale locale)
          Converts the given source into a String.
static void copy(java.lang.Object destination, java.lang.Object source)
           Copies information from the given source to the given destination.
static void copy(java.lang.Object destination, java.lang.Object source, java.util.Locale locale)
           Copies information from the given source to the given destination.
static java.lang.Object get(java.lang.Object container, int index)
          Gets the element at the specified index.
static java.lang.Object get(java.lang.Object target, java.lang.String expression)
          Retrieve the property indicated by expression from target.
static java.lang.Object get(java.lang.Object target, java.lang.String expression, java.lang.Class destinationClass)
          Retrieve the information indicated by expression from target as the type indicated by destinationClass.
static java.lang.Object get(java.lang.Object target, java.lang.String expression, java.lang.Class destinationClass, java.util.Locale locale)
          Retrieve the information indicated by expression from target as the type indicated by destinationClass.
static java.lang.Object get(java.lang.Object target, java.lang.String expression, java.util.Locale locale, java.lang.Class destinationClass)
          Retrieve the information indicated by expression from target as the type indicated by destinationClass.
static Bean getBean(java.lang.Object object)
          Returns the given object wrapped as a Bean.
static java.math.BigDecimal getBigDecimal(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a BigDecimal.
static java.math.BigInteger getBigInteger(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a BigInteger.
static boolean getBoolean(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a boolean.
static java.lang.Boolean getBooleanObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Boolean object.
static byte getByte(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a byte.
static java.lang.Byte getByteObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Byte object.
static java.util.Calendar getCalendar(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Calendar.
static java.lang.Class getContainedType(java.lang.Class clazz)
          Returns the type of the elements that are contained in objects of the given class.
static Container getContainer(java.lang.Object object)
          Returns the given object wrapped as a Container.
static java.util.Date getDate(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Date.
static double getDouble(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a double.
static java.lang.Double getDoubleObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Double object.
static float getFloat(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a float.
static java.lang.Float getFloatObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Float object.
static GrowableContainer getGrowableContainer(java.lang.Object object)
          Returns the given object wrapped as a GrowableContainer.
static IndexedContainer getIndexedContainer(java.lang.Object object)
          Returns the given object wrapped as an IndexedContainer.
static int getInt(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a int.
static java.lang.Integer getIntegerObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Integer object.
static java.util.Iterator getIterator(java.lang.Object container)
          Exposes an iterator over the contents of the container.
static long getLong(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a long.
static java.lang.Long getLongObject(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a Long object.
static MutableIndexedContainer getMutableIndexedContainer(java.lang.Object object)
          Returns the given object wrapped as a MutableIndexedContainer.
static java.lang.String[] getPropertyNames(java.lang.Object bean)
          Gets the names of the properties which are currently defined for the given bean.
static int getSize(java.lang.Object object)
          Returns the number of elements contained in a given object.
static java.lang.String getString(java.lang.Object target, java.lang.String expression)
          Retrieve the information indicated by expression from target as a String.
static java.lang.String getString(java.lang.Object target, java.lang.String expression, java.util.Locale locale)
          Retrieve the information indicated by expression from target as a String.
static java.lang.Class getType(java.lang.Class beanType, java.lang.String propertyName)
          Specifies the least restrictive type that may be assigned to the given property.
static java.lang.Class getType(java.lang.Object bean, java.lang.String propertyName)
          Specifies the least restrictive type that may be assigned to the given property.
static boolean isReadable(java.lang.Object bean, java.lang.String propertyName)
          Specifies whether the given property is readable.
static boolean isWriteable(java.lang.Object bean, java.lang.String propertyName)
          Specifies whether the given property is writeable.
static java.lang.Object newInstance(java.lang.Class clazz)
          Creates a new instance of the given type.
static java.lang.Object set(java.lang.Object container, int index, java.lang.Object propertyValue)
          Sets the element at the specified index.
static void set(java.lang.Object target, java.lang.String expression, boolean value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, byte value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, double value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, float value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, int value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, long value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, java.lang.Object value)
          Sets the information indicated by expression on target.
static void set(java.lang.Object target, java.lang.String expression, java.lang.Object value, java.util.Locale locale)
          Sets the information indicated by expression on target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convert

public static java.lang.Object convert(java.lang.Class destinationClass,
                                       java.lang.Object source)
                                throws TransformationException
Converts the given source into an object of class destinationClass. The returned object may be a reference to source itself. This isn't an issue for immutable classes (String, Long, etc) but is an issue for Collection and Array types.

Parameters:
destinationClass - the destination class to convert
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convert

public static java.lang.Object convert(java.lang.Class destinationClass,
                                       java.lang.Object source,
                                       java.util.Locale locale)
                                throws TransformationException
Converts the given source into an object of class destinationClass. The returned object may be a reference to source itself. This isn't an issue for immutable classes (String, Long, etc) but is an issue for Collection and Array types.

Parameters:
destinationClass - the destination class to convert
source - the source object to convert
locale - the locale in which the conversion should take place, or null if the locale is not applicable
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToPrettyString

public static java.lang.String convertToPrettyString(java.lang.Object source)
                                              throws TransformationException
Converts the given source into a String that displays the information contained in the object in a format good for debugging. This is a great implementation of the toString method for an object. FIXME actually, calling this method from the toString method of an object is likely to cause a StackOverflowException

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBigDecimal

public static java.math.BigDecimal convertToBigDecimal(java.lang.Object source)
                                                throws TransformationException
Converts the given source into a BigDecimal.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBigDecimal

public static java.math.BigDecimal convertToBigDecimal(java.lang.Object source,
                                                       java.util.Locale locale)
                                                throws TransformationException
Converts the given source into a BigDecimal.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBigInteger

public static java.math.BigInteger convertToBigInteger(java.lang.Object source)
                                                throws TransformationException
Converts the given source into a BigInteger.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBigInteger

public static java.math.BigInteger convertToBigInteger(java.lang.Object source,
                                                       java.util.Locale locale)
                                                throws TransformationException
Converts the given source into a BigInteger.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBoolean

public static boolean convertToBoolean(java.lang.Object source)
                                throws TransformationException
Converts the given source into a boolean.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToBooleanObject

public static java.lang.Boolean convertToBooleanObject(java.lang.Object source)
                                                throws TransformationException
Converts the given source into a Boolean.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToByte

public static byte convertToByte(java.lang.Object source)
                          throws TransformationException
Converts the given source into a byte.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToByte

public static byte convertToByte(java.lang.Object source,
                                 java.util.Locale locale)
                          throws TransformationException
Converts the given source into a byte.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToByteObject

public static java.lang.Byte convertToByteObject(java.lang.Object source)
                                          throws TransformationException
Converts the given source into a Byte.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToByteObject

public static java.lang.Byte convertToByteObject(java.lang.Object source,
                                                 java.util.Locale locale)
                                          throws TransformationException
Converts the given source into a Byte.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToCalendar

public static java.util.Calendar convertToCalendar(java.lang.Object source)
                                            throws TransformationException
Converts the given source into a Calendar.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToCalendar

public static java.util.Calendar convertToCalendar(java.lang.Object source,
                                                   java.util.Locale locale)
                                            throws TransformationException
Converts the given source into a Calendar.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDate

public static java.util.Date convertToDate(java.lang.Object source)
                                    throws TransformationException
Converts the given source into a Date.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDate

public static java.util.Date convertToDate(java.lang.Object source,
                                           java.util.Locale locale)
                                    throws TransformationException
Converts the given source into a Date.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDouble

public static double convertToDouble(java.lang.Object source)
                              throws TransformationException
Converts the given source into a double.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDouble

public static double convertToDouble(java.lang.Object source,
                                     java.util.Locale locale)
                              throws TransformationException
Converts the given source into a double.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDoubleObject

public static java.lang.Double convertToDoubleObject(java.lang.Object source)
                                              throws TransformationException
Converts the given source into a Double.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToDoubleObject

public static java.lang.Double convertToDoubleObject(java.lang.Object source,
                                                     java.util.Locale locale)
                                              throws TransformationException
Converts the given source into a Double.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToFloat

public static float convertToFloat(java.lang.Object source)
                            throws TransformationException
Converts the given source into a float.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToFloat

public static float convertToFloat(java.lang.Object source,
                                   java.util.Locale locale)
                            throws TransformationException
Converts the given source into a float.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToFloatObject

public static java.lang.Float convertToFloatObject(java.lang.Object source)
                                            throws TransformationException
Converts the given source into a Float.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToFloatObject

public static java.lang.Float convertToFloatObject(java.lang.Object source,
                                                   java.util.Locale locale)
                                            throws TransformationException
Converts the given source into a Float.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToInt

public static int convertToInt(java.lang.Object source)
                        throws TransformationException
Converts the given source into a int.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToInt

public static int convertToInt(java.lang.Object source,
                               java.util.Locale locale)
                        throws TransformationException
Converts the given source into a int.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToIntegerObject

public static java.lang.Integer convertToIntegerObject(java.lang.Object source)
                                                throws TransformationException
Converts the given source into a Integer.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToIntegerObject

public static java.lang.Integer convertToIntegerObject(java.lang.Object source,
                                                       java.util.Locale locale)
                                                throws TransformationException
Converts the given source into a Integer.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToLong

public static long convertToLong(java.lang.Object source)
                          throws TransformationException
Converts the given source into a long.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToLong

public static long convertToLong(java.lang.Object source,
                                 java.util.Locale locale)
                          throws TransformationException
Converts the given source into a long.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToLongObject

public static java.lang.Long convertToLongObject(java.lang.Object source)
                                          throws TransformationException
Converts the given source into a Long.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToLongObject

public static java.lang.Long convertToLongObject(java.lang.Object source,
                                                 java.util.Locale locale)
                                          throws TransformationException
Converts the given source into a Long.

Parameters:
source - the source object to convert
locale - the locale in which the conversion is to be performed
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToString

public static java.lang.String convertToString(java.lang.Object source)
                                        throws TransformationException
Converts the given source into a String.

Parameters:
source - the source object to convert
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

convertToString

public static java.lang.String convertToString(java.lang.Object source,
                                               java.util.Locale locale)
                                        throws TransformationException
Converts the given source into a String.

Parameters:
source - the source object to convert
locale - the locale in which the conversion should take place
Returns:
the result of the conversion
Throws:
TransformationException - if destinationClass is null, an error occurred while performing the conversion

get

public static java.lang.Object get(java.lang.Object target,
                                   java.lang.String expression)
                            throws LanguageException
Retrieve the property indicated by expression from target.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target
Throws:
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

get

public static java.lang.Object get(java.lang.Object target,
                                   java.lang.String expression,
                                   java.lang.Class destinationClass)
                            throws LanguageException,
                                   TransformationException
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
destinationClass - indicates the type that should be returned by this method
Returns:
the information indicated by expression from target
Throws:
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

get

public static java.lang.Object get(java.lang.Object target,
                                   java.lang.String expression,
                                   java.lang.Class destinationClass,
                                   java.util.Locale locale)
                            throws LanguageException,
                                   TransformationException
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
destinationClass - indicates the type that should be returned by this method
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
Returns:
the information indicated by expression from target
Throws:
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

get

public static java.lang.Object get(java.lang.Object target,
                                   java.lang.String expression,
                                   java.util.Locale locale,
                                   java.lang.Class destinationClass)
                            throws LanguageException,
                                   TransformationException
Retrieve the information indicated by expression from target as the type indicated by destinationClass.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
destinationClass - indicates the type that should be returned by this method
Returns:
the information indicated by expression from target
Throws:
TransformationException - if an error occurs while converting the requested information to the type indicated by destinationClass
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       java.lang.Object value)
                throws LanguageException,
                       TransformationException
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       java.lang.Object value,
                       java.util.Locale locale)
                throws LanguageException,
                       TransformationException
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
locale - indicates the locale in which the conversion to type destinationClass should be performed, if applicable
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

copy

public static void copy(java.lang.Object destination,
                        java.lang.Object source)
                 throws TransformationException

Copies information from the given source to the given destination.

Parameters:
destination - the object to which information is written
source - the object from which information is read
Throws:
TransformationException - if source or destination are null

copy

public static void copy(java.lang.Object destination,
                        java.lang.Object source,
                        java.util.Locale locale)
                 throws TransformationException

Copies information from the given source to the given destination.

Parameters:
destination - the object to which information is written
source - the object from which information is read
locale - the locale of the current user, which may be null if the locale is unknown or not applicable
Throws:
TransformationException - if source or destination are null

getBean

public static Bean getBean(java.lang.Object object)
                    throws WrapperException
Returns the given object wrapped as a Bean.

Parameters:
object - the object to be wrapped
Returns:
the wrapped object
Throws:
WrapperException - if the wrapper could not be retrieved

getContainer

public static Container getContainer(java.lang.Object object)
                              throws WrapperException
Returns the given object wrapped as a Container.

Parameters:
object - the object to be wrapped
Returns:
the wrapped object
Throws:
WrapperException - if the wrapper could not be retrieved

getGrowableContainer

public static GrowableContainer getGrowableContainer(java.lang.Object object)
                                              throws WrapperException
Returns the given object wrapped as a GrowableContainer.

Parameters:
object - the object to be wrapped
Returns:
the wrapped object
Throws:
WrapperException - if the wrapper could not be retrieved

getIndexedContainer

public static IndexedContainer getIndexedContainer(java.lang.Object object)
                                            throws WrapperException
Returns the given object wrapped as an IndexedContainer.

Parameters:
object - the object to be wrapped
Returns:
the wrapped object
Throws:
WrapperException - if the wrapper could not be retrieved

getMutableIndexedContainer

public static MutableIndexedContainer getMutableIndexedContainer(java.lang.Object object)
                                                          throws WrapperException
Returns the given object wrapped as a MutableIndexedContainer.

Parameters:
object - the object to be wrapped
Returns:
the wrapped object
Throws:
WrapperException - if the wrapper could not be retrieved

getBigDecimal

public static java.math.BigDecimal getBigDecimal(java.lang.Object target,
                                                 java.lang.String expression)
Retrieve the information indicated by expression from target as a BigDecimal.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a BigDecimal
Throws:
TransformationException - if an error occurs while converting the requested information to a BigDecimal
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getBigInteger

public static java.math.BigInteger getBigInteger(java.lang.Object target,
                                                 java.lang.String expression)
Retrieve the information indicated by expression from target as a BigInteger.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a BigInteger
Throws:
TransformationException - if an error occurs while converting the requested information to a BigInteger
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getBoolean

public static boolean getBoolean(java.lang.Object target,
                                 java.lang.String expression)
Retrieve the information indicated by expression from target as a boolean.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a boolean
Throws:
TransformationException - if an error occurs while converting the requested information to a boolean
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getBooleanObject

public static java.lang.Boolean getBooleanObject(java.lang.Object target,
                                                 java.lang.String expression)
Retrieve the information indicated by expression from target as a Boolean object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Boolean object
Throws:
TransformationException - if an error occurs while converting the requested information to a Boolean object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       boolean value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getByte

public static byte getByte(java.lang.Object target,
                           java.lang.String expression)
Retrieve the information indicated by expression from target as a byte.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a byte
Throws:
TransformationException - if an error occurs while converting the requested information to a byte
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getByteObject

public static java.lang.Byte getByteObject(java.lang.Object target,
                                           java.lang.String expression)
Retrieve the information indicated by expression from target as a Byte object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Byte object
Throws:
TransformationException - if an error occurs while converting the requested information to a Byte object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       byte value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getDouble

public static double getDouble(java.lang.Object target,
                               java.lang.String expression)
Retrieve the information indicated by expression from target as a double.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a double
Throws:
TransformationException - if an error occurs while converting the requested information to a double
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getDoubleObject

public static java.lang.Double getDoubleObject(java.lang.Object target,
                                               java.lang.String expression)
Retrieve the information indicated by expression from target as a Double object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Double object
Throws:
TransformationException - if an error occurs while converting the requested information to a Double object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       double value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getFloat

public static float getFloat(java.lang.Object target,
                             java.lang.String expression)
Retrieve the information indicated by expression from target as a float.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a float
Throws:
TransformationException - if an error occurs while converting the requested information to a float
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getFloatObject

public static java.lang.Float getFloatObject(java.lang.Object target,
                                             java.lang.String expression)
Retrieve the information indicated by expression from target as a Float object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Float object
Throws:
TransformationException - if an error occurs while converting the requested information to a Float object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       float value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getInt

public static int getInt(java.lang.Object target,
                         java.lang.String expression)
Retrieve the information indicated by expression from target as a int.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a int
Throws:
TransformationException - if an error occurs while converting the requested information to a int
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getIntegerObject

public static java.lang.Integer getIntegerObject(java.lang.Object target,
                                                 java.lang.String expression)
Retrieve the information indicated by expression from target as a Integer object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Integer object
Throws:
TransformationException - if an error occurs while converting the requested information to a Integer object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       int value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getLong

public static long getLong(java.lang.Object target,
                           java.lang.String expression)
Retrieve the information indicated by expression from target as a long.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a long
Throws:
TransformationException - if an error occurs while converting the requested information to a long
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getLongObject

public static java.lang.Long getLongObject(java.lang.Object target,
                                           java.lang.String expression)
Retrieve the information indicated by expression from target as a Long object.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Long object
Throws:
TransformationException - if an error occurs while converting the requested information to a Long object
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

set

public static void set(java.lang.Object target,
                       java.lang.String expression,
                       long value)
Sets the information indicated by expression on target. value will be automatically converted to a type appropriate for the given expression.

Parameters:
target - the object that will be modified
expression - an expression specifying which information will be modified
value - the information to be changed
Throws:
TransformationException - if an error occurs while converting value to the appropriate type
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getDate

public static java.util.Date getDate(java.lang.Object target,
                                     java.lang.String expression)
Retrieve the information indicated by expression from target as a Date.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Date
Throws:
TransformationException - if an error occurs while converting the requested information to a Date
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getString

public static java.lang.String getString(java.lang.Object target,
                                         java.lang.String expression)
Retrieve the information indicated by expression from target as a String.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a String
Throws:
TransformationException - if an error occurs while converting the requested information to a String
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getString

public static java.lang.String getString(java.lang.Object target,
                                         java.lang.String expression,
                                         java.util.Locale locale)
Retrieve the information indicated by expression from target as a String.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
locale - the locale in which the conversion should take place, or null if the locale is not applicable
Returns:
the information indicated by expression from target as a String
Throws:
TransformationException - if an error occurs while converting the requested information to a String
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getCalendar

public static java.util.Calendar getCalendar(java.lang.Object target,
                                             java.lang.String expression)
Retrieve the information indicated by expression from target as a Calendar.

Parameters:
target - the object from which information will be retrieved
expression - an expression specifying which information to retrieve
Returns:
the information indicated by expression from target as a Calendar
Throws:
TransformationException - if an error occurs while converting the requested information to a Calendar
LanguageException - if target is null or
an error occurrs while evaluating an otherwise valid expression
InvalidExpressionException - if expression is empty or not a valid expression

getPropertyNames

public static java.lang.String[] getPropertyNames(java.lang.Object bean)
                                           throws ReflectionException
Gets the names of the properties which are currently defined for the given bean. Note that some beans (e.g. - Maps) allow the creation of new properties, which means isWriteable may return true for property names that are not included in the return value of this method.

Parameters:
bean - the bean for which we would like a list of properties
Returns:
the names of the properties which are currently defined for the given bean. Note that some beans (e.g. - Maps) allow the creation of new properties, which means isWriteable may return true for property names that are not included in the return value of this method.
Throws:
ReflectionException - if bean is null

getType

public static java.lang.Class getType(java.lang.Object bean,
                                      java.lang.String propertyName)
                               throws ReflectionException
Specifies the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property.

Parameters:
bean - the bean
propertyName - the name of the property
Returns:
the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property
Throws:
ReflectionException - if bean or propertyName are null or
if the type could not be retrieved for some reason

getType

public static java.lang.Class getType(java.lang.Class beanType,
                                      java.lang.String propertyName)
                               throws ReflectionException
Specifies the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property.

Parameters:
beanType - the type of the bean
propertyName - the name of the property
Returns:
the least restrictive type that may be assigned to the given property. In the case of a weakly typed bean, the correct value to return is simply Object.class, which indicates that any type can be assigned to the given property
Throws:
ReflectionException - if beanType or propertyName are null or
if the type could not be retrieved for some reason

isReadable

public static boolean isReadable(java.lang.Object bean,
                                 java.lang.String propertyName)
                          throws ReflectionException
Specifies whether the given property is readable. A reflector can always determine if a property is readable by attempting to read the property value, so this method can be counted on to truly indicate whether or not the given property is readable.

Parameters:
bean - the bean
propertyName - the name of the property
Returns:
true if the property is readable, or
false, otherwise
Throws:
ReflectionException - if bean or propertyName are null or
if the readability of the property cannot be determined

isWriteable

public static boolean isWriteable(java.lang.Object bean,
                                  java.lang.String propertyName)
                           throws ReflectionException
Specifies whether the given property is writeable. If the reflector cannot determine whether the given property is writeable, it may simply return true. This method only guarantees that if isWriteable returns false, the method is not writeable. The method may or may not be writeable if this method returns true.

Parameters:
bean - the bean
propertyName - the name of the property
Returns:
false if the property is not writeable or
true if the property is writeable or if this reflector cannot determine for sure whether or not the property is writeable
Throws:
ReflectionException - if bean or propertyName are null or
if the writeability of the property cannot be determined

getContainedType

public static java.lang.Class getContainedType(java.lang.Class clazz)
                                        throws ReflectionException
Returns the type of the elements that are contained in objects of the given class. For example, if indexedClass represents an array of ints,Integer.TYPE should be returned. This method should only be called if Reflector#isReflectable(Class)returns true.

Parameters:
clazz - the container's type
Returns:
the type of the elements that are container by the given object
Throws:
ReflectionException - if container is null or
the type of the elements that are container could not be determined

getIterator

public static java.util.Iterator getIterator(java.lang.Object container)
                                      throws ReflectionException
Exposes an iterator over the contents of the container. Note that in many cases, an Iterator may only be used once and is then considered invalid. If you need to loop through the contents of the iterator multiple times, you will have to copy the contents of the iterator to some other structure, such as a java.util.List.

Parameters:
container - the container to iterate over
Returns:
an Iterator over the elements in the container
Throws:
ReflectionException - if container is null or
the Iterator could not be created for some reason

add

public static boolean add(java.lang.Object container,
                          java.lang.Object value)
                   throws ReflectionException
Adds a new value to the end of a container.

Parameters:
container - the container to which the value is to be added
value - the value to be added
Returns:
true if the container changed as a result of the call or
false, otherwise
Throws:
ReflectionException - if an error occurrs

get

public static java.lang.Object get(java.lang.Object container,
                                   int index)
                            throws ReflectionException
Gets the element at the specified index. Valid indexes range between 0 and one less than the container object's size, inclusive.

Parameters:
container - the container object
index - a number indiciating which element should be retrieved
Returns:
the object at the specified index
Throws:
ReflectionException - if container is null or
index is not a valid index for the given container object or
the object at the specified index could not be retrieved for some reason

newInstance

public static java.lang.Object newInstance(java.lang.Class clazz)
                                    throws ReflectionException
Creates a new instance of the given type.

Parameters:
clazz - the type for which we would like a new instance to be created
Throws:
ReflectionException - if an error occurrs

set

public static java.lang.Object set(java.lang.Object container,
                                   int index,
                                   java.lang.Object propertyValue)
                            throws ReflectionException
Sets the element at the specified index. Valid indexes range between 0 and one less than the container object's size, inclusive.

Parameters:
container - the container object
index - a number indiciating which element should be set
propertyValue - the value to be set
Returns:
the element previously at the specified position
Throws:
ReflectionException - if container is null or
index is not a valid index for the given container object or
the object at the specified index could not be set for some reason

getSize

public static int getSize(java.lang.Object object)
                   throws ReflectionException
Returns the number of elements contained in a given object. If the object is a bean, the number of properties is returned. If the object is a container, the number of elements in the container is returned.

Parameters:
object - the object
Returns:
the number of elements contained in the given object
Throws:
ReflectionException - if object is null or the number of elements in the object could not be determined


Copyright © 2004-2008.