org.apache.commons.betwixt
Class BeanProperty

java.lang.Object
  extended byorg.apache.commons.betwixt.BeanProperty

public class BeanProperty
extends java.lang.Object

Betwixt-centric view of a bean (or pseudo-bean) property. This object decouples the way that the (possibly pseudo) property introspection is performed from the results of that introspection.

Since:
0.5
Author:
Robert Burrell Donkin

Field Summary
private  Expression propertyExpression
          The Expression used to read values of this property (possibly null)
private  java.lang.String propertyName
          The bean name for the property (not null)
private  java.lang.Class propertyType
          The type of this property (not null)
private  Updater propertyUpdater
          The Updater used to write values of this property (possibly null)
 
Constructor Summary
BeanProperty(org.apache.commons.beanutils.DynaProperty dynaProperty)
          Constructs a BeanProperty from a DynaProperty
BeanProperty(java.beans.PropertyDescriptor descriptor)
          Constructs a BeanProperty from a PropertyDescriptor.
BeanProperty(java.lang.String propertyName, java.lang.Class propertyType, Expression propertyExpression, Updater propertyUpdater)
          Construct a BeanProperty.
 
Method Summary
private  void configureDescriptor(NodeDescriptor descriptor, IntrospectionConfiguration configuration)
          Configures descriptor (in the standard way).
private  ElementDescriptor createDescriptorForCollective(IntrospectionConfiguration configuration, Updater propertyUpdater, Expression propertyExpression)
          Creates an ElementDescriptor for a collective type property
private  ElementDescriptor createDescriptorForMap(IntrospectionConfiguration configuration, Expression propertyExpression)
          Creates an ElementDescriptor for an Map type property
private  NodeDescriptor createDescriptorForPrimitive(IntrospectionConfiguration configuration, Expression propertyExpression, Updater propertyUpdater)
          Creates a NodeDescriptor for a primitive type node
private  ElementDescriptor createDescriptorForStandard(Expression propertyExpression, Updater propertyUpdater, IntrospectionConfiguration configuration)
          Creates an ElementDescriptor for a standard property
 Descriptor createXMLDescriptor(IntrospectionConfiguration configuration)
          Create a XML descriptor from a bean one.
 Expression getPropertyExpression()
          Gets the expression used to read this property.
 java.lang.String getPropertyName()
          Gets the bean name for this property.
 java.lang.Class getPropertyType()
          Gets the type of this property.
 Updater getPropertyUpdater()
          Gets the updater used to write to this properyty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyName

private final java.lang.String propertyName
The bean name for the property (not null)


propertyType

private final java.lang.Class propertyType
The type of this property (not null)


propertyExpression

private Expression propertyExpression
The Expression used to read values of this property (possibly null)


propertyUpdater

private Updater propertyUpdater
The Updater used to write values of this property (possibly null)

Constructor Detail

BeanProperty

public BeanProperty(java.lang.String propertyName,
                    java.lang.Class propertyType,
                    Expression propertyExpression,
                    Updater propertyUpdater)
Construct a BeanProperty.

Parameters:
propertyName - not null
propertyType - not null
propertyExpression - the Expression used to read the property, null if the property is not readable
propertyUpdater - the Updater used to write the property, null if the property is not writable

BeanProperty

public BeanProperty(java.beans.PropertyDescriptor descriptor)
Constructs a BeanProperty from a PropertyDescriptor.

Parameters:
descriptor - not null

BeanProperty

public BeanProperty(org.apache.commons.beanutils.DynaProperty dynaProperty)
Constructs a BeanProperty from a DynaProperty

Parameters:
dynaProperty - not null
Method Detail

getPropertyName

public java.lang.String getPropertyName()
Gets the bean name for this property. Betwixt will map this to an xml name.

Returns:
the bean name for this property, not null

getPropertyType

public java.lang.Class getPropertyType()
Gets the type of this property.

Returns:
the property type, not null

getPropertyExpression

public Expression getPropertyExpression()
Gets the expression used to read this property.

Returns:
the expression to be used to read this property or null if this property is not readable.

getPropertyUpdater

public Updater getPropertyUpdater()
Gets the updater used to write to this properyty.

Returns:
the Updater to the used to write to this property or null if this property is not writable.

createXMLDescriptor

public Descriptor createXMLDescriptor(IntrospectionConfiguration configuration)
Create a XML descriptor from a bean one. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.

Parameters:
configuration - IntrospectionConfiguration, not null
Returns:
a correctly configured NodeDescriptor for the property

configureDescriptor

private void configureDescriptor(NodeDescriptor descriptor,
                                 IntrospectionConfiguration configuration)
Configures descriptor (in the standard way). This sets the common properties.

Parameters:
descriptor - Descriptor to map, not null
configuration - IntrospectionConfiguration, not null

createDescriptorForStandard

private ElementDescriptor createDescriptorForStandard(Expression propertyExpression,
                                                      Updater propertyUpdater,
                                                      IntrospectionConfiguration configuration)
Creates an ElementDescriptor for a standard property

Parameters:
propertyExpression -
propertyUpdater -
Returns:

createDescriptorForMap

private ElementDescriptor createDescriptorForMap(IntrospectionConfiguration configuration,
                                                 Expression propertyExpression)
Creates an ElementDescriptor for an Map type property

Parameters:
configuration -
propertyExpression -
Returns:

createDescriptorForCollective

private ElementDescriptor createDescriptorForCollective(IntrospectionConfiguration configuration,
                                                        Updater propertyUpdater,
                                                        Expression propertyExpression)
Creates an ElementDescriptor for a collective type property

Parameters:
configuration -
propertyExpression -
Returns:

createDescriptorForPrimitive

private NodeDescriptor createDescriptorForPrimitive(IntrospectionConfiguration configuration,
                                                    Expression propertyExpression,
                                                    Updater propertyUpdater)
Creates a NodeDescriptor for a primitive type node

Parameters:
configuration -
propertyExpression -
propertyUpdater -
Returns: