//
if ((argTypes[0] == int.class) && name.startsWith(_READ_PREFIX))
{
// It's an indexed getter
pd = new IndexedPropertyDescriptor(
decapitalize(name.substring(_READ_PREFIX.length())),
null,
null,
method,
null);
}
else if ((resultType == void.class) &&
name.startsWith(_WRITE_PREFIX))
{
// It's a simple setter
pd = new PropertyDescriptor(
decapitalize(name.substring(_WRITE_PREFIX.length())),
null,
method);
if (_throwsException(method, PropertyVetoException.class))
{
pd.setConstrained(true);
}
}
}
else if (argCount == 2)
{
if ((argTypes[0] == int.class) && name.startsWith(_WRITE_PREFIX))
{
// it's an indexed setter
pd = new IndexedPropertyDescriptor(
decapitalize(name.substring(_WRITE_PREFIX.length())),
null,
null,
null,
method);
if (_throwsException(method, PropertyVetoException.class))
{
pd.setConstrained(true);
}
}
}
}
catch (IntrospectionException ex)
{
// This happens if a PropertyDescriptor or IndexedPropertyDescriptor
// constructor finds that the method violates details of the design
// pattern, e.g. by having an empty name, or a getter returning
// void , or whatever.
pd = null;
}
if (pd != null)
{
// If this class or one of its base classes is a PropertyChange
// source, then we assume that any properties we discover are "bound".
if (_propertyChangeSource)
{
pd.setBound(true);
}
// add the property to our list of properties
_addProperty(properties, pd);
}
}
}
//
// prune the list of properties, removing bogusly introspected properties.
//
Enumeration<PropertyDescriptor> elements = properties.elements();
while (elements.hasMoreElements())
{
Object currElement = elements.nextElement();
//
// Prune out IndexedPropertyDescriptors that have no indexedGetMethods
// and take two ints as parameters.
//
if (currElement instanceof IndexedPropertyDescriptor)
{
IndexedPropertyDescriptor indexedElement =
(IndexedPropertyDescriptor)currElement;
if (indexedElement.getIndexedReadMethod() == null)
{
Method writeMethod = indexedElement.getIndexedWriteMethod();
if ((writeMethod != null) &&
(writeMethod.getParameterTypes()[1] == int.class))
{
// prune this descriptor
properties.remove(indexedElement.getName());
}
}
}
}