org.jbeans
Class NestedBeanProperty

java.lang.Object
  |
  +--org.jbeans.BaseBeanProperty
        |
        +--org.jbeans.DynamicNestedBeanProperty
              |
              +--org.jbeans.NestedBeanProperty
Direct Known Subclasses:
SynchronizedNestedBeanProperty

public class NestedBeanProperty
extends DynamicNestedBeanProperty

This class is used to store information about and handle getting and setting of both nested and local properties. This class functions very similarly its parent, DynamicNestedBeanProperty, except for one slight difference. This is that when this class is constructed, it takes a property name that contains the indexes to be used for the indexed properties in the nesting. For example, if we had a nesting such as:

getIndexed(1).getProperty2().getValue()

you would construct an instance of this class using the property String:

indexed[1].property2.value

This is an important disctinction and was added to the JBeans package because of speed issues and also because many applications could use this static concept for initialization and many other places. Adding in this class reduces the amount of work needed to parse the indices out of the property String and re-format the property String.

One important thing to remember is that after this class has been constructed, you can still use the getPropertyValue, getPropertyValue, setPropertyValue, and setPropertyValue methods from DynamicNestedBeanProperty.

Author:
Brian Pontarelli

Fields inherited from class org.jbeans.BaseBeanProperty
BAD_CONVERT, beanClass, conversionListeners, GET, POST_CONVERT, PRE_CONVERT, propertyListeners, propertyName, propertyType, SET
 
Constructor Summary
protected NestedBeanProperty()
          Default constructor that can be used by sub-classes that want to delay the initialization of the propertyName and beanClass or that do not use these members.
  NestedBeanProperty(String propertyName, Class beanClass)
          Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information).
  NestedBeanProperty(String propertyName, Class beanClass, boolean strict)
          Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information).
  NestedBeanProperty(String propertyName, String beanClass)
          Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information).
  NestedBeanProperty(String propertyName, String beanClass, boolean strict)
          Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information).
 
Method Summary
 Object getPropertyValue(Object bean)
          Returns the value of the local or nested property described by this instance.
protected  void initialize()
          Initializes all the members of this class by parsing out the propertyName String and creating the necessary BeanProperty class and everything else that might be needed
 void setPropertyValue(Object bean, Object value, boolean convert)
          Sets the local or nested property value described by this instance.
 
Methods inherited from class org.jbeans.DynamicNestedBeanProperty
getPropertyValue, getPropertyValue, getRootProperty, isStrict, setPropertyValue, setPropertyValue, setStrict
 
Methods inherited from class org.jbeans.BaseBeanProperty
addConversionListener, addPropertyListener, convertParameter, fireConversionEvent, firePropertyEvent, getBeanClass, getConversionListeners, getFullName, getPropertyListeners, getPropertyName, getPropertyType, hasConversionListeners, hasPropertyListeners, instantiate, removeConversionListener, removePropertyListener, setPropertyValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NestedBeanProperty

protected NestedBeanProperty()
Default constructor that can be used by sub-classes that want to delay the initialization of the propertyName and beanClass or that do not use these members. This constructor also calls the default constructor from the BaseBeanProperty super-class. This means that using this constructor will not make a template method call to #initialize().

NestedBeanProperty

public NestedBeanProperty(String propertyName,
                          Class beanClass)
                   throws BeanException
Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information). It also uses the class given to construct the method list.
Parameters:
propertyName - The name of the local or nested property
beanClass - The class to build the property for
Throws:
BeanException - If anything went wrong during the parsing of the property string or building of the property list

NestedBeanProperty

public NestedBeanProperty(String propertyName,
                          String beanClass)
                   throws BeanException
Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information). It also uses the given fully qualified name of the bean class and the propertyName to construct the method list.
Parameters:
propertyName - The name of the local or nested property
beanClass - The fully qualified name of the bean class to build the property for
Throws:
BeanException - If anything went wrong during the parsing of the property string or building of the property list

NestedBeanProperty

public NestedBeanProperty(String propertyName,
                          Class beanClass,
                          boolean strict)
                   throws BeanException
Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information). It also uses the class given to construct the method list.
Parameters:
propertyName - The name of the property or deep property String
beanClass - The class to build the property for
strict - Determines how this class handles cases when setting and retrieving property values where nested properties need to be auto generated because they are null
Throws:
BeanException - If anything went wrong during the parsing of the property string or building of the property list

NestedBeanProperty

public NestedBeanProperty(String propertyName,
                          String beanClass,
                          boolean strict)
                   throws BeanException
Constructs a new NestedBeanProperty that can be used to describe nested or local properties, depending on the value of the property string (see the class comment for more information). It also uses the given fully qualified name of the bean class and the propertyName to construct the method list.
Parameters:
propertyName - The name of the property or deep property String
beanClass - The fully qualified name of the bean class to build the property for
strict - Determines how this class handles cases when setting and retrieving property values where nested properties need to be auto generated because they are null
Throws:
BeanException - If anything went wrong during the parsing of the property string or building of the property list
Method Detail

initialize

protected void initialize()
                   throws BeanException
Initializes all the members of this class by parsing out the propertyName String and creating the necessary BeanProperty class and everything else that might be needed
Overrides:
initialize in class DynamicNestedBeanProperty
Throws:
BeanException - If there were any problems initializing this class

getPropertyValue

public Object getPropertyValue(Object bean)
                        throws BeanException
Returns the value of the local or nested property described by this instance.
Overrides:
getPropertyValue in class DynamicNestedBeanProperty
Parameters:
bean - The bean to retrieve the property on
Returns:
The value of the property
Throws:
BeanException - If there was an error getting the JavaBean property or the getter/is method threw a checked Exception or if strict is true and a null non-leaf property was encountered

setPropertyValue

public void setPropertyValue(Object bean,
                             Object value,
                             boolean convert)
                      throws BeanException
Sets the local or nested property value described by this instance. This method will optionally try to convert the value parameter to the correct type for the property.
Overrides:
setPropertyValue in class DynamicNestedBeanProperty
Parameters:
bean - The bean instance to set the property on
value - The value to set on the bean
convert - Determines whether or not the value should be converted to the correct parameter type for the property set method
Throws:
BeanException - If there was an error setting the JavaBean property or the setter method threw a checked Exception or if strict is true an a null non-leaf property was encountered