Class BeanPropertyDescriptor

  • Direct Known Subclasses:
    FieldPropertyDescriptor

    public class BeanPropertyDescriptor
    extends java.lang.Object
    This class represents a field/property in a value type (a class with either bean-style getters/setters or public fields). It is essentially a thin wrapper around the PropertyDescriptor from the JavaBean utilities. We wrap it with this class so that we can create the subclass FieldPropertyDescriptor and access public fields (who wouldn't have PropertyDescriptors normally) via the same interface. There are also some interesting tricks where indexed properties are concerned, mostly involving the fact that we manage the arrays here rather than relying on the value type class to do it itself.
    Author:
    Rich Scheuerle , Glen Daniels (gdaniels@apache.org)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.apache.commons.logging.Log log  
      protected java.beans.PropertyDescriptor myPD  
      protected static java.lang.Object[] noArgs  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BeanPropertyDescriptor()
      Protected constructor for use by our children
        BeanPropertyDescriptor​(java.beans.PropertyDescriptor pd)
      Constructor (takes a PropertyDescriptor)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object get​(java.lang.Object obj)
      Get the property value
      java.lang.Object get​(java.lang.Object obj, int i)
      Get an indexed property
      java.lang.Class getActualType()  
      java.lang.String getName()
      Get our property name.
      java.lang.Class getType()
      Get the type of a property
      protected void growArrayToSize​(java.lang.Object obj, java.lang.Class componentType, int i)
      Grow the array
      boolean isArray()
      Query if property is an array (excluded byte[]).
      boolean isIndexed()
      Query if property is indexed
      boolean isIndexedOrArray()
      Query if property is indexed or if it' an array.
      boolean isReadable()
      Query if property is readable
      boolean isWriteable()
      Query if property is writeable
      void set​(java.lang.Object obj, int i, java.lang.Object newValue)
      Set an indexed property value
      void set​(java.lang.Object obj, java.lang.Object newValue)
      Set the property value
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        protected static org.apache.commons.logging.Log log
      • myPD

        protected java.beans.PropertyDescriptor myPD
      • noArgs

        protected static final java.lang.Object[] noArgs
    • Constructor Detail

      • BeanPropertyDescriptor

        public BeanPropertyDescriptor​(java.beans.PropertyDescriptor pd)
        Constructor (takes a PropertyDescriptor)
        Parameters:
        pd -
      • BeanPropertyDescriptor

        protected BeanPropertyDescriptor()
        Protected constructor for use by our children
    • Method Detail

      • getName

        public java.lang.String getName()
        Get our property name.
      • isReadable

        public boolean isReadable()
        Query if property is readable
        Returns:
        true if readable
      • isWriteable

        public boolean isWriteable()
        Query if property is writeable
        Returns:
        true if writeable
      • isIndexed

        public boolean isIndexed()
        Query if property is indexed
        Returns:
        true if indexed methods exist
      • isIndexedOrArray

        public boolean isIndexedOrArray()
        Query if property is indexed or if it' an array.
        Returns:
        true if indexed methods exist or if it's an array
      • isArray

        public boolean isArray()
        Query if property is an array (excluded byte[]).
        Returns:
        true if it's an array (excluded byte[])
      • get

        public java.lang.Object get​(java.lang.Object obj)
                             throws java.lang.reflect.InvocationTargetException,
                                    java.lang.IllegalAccessException
        Get the property value
        Parameters:
        obj - is the object
        Returns:
        the entire propery value
        Throws:
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
      • set

        public void set​(java.lang.Object obj,
                        java.lang.Object newValue)
                 throws java.lang.reflect.InvocationTargetException,
                        java.lang.IllegalAccessException
        Set the property value
        Parameters:
        obj - is the object
        newValue - is the new value
        Throws:
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
      • get

        public java.lang.Object get​(java.lang.Object obj,
                                    int i)
                             throws java.lang.reflect.InvocationTargetException,
                                    java.lang.IllegalAccessException
        Get an indexed property
        Parameters:
        obj - is the object
        i - the index
        Returns:
        the object at the indicated index
        Throws:
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
      • set

        public void set​(java.lang.Object obj,
                        int i,
                        java.lang.Object newValue)
                 throws java.lang.reflect.InvocationTargetException,
                        java.lang.IllegalAccessException
        Set an indexed property value
        Parameters:
        obj - is the object
        i - the index
        newValue - is the new value
        Throws:
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
      • growArrayToSize

        protected void growArrayToSize​(java.lang.Object obj,
                                       java.lang.Class componentType,
                                       int i)
                                throws java.lang.reflect.InvocationTargetException,
                                       java.lang.IllegalAccessException
        Grow the array
        Parameters:
        obj -
        componentType -
        i -
        Throws:
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
      • getType

        public java.lang.Class getType()
        Get the type of a property
        Returns:
        the type of the property
      • getActualType

        public java.lang.Class getActualType()