raccoon.core.bean.descriptor
Class BeanProperty

java.lang.Object
  extended by raccoon.core.bean.descriptor.BeanProperty
All Implemented Interfaces:
IBeanProperty

public class BeanProperty
extends java.lang.Object
implements IBeanProperty

The default property descriptor for the Raccoon Framework.

The are two different types of bean properties:

  1. The standard property that has a getter and setter. For example:
  2. The extended property that has a getter, setter and adder. For example:

The extended property is feature that is required in every Raccoon compliant bean.

Since:
Raccoon v0.1, refactored in Raccoon v0.4, v0.5 & v0.8
Version:
$Id: BeanProperty.java,v 1.1 2004/08/08 20:19:16 crouvrais Exp $
Author:
Cedric ROUVRAIS

Constructor Summary
BeanProperty(java.lang.reflect.Method pGetMethod, java.lang.reflect.Method pSetMethod)
          Intialises this instance and links it to a method.
BeanProperty(java.lang.reflect.Method pGetMethod, java.lang.reflect.Method pSetMethod, java.lang.reflect.Method pAddMethod)
          Intialises this instance and links it to a method
 
Method Summary
 java.lang.reflect.Method adder()
          Returns the adder for this bean, used to add an element to a collection of a java bean.
 void append(java.lang.Object pInstance, java.lang.Object pData)
          Adds an element to this object, this object being a collection!
 java.lang.Class beanType()
          Returns the type of class that this method handles.
 java.lang.Class collectionType()
          Returns the atomic type of the collection, a call to this method is valid only if isCollectionProperty returns true
 java.lang.reflect.Method getter()
          Returns the getter for this bean, used to invoke the getter of a java bean.
 boolean isCastorProperty()
          Checks if this property is a valid Castor property.
 boolean isCollectionProperty()
          Checks if this class is a Collection defined by the Raccoon project.
 boolean isRaccoonProperty()
          Checks if this property is a valid Raccoon property.
 java.lang.String lPropertyName()
          Extracts the name of this property.
 java.lang.Object read(java.lang.Object pInstance)
          Reads the value of this property from a given object instance.
 java.lang.reflect.Method setter()
          Returns the setter for this bean, used to invoke the setter of a java bean.
 java.lang.String uPropertyName()
          Extracts the name of this property
 void write(java.lang.Object pInstance, java.lang.Object pData)
          Sets the value of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanProperty

public BeanProperty(java.lang.reflect.Method pGetMethod,
                    java.lang.reflect.Method pSetMethod)
             throws IntrospectionException
Intialises this instance and links it to a method.

Parameters:
pGetMethod - the get method to which this instance is to be attached.
pSetMethod - the set method to which this instance is to be attached.
Throws:
IntrospectionException - if parseMethods() fails

BeanProperty

public BeanProperty(java.lang.reflect.Method pGetMethod,
                    java.lang.reflect.Method pSetMethod,
                    java.lang.reflect.Method pAddMethod)
             throws IntrospectionException
Intialises this instance and links it to a method

Parameters:
pGetMethod - the get method to which this instance is to be attached.
pSetMethod - the set method to which this instance is to be attached.
pAddMethod - the add method to which this instance is to be attached.
Throws:
IntrospectionException - if the get/set/add method signatures don't match (i.e. differents types)
Method Detail

isCastorProperty

public boolean isCastorProperty()
Checks if this property is a valid Castor property. A valid bean method must meet the following criteria:

A valid example is:

A invalid example is:

Another invalid example is:

Specified by:
isCastorProperty in interface IBeanProperty
Returns:
true if this is a valid Castor property.

isRaccoonProperty

public boolean isRaccoonProperty()
Checks if this property is a valid Raccoon property. A valid bean method must all the criteria of a valid Castor Bean Method, plus if it is Collection property then an addElement method must exist.

Specified by:
isRaccoonProperty in interface IBeanProperty
Returns:
true if this is a valid Raccoon property.

isCollectionProperty

public boolean isCollectionProperty()
Checks if this class is a Collection defined by the Raccoon project.

A Collection meets the following criteria:

Specified by:
isCollectionProperty in interface IBeanProperty
Returns:
true if this method is a collection.

lPropertyName

public java.lang.String lPropertyName()
Extracts the name of this property.

Specified by:
lPropertyName in interface IBeanProperty
Returns:
the bean name, first letter is lower case.

uPropertyName

public java.lang.String uPropertyName()
Extracts the name of this property

Specified by:
uPropertyName in interface IBeanProperty
Returns:
the property name, first letter is upper case.

beanType

public java.lang.Class beanType()
Returns the type of class that this method handles.
For example if beanType returns String.class then the following methods are available:
If beanType returns Vector.class then the following methods are available:
Or:
Where the type of the Object is defined by the method collectionType()

Specified by:
beanType in interface IBeanProperty
Returns:
the type of the bean

collectionType

public java.lang.Class collectionType()
Returns the atomic type of the collection, a call to this method is valid only if isCollectionProperty returns true

Specified by:
collectionType in interface IBeanProperty
Returns:
type of atomic element.

getter

public java.lang.reflect.Method getter()
Returns the getter for this bean, used to invoke the getter of a java bean. The return type of this method is provided by the method beanType().

Specified by:
getter in interface IBeanProperty
Returns:
the getter for this class.

setter

public java.lang.reflect.Method setter()
Returns the setter for this bean, used to invoke the setter of a java bean. This method takes a single parameter, this parameter must be an instance of the class provided by the method beanType().

Specified by:
setter in interface IBeanProperty
Returns:
the setter for this class.

adder

public java.lang.reflect.Method adder()
Returns the adder for this bean, used to add an element to a collection of a java bean. This method takes a single parameter, this parameter must be an instance of the class provided by the method collectionType().

Specified by:
adder in interface IBeanProperty
Returns:
the adder for this class.

read

public java.lang.Object read(java.lang.Object pInstance)
Reads the value of this property from a given object instance.

Specified by:
read in interface IBeanProperty
Parameters:
pInstance - the instance of the object on which the getter will be invoked.
Returns:
the object returned by the invocation of the getter, null if the invocation failed.

write

public void write(java.lang.Object pInstance,
                  java.lang.Object pData)
           throws RaccoonException
Sets the value of this object

Specified by:
write in interface IBeanProperty
Parameters:
pInstance - the instance of the object on which the setter will be invoked.
pData - the data that passed on to the setter that will be invoked.
Throws:
RaccoonException - if the setter and object pData don't match.

append

public void append(java.lang.Object pInstance,
                   java.lang.Object pData)
            throws RaccoonException
Adds an element to this object, this object being a collection!

Specified by:
append in interface IBeanProperty
Parameters:
pInstance - the instance of the object on which the adder will be invoked.
pData - the data that passed on to the adder that will be invoked.
Throws:
RaccoonException - if the adder and object pData don't match.


Copyright null null. All Rights Reserved.