atg.beans
Class BeanPropertyMapper

java.lang.Object
  extended by atg.beans.BeanPropertyMapper
All Implemented Interfaces:
atg.beans.AnnotationDynamicPropertyMapper, DynamicPropertyMapper

public class BeanPropertyMapper
extends java.lang.Object
implements DynamicPropertyMapper, atg.beans.AnnotationDynamicPropertyMapper

Implementation of DynamicPropertyMapper that works off of a bean's regular compile-time properties as discovered by introspection. Is used to cache a set of property descriptors for non-dynamic beans for efficient retrieval, but can also be useful in the implementation of DynamicPropertyMappers that expose a combination of dynamic and compile-time properties.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Constructor Summary
BeanPropertyMapper(java.lang.Class pClass)
           
 
Method Summary
 java.lang.annotation.Annotation getAnnotation(java.lang.Object pBean, java.lang.String pPropertyName, java.lang.Class pAnnotationClass)
          Gets a particular type of annotation, if it exists, for a property on a bean.
 java.util.Set<java.lang.annotation.Annotation> getAnnotations(java.lang.Object pBean, java.lang.String pPropertyName)
          Gets all of the annotations for a property on a bean.
 DynamicBeanInfo getBeanInfo(java.lang.Object pBean)
          Gets a DynamicBeanInfo that describes the given dynamic bean.
 java.util.Set<java.lang.String> getPropertiesWithAnnotation(java.lang.Object pBean, java.lang.Class pAnnotationClass)
          Gets a set of property names that have a particular annotation.
protected  java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String pPropertyName)
          Get a PropertyDescriptor for some property, in a case-insensitive matter.
 java.lang.Object getPropertyValue(java.lang.Object pBean, java.lang.String pPropertyName)
          Gets the value of the dynamic property from the specified object.
 java.lang.String getPropertyWithAnnotation(java.lang.Object pBean, java.lang.Class pAnnotationClass)
          Gets a property name for a property on a bean that has a particular annotation.
static java.lang.reflect.Method getPublicMethod(java.lang.reflect.Method pMethod)
          Returns a publicly-accessible version of the given method, by searching for a public declaring class.
protected  boolean isBeanProperty(java.lang.String pPropertyName)
          Use this method in a subclass to determine whether or not the specified property name is a regular bean property (i.e.
 void setPropertyValue(java.lang.Object pBean, java.lang.String pPropertyName, java.lang.Object pValue)
          Sets the value of the dynamic property from the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

BeanPropertyMapper

public BeanPropertyMapper(java.lang.Class pClass)
Method Detail

isBeanProperty

protected boolean isBeanProperty(java.lang.String pPropertyName)
Use this method in a subclass to determine whether or not the specified property name is a regular bean property (i.e. not a dynamic property).

Returns:
true if the name passed in is a bean property.

getPropertyDescriptor

protected java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String pPropertyName)
Get a PropertyDescriptor for some property, in a case-insensitive matter. We store properties initially under their lowercased name and then cache the same properties under equivalent, alternate names as they crop up.

Parameters:
pPropertyName - the name of the property
Returns:
the sought-after PropertyDescriptor, or null if not found

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object pBean,
                                         java.lang.String pPropertyName)
                                  throws PropertyNotFoundException
Gets the value of the dynamic property from the specified object.

Specified by:
getPropertyValue in interface DynamicPropertyMapper
Throws:
PropertyNotFoundException

setPropertyValue

public void setPropertyValue(java.lang.Object pBean,
                             java.lang.String pPropertyName,
                             java.lang.Object pValue)
                      throws PropertyNotFoundException
Sets the value of the dynamic property from the specified object.

Specified by:
setPropertyValue in interface DynamicPropertyMapper
Throws:
PropertyNotFoundException

getBeanInfo

public DynamicBeanInfo getBeanInfo(java.lang.Object pBean)
                            throws java.beans.IntrospectionException
Gets a DynamicBeanInfo that describes the given dynamic bean.

Specified by:
getBeanInfo in interface DynamicPropertyMapper
Returns:
the DynamicBeanInfo describing the bean.
Throws:
java.beans.IntrospectionException - if no information is available.

getPublicMethod

public static java.lang.reflect.Method getPublicMethod(java.lang.reflect.Method pMethod)
Returns a publicly-accessible version of the given method, by searching for a public declaring class.


getAnnotations

public java.util.Set<java.lang.annotation.Annotation> getAnnotations(java.lang.Object pBean,
                                                                     java.lang.String pPropertyName)
                                                              throws java.beans.IntrospectionException
Gets all of the annotations for a property on a bean.

Specified by:
getAnnotations in interface atg.beans.AnnotationDynamicPropertyMapper
Parameters:
pBean - The object
pPropertyName - The property name
Returns:
A set of all of the annotations for this property
Throws:
java.beans.IntrospectionException - Thrown if there is a problem retrieving the annotations from the class

getAnnotation

public java.lang.annotation.Annotation getAnnotation(java.lang.Object pBean,
                                                     java.lang.String pPropertyName,
                                                     java.lang.Class pAnnotationClass)
                                              throws java.beans.IntrospectionException
Gets a particular type of annotation, if it exists, for a property on a bean.

Specified by:
getAnnotation in interface atg.beans.AnnotationDynamicPropertyMapper
Parameters:
pBean - The object
pPropertyName - The property name
pAnnotationClass - The type of annotation
Returns:
The annotation if it exists, null otherwise.
Throws:
java.beans.IntrospectionException - Thrown if there is a problem retrieving the annotation from the class

getPropertyWithAnnotation

public java.lang.String getPropertyWithAnnotation(java.lang.Object pBean,
                                                  java.lang.Class pAnnotationClass)
                                           throws java.beans.IntrospectionException
Gets a property name for a property on a bean that has a particular annotation.

Specified by:
getPropertyWithAnnotation in interface atg.beans.AnnotationDynamicPropertyMapper
Parameters:
pBean - The object
pAnnotationClass - The type of annotation
Returns:
The property name if one exists with the annotation, null otherwise.
Throws:
java.beans.IntrospectionException - Thrown if there is a problem retrieving the annotation from the class

getPropertiesWithAnnotation

public java.util.Set<java.lang.String> getPropertiesWithAnnotation(java.lang.Object pBean,
                                                                   java.lang.Class pAnnotationClass)
                                                            throws java.beans.IntrospectionException
Gets a set of property names that have a particular annotation.

Specified by:
getPropertiesWithAnnotation in interface atg.beans.AnnotationDynamicPropertyMapper
Parameters:
pBean - The object
pAnnotationClass - The type of annotation
Returns:
The set of property names, if any exist, with the annotation, null otherwise.
Throws:
java.beans.IntrospectionException - Thrown if there is a problem retrieving the annotation from the class