javax.rad.type.bean
Class BeanType

java.lang.Object
  extended by javax.rad.type.AbstractType<T>
      extended by javax.rad.type.bean.AbstractBeanType<Object>
          extended by javax.rad.type.bean.BeanType
All Implemented Interfaces:
IBeanType<Object>, IType<Object>

public class BeanType
extends AbstractBeanType<Object>

The BeanType is a wrapper for dynamic/generic beans and POJOs. With this class you can set/get properties without get/set methods.


Field Summary
protected  Class beanClass
          The bean class.
protected  Method[] getMethods
          The get methods.
protected  Method[] setMethods
          The set methods.
 
Fields inherited from class javax.rad.type.bean.AbstractBeanType
className, propertyDefinitions, propertyNames
 
Fields inherited from interface javax.rad.type.IType
UNKNOWN_TYPE
 
Constructor Summary
  BeanType()
          Constructs a new BeanType.
protected BeanType(Class pBeanClass)
          Constructs a new BeanType from a POJO.
  BeanType(PropertyDefinition[] pPropertyDefinitions)
          Constructs a new BeanType with given PropertyDefinitions.
  BeanType(String[] pPropertyNames)
          Constructs a new BeanType with given property names.
  BeanType(String pClassName, PropertyDefinition[] pPropertyDefinitions)
          Constructs a new BeanType with given class name and PropertyDefinitions.
  BeanType(String pClassName, String[] pPropertyNames)
          Constructs a new BeanType with given class name and property list.
 
Method Summary
 Object clone(Object pObject)
          Clones a bean.
 int compareTo(Object object1, Object object2)
          Compares two objects.
protected  PropertyDefinition createPropertyDefinition(String pPropertyName, Class pPropertyType)
          Creates the PropertyDefinition.
 Object get(Object pObject, int pPropertyIndex)
          Gets the value for a bean.
 Object get(Object pObject, String pPropertyName)
          Gets a value from a bean.
static BeanType getBeanType(Class pBeanClass)
          Gets a singleton instance of BeanType for the given bean class.
static BeanType getBeanType(Object pObject)
          Gets the BeanType for the given bean.
 Method getGetMethod(String pPropertyName)
          Gets the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.
 Method getSetMethod(String pPropertyName)
          Gets the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.
 Class getTypeClass()
          Returns the class used by this type.
 Object newInstance()
          Creates a new instance of the bean.
 void put(Object pObject, int pPropertyIndex, Object pValue)
          Sets the value for a bean.
 void put(Object pObject, String pPropertyName, Object pValue)
          Sets the value for a bean.
 Object valueOf(Object pObject)
          Converts the object to an Object which is an instance of type class.
 
Methods inherited from class javax.rad.type.bean.AbstractBeanType
addPropertyDefinition, addPropertyDefinition, createPropertyDefinition, createPropertyDefinitions, equals, getClassName, getPropertyCount, getPropertyDefinition, getPropertyDefinition, getPropertyIndex, getPropertyNames, hashCode, removeAllPropertyDefinitions
 
Methods inherited from class javax.rad.type.AbstractType
equals, getTypeFromClass, getTypeFromObject, hashCode, registerType, toString, validatedValueOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beanClass

protected transient Class beanClass
The bean class.


getMethods

protected transient Method[] getMethods
The get methods.


setMethods

protected transient Method[] setMethods
The set methods.

Constructor Detail

BeanType

public BeanType()
Constructs a new BeanType.


BeanType

public BeanType(String[] pPropertyNames)
Constructs a new BeanType with given property names.

Parameters:
pPropertyNames - the bean properties.

BeanType

public BeanType(String pClassName,
                String[] pPropertyNames)
Constructs a new BeanType with given class name and property list.

Parameters:
pClassName - the class name.
pPropertyNames - the bean properties.

BeanType

public BeanType(PropertyDefinition[] pPropertyDefinitions)
Constructs a new BeanType with given PropertyDefinitions.

Parameters:
pPropertyDefinitions - the bean properties.

BeanType

public BeanType(String pClassName,
                PropertyDefinition[] pPropertyDefinitions)
Constructs a new BeanType with given class name and PropertyDefinitions.

Parameters:
pClassName - the class name.
pPropertyDefinitions - the bean properties.

BeanType

protected BeanType(Class pBeanClass)
Constructs a new BeanType from a POJO.

Parameters:
pBeanClass - the bean class.
Method Detail

getTypeClass

public Class getTypeClass()
Returns the class used by this type.

Returns:
the class used by this type.

valueOf

public Object valueOf(Object pObject)
Converts the object to an Object which is an instance of type class.

Specified by:
valueOf in interface IType<Object>
Overrides:
valueOf in class AbstractType<Object>
Parameters:
pObject - the Object to convert
Returns:
the Object which is an instance of type class.

compareTo

public int compareTo(Object object1,
                     Object object2)
Compares two objects. If the first object is smaller than the second object a value < 0 is returned. If the two objects are equal than 0 is returned. If the first object is greater than the second object a value > 0 is returned.

Parameters:
object1 - the first object.
object2 - the second object.
Returns:
< 0 if pObject1 is smaller, 0 if equal and > 0 if it is greater then pObject2

getBeanType

public static BeanType getBeanType(Class pBeanClass)
Gets a singleton instance of BeanType for the given bean class.

Parameters:
pBeanClass - the POJO class.
Returns:
the POJO bean type.

getBeanType

public static BeanType getBeanType(Object pObject)
Gets the BeanType for the given bean.

Parameters:
pObject - the bean.
Returns:
the bean type.

createPropertyDefinition

protected PropertyDefinition createPropertyDefinition(String pPropertyName,
                                                      Class pPropertyType)
Creates the PropertyDefinition.

Parameters:
pPropertyName - the property name.
pPropertyType - the property type.
Returns:
the PropertyDefinition

newInstance

public Object newInstance()
Creates a new instance of the bean. If it is possible, the pojo is returned. If not, a instance of Bean is returned.

Returns:
the pojo or a bean

get

public Object get(Object pObject,
                  int pPropertyIndex)
Gets the value for a bean.

Parameters:
pObject - the bean.
pPropertyIndex - the property index.
Returns:
pValue the value of the property index.

put

public void put(Object pObject,
                int pPropertyIndex,
                Object pValue)
Sets the value for a bean.

Parameters:
pObject - the bean.
pPropertyIndex - the property index.
pValue - the value of the property index.

get

public Object get(Object pObject,
                  String pPropertyName)
Gets a value from a bean.

Parameters:
pObject - the bean.
pPropertyName - the property name.
Returns:
the value of the property name.

put

public void put(Object pObject,
                String pPropertyName,
                Object pValue)
Sets the value for a bean.

Parameters:
pObject - the bean.
pPropertyName - the property name.
pValue - the value of the property name.

getGetMethod

public Method getGetMethod(String pPropertyName)
Gets the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.

Parameters:
pPropertyName - the property name.
Returns:
the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.

getSetMethod

public Method getSetMethod(String pPropertyName)
Gets the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.

Parameters:
pPropertyName - the property name.
Returns:
the method for getting a value, in case of a class based BeanType and the property exists, null otherwise.

clone

public Object clone(Object pObject)
Clones a bean.

Parameters:
pObject - the bean.
Returns:
the cloned bean.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.