Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.beans

Class IndexedPropertyDescriptor

java.lang.Object
|
+--java.beans.FeatureDescriptor
   |
   +--java.beans.PropertyDescriptor
      |
      +--java.beans.IndexedPropertyDescriptor


public class IndexedPropertyDescriptor

extends PropertyDescriptor

IndexedPropertyDescriptor describes information about a JavaBean indexed property, by which we mean an array-like property that has been exposed via a pair of get and set methods and another pair that allows you to get to the property by an index.

An example property would have four methods like this:

FooBar[] getFoo()
void setFoo(FooBar[])
FooBar getFoo(int)
void setFoo(int,FooBar)

The constraints put on get and set methods are:

  1. There must be at least a get(int) or a set(int,...) method. Nothing else is required. Spec note:One nice restriction would be that if there is a get() there must be a get(int), same with set, but that is not in the spec and is fairly harmless.)
  2. A get array method must have signature <propertyType>[] <getMethodName>()
  3. A set array method must have signature void <setMethodName>(<propertyType>[])
  4. A get index method must have signature <propertyType> <getMethodName>(int)
  5. A set index method must have signature void <setMethodName>(int,<propertyType>)
  6. All these methods may throw any exception.
  7. All these methods must be public.

Since:Author:

Constructor Summary

IndexedPropertyDescriptor(java.lang.String name, java.lang.Class beanClass)

Create a new IndexedPropertyDescriptor by introspection.
IndexedPropertyDescriptor(java.lang.String name, java.lang.Class beanClass, java.lang.String getMethodName, java.lang.String setMethodName, java.lang.String getIndexName, java.lang.String setIndexName)

Create a new IndexedPropertyDescriptor by introspection.
IndexedPropertyDescriptor(java.lang.String name, java.lang.reflect.Method getMethod, java.lang.reflect.Method setMethod, java.lang.reflect.Method getIndex, java.lang.reflect.Method setIndex)

Create a new PropertyDescriptor using explicit Methods.

Method Summary

java.lang.ClassgetIndexedPropertyType()

java.lang.reflect.MethodgetIndexedReadMethod()

java.lang.reflect.MethodgetIndexedWriteMethod()

Constructor Details

IndexedPropertyDescriptor

public IndexedPropertyDescriptor(java.lang.String name, java.lang.Class beanClass)

Create a new IndexedPropertyDescriptor by introspection. This form of constructor creates the PropertyDescriptor by looking for getter methods named get<name>() and setter methods named set<name>() in class <beanClass>, where <name> has its first letter capitalized by the constructor.

Implementation note: If there is a get(int) method, then the return type of that method is used to find the remaining methods. If there is no get method, then the set(int) method is searched for exhaustively and that type is used to find the others.

Spec note: If there is no get(int) method and multiple set(int) methods with the same name and the correct parameters (different type of course), then an IntrospectionException is thrown. While Sun's spec does not state this, it can make Bean behavior different on different systems (since method order is not guaranteed) and as such, can be treated as a bug in the spec. I am not aware of whether Sun's implementation catches this.

Parameters:

Throws:


IndexedPropertyDescriptor

public IndexedPropertyDescriptor(java.lang.String name, java.lang.Class beanClass, java.lang.String getMethodName, java.lang.String setMethodName, java.lang.String getIndexName, java.lang.String setIndexName)

Create a new IndexedPropertyDescriptor by introspection. This form of constructor allows you to specify the names of the get and set methods to search for.

Implementation note: If there is a get(int) method, then the return type of that method is used to find the remaining methods. If there is no get method, then the set(int) method is searched for exhaustively and that type is used to find the others.

Spec note: If there is no get(int) method and multiple set(int) methods with the same name and the correct parameters (different type of course), then an IntrospectionException is thrown. While Sun's spec does not state this, it can make Bean behavior different on different systems (since method order is not guaranteed) and as such, can be treated as a bug in the spec. I am not aware of whether Sun's implementation catches this.

Parameters:

Throws:


IndexedPropertyDescriptor

public IndexedPropertyDescriptor(java.lang.String name, java.lang.reflect.Method getMethod, java.lang.reflect.Method setMethod, java.lang.reflect.Method getIndex, java.lang.reflect.Method setIndex)

Create a new PropertyDescriptor using explicit Methods. Note that the methods will be checked for conformance to standard Property method rules, as described above at the top of this class.

Parameters:

Throws:


Method Details

getIndexedPropertyType

public Class getIndexedPropertyType()


getIndexedReadMethod

public Method getIndexedReadMethod()


getIndexedWriteMethod

public Method getIndexedWriteMethod()