raccoon.core.bean.descriptor
Class BeanDescriptor

java.lang.Object
  extended by raccoon.core.bean.descriptor.BeanDescriptor
All Implemented Interfaces:
IBeanDescriptor

public class BeanDescriptor
extends java.lang.Object
implements IBeanDescriptor

Contains all the valid property methods linked to a class.

The information contained within this instance is relative to a java bean that complies either to the Raccoon or Castor specification of a java bean.

This class complies to that specification and so do the samples provided in raccoon.samples.beans.* (see tutorial)

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

Constructor Summary
BeanDescriptor()
           
 
Method Summary
 void addProperty(IBeanProperty pProperty)
          Adds a new bean property to the current list of bean properties
 int analyzeProperties()
          Parses all the properties assigned to this instance in order to set correctly the fields.
 boolean containsProperty(java.lang.String pPropertyName)
          Determines whether or not the property is contained by this instance.
 java.lang.String getClassName()
          The class that this instance bears information on.
 IBeanProperty getProperty(java.lang.String pPropertyName)
          Convenience method for retrieving a specific property descriptor.
 boolean hasDefaultConstructor()
          Is the associated java bean dynamically instanciable.
 boolean isCastorBean()
          Convenience method for determining the type of bean this instance is.
 boolean isParsed()
          Have the methods assigned to this instance been analyzed to determine the type of bean.
 boolean isRaccoonBean()
          Convenience method for determining the type of bean this instance is.
 java.util.Iterator<IBeanProperty> properties()
          The list of avaible properties of this java bean instance.
 java.util.Iterator propertyNames()
          The names of the available java bean properties within this BeanDescriptor.
 void setClassName(java.lang.String pClassName)
          Defines the name of the class that this instance represents.
 void setDefaultConstructor(boolean pHasDefaultConstructor)
          Sets the property related to the existence of a default constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanDescriptor

public BeanDescriptor()
Method Detail

getClassName

public java.lang.String getClassName()
The class that this instance bears information on.

Specified by:
getClassName in interface IBeanDescriptor
Returns:
the class name
See Also:
setClassName(String)

setClassName

public void setClassName(java.lang.String pClassName)
Defines the name of the class that this instance represents.
For example if this instance represents a Person class, then pClassName is worth Person.class.getName()

Specified by:
setClassName in interface IBeanDescriptor
Parameters:
pClassName - the class name contained in this object
See Also:
isParsed()

addProperty

public void addProperty(IBeanProperty pProperty)
Adds a new bean property to the current list of bean properties

Specified by:
addProperty in interface IBeanDescriptor
Parameters:
pProperty - the bean property to add.
See Also:
isParsed()

getProperty

public IBeanProperty getProperty(java.lang.String pPropertyName)
                          throws RaccoonException
Convenience method for retrieving a specific property descriptor. The property descriptor is stored under the index: IBeanProperty.lPropertyName()

Specified by:
getProperty in interface IBeanDescriptor
Parameters:
pPropertyName - the lower bean name of the property (for example: nameOfPerson and not NameOfPerson
Returns:
the property descriptor instance corresponding to the given logical name.
Throws:
RaccoonException - if the property wasn't found.
See Also:
containsProperty(String)

propertyNames

public java.util.Iterator propertyNames()
The names of the available java bean properties within this BeanDescriptor.

Specified by:
propertyNames in interface IBeanDescriptor
Returns:
an enumeration of String which are the java property names of the given java bean

properties

public java.util.Iterator<IBeanProperty> properties()
                                             throws IntrospectionException
The list of avaible properties of this java bean instance.

Specified by:
properties in interface IBeanDescriptor
Returns:
an enumeration of IBeanProperty elements
Throws:
IntrospectionException - if the method analyzeProperties() wasn't called previously.

containsProperty

public boolean containsProperty(java.lang.String pPropertyName)
Determines whether or not the property is contained by this instance.

Specified by:
containsProperty in interface IBeanDescriptor
Parameters:
pPropertyName - the lower bean name of the property (for example: nameOfPerson and not NameOfPerson
Returns:
true if there is a property descriptor for the specified property.

isParsed

public boolean isParsed()
Have the methods assigned to this instance been analyzed to determine the type of bean.

It is possible to add methods (properties) to this instance as long as this method returns false. Once it returns true, it means that the list of methods have been analyzed to determine the type of bean this instance represents. It is then no longer possible to change the data contained within this instance.

Specified by:
isParsed in interface IBeanDescriptor
Returns:
true if the properties have been analyzed (the class becomes read only)

isCastorBean

public boolean isCastorBean()
Convenience method for determining the type of bean this instance is. Valid only if isParsed() returns true.

Specified by:
isCastorBean in interface IBeanDescriptor
Returns:
the compliance or not to the Castor spec of a bean.

isRaccoonBean

public boolean isRaccoonBean()
Convenience method for determining the type of bean this instance is. Valid only if isParsed() returns true.

Specified by:
isRaccoonBean in interface IBeanDescriptor
Returns:
the compliance or not to the Raccoon spec of a bean.

analyzeProperties

public int analyzeProperties()
                      throws IntrospectionException
Parses all the properties assigned to this instance in order to set correctly the fields. isAtomic, isCastorBean and isRaccoonBean

Specified by:
analyzeProperties in interface IBeanDescriptor
Returns:
the number of properties attached to this instance.
Throws:
IntrospectionException - if some props wheren't set or if the component is in error

hasDefaultConstructor

public boolean hasDefaultConstructor()
Is the associated java bean dynamically instanciable.

Specified by:
hasDefaultConstructor in interface IBeanDescriptor
Returns:
true if there is a default constructor.

setDefaultConstructor

public void setDefaultConstructor(boolean pHasDefaultConstructor)
Sets the property related to the existence of a default constructor.

Parameters:
pHasDefaultConstructor - true if this bean has a default constructor.


Copyright null null. All Rights Reserved.