org.jbeans
Class IndexedBeanProperty

java.lang.Object
  |
  +--org.jbeans.BaseBeanProperty
        |
        +--org.jbeans.BeanProperty
              |
              +--org.jbeans.IndexedBeanProperty
Direct Known Subclasses:
SynchronizedIndexedBeanProperty

public class IndexedBeanProperty
extends BeanProperty

This class is used to access an indexed JavaBean property. Normal indexed JavaBean properties take a single int parameter, in addition to the value parameter for setters, that indicates the index into an array or collection of values.

Author:
Brian Pontarelli

Fields inherited from class org.jbeans.BeanProperty
read, write
 
Fields inherited from class org.jbeans.BaseBeanProperty
BAD_CONVERT, beanClass, conversionListeners, GET, POST_CONVERT, PRE_CONVERT, propertyListeners, propertyName, propertyType, SET
 
Constructor Summary
protected IndexedBeanProperty()
          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.
  IndexedBeanProperty(String propertyName, Class beanClass)
          Constructs a new indexed bean property using the property name and bean class given.
  IndexedBeanProperty(String propertyName, String beanClass)
          Constructs a new indexed bean property using the property name and fully qualified name of the bean class given.
 
Method Summary
 Object getPropertyValue(Object bean)
          This method is not implemented and will throw an exception
 Object getPropertyValue(Object bean, int index)
          Returns the value of the indexed JavaBean property at the given index
protected  void initialize()
          Initializes the bean property by finding the read and write methods and setting up the propertyType for this BeanProperty.
 void setPropertyValue(Object bean, int index, Object value)
          Sets the value of the indexed JavaBean property at the given index with the given value.
 void setPropertyValue(Object bean, int index, Object value, boolean convert)
          Sets the value of the indexed JavaBean property at the given index with the given value
 void setPropertyValue(Object bean, Object value, boolean convert)
          This method is not implemented and will throw an exception
 
Methods inherited from class org.jbeans.BeanProperty
getBeanClass, getReadMethod, getWriteMethod
 
Methods inherited from class org.jbeans.BaseBeanProperty
addConversionListener, addPropertyListener, convertParameter, fireConversionEvent, firePropertyEvent, 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

IndexedBeanProperty

protected IndexedBeanProperty()
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().

IndexedBeanProperty

public IndexedBeanProperty(String propertyName,
                           Class beanClass)
                    throws BeanException
Constructs a new indexed bean property using the property name and bean class given.

If the bean class does not have a write method (set method) than the property is considered read-only. The bean class MUST have a read method (get method) or this method will throw and exception. This method calls the super-class constructor with the same signature.

Parameters:
propertyName - The name of the indexed JavaBean property
beanClass - The Class object used to find the read and write methods for the indexed JavaBean property
Throws:
BeanException - If the property is invalid or does not exist in the bean class given

IndexedBeanProperty

public IndexedBeanProperty(String propertyName,
                           String beanClass)
                    throws BeanException
Constructs a new indexed bean property using the property name and fully qualified name of the bean class given.

If the bean class does not have a write method (set method) than the property is considered read-only. The bean class MUST have a read method (get method) or this method will throw and exception. This method calls the super-class constructor with the same signature.

Parameters:
propertyName - The name of the indexed JavaBean property
beanClass - The fully qualified name of the bean Class object used to find the read and write methods for the indexed Java bean property
Throws:
BeanException - If the property is invalid or does not exist in the bean class given
Method Detail

initialize

protected void initialize()
                   throws BeanException
Initializes the bean property by finding the read and write methods and setting up the propertyType for this BeanProperty.
Overrides:
initialize in class BeanProperty
Throws:
BeanException - If the bean class does not contain the property

getPropertyValue

public Object getPropertyValue(Object bean,
                               int index)
                        throws BeanException
Returns the value of the indexed JavaBean property at the given index
Parameters:
bean - The instance of the JavaBean to retrieve the indexed property from.
index - The index of the JavaBean property to retrieve, this is also the parameter to the getter
Throws:
BeanException - If there was an error getting the JavaBean property or the getter/is method threw a checked Exception

getPropertyValue

public Object getPropertyValue(Object bean)
                        throws BeanException
This method is not implemented and will throw an exception
Overrides:
getPropertyValue in class BeanProperty
Following copied from class: org.jbeans.BeanProperty
Parameters:
bean - The instance of the Java bean to retrieve the property from
Throws:
BeanException - If there was an error getting the Java bean property or the getter/is method threw a checked Exception

setPropertyValue

public void setPropertyValue(Object bean,
                             int index,
                             Object value,
                             boolean convert)
                      throws BeanException,
                             TypeConversionException
Sets the value of the indexed JavaBean property at the given index with the given value
Parameters:
bean - The instance of the JavaBean to set the indexed property on
index - The index to set to value of
value - The value to set the indexed property to
convert - Determines whether or not value should be converted to the type that the setter requires or not
Throws:
BeanException - If there was an error setting the JavaBean property or the setter method threw a checked Exception
TypeConversionException - If there was a problem auto-converting the property value

setPropertyValue

public void setPropertyValue(Object bean,
                             int index,
                             Object value)
                      throws BeanException
Sets the value of the indexed JavaBean property at the given index with the given value. This value is set without doing any conversion. This method is the same as calling the other setPropertyValue method with the convert parameter set to false
Parameters:
bean - The instance of the JavaBean to set the indexed property on
index - The index to set to value of
value - The value to set the indexed property to
Throws:
BeanException - If there was an error setting the JavaBean property or the setter method threw a checked Exception

setPropertyValue

public void setPropertyValue(Object bean,
                             Object value,
                             boolean convert)
                      throws BeanException
This method is not implemented and will throw an exception
Overrides:
setPropertyValue in class BeanProperty
Following copied from class: org.jbeans.BeanProperty
Parameters:
bean - The instance of the Java bean to set the property on
value - The value to set the property to
convert - Determines whether or not value should be converted to the type that the setter requires or not
Throws:
BeanException - If there was an error setting the Java bean property or the setter method threw a checked Exception
TypeConversionException - If there was a problem auto-converting the property value