*/
private PropertyDescriptor getPropertyDescriptor(
final Class type,
final String name)
{
PropertyDescriptor propertyDescriptor = null;
Map classPropertyDescriptors = (Map)this.propertyDescriptorsCache.get(type);
if (classPropertyDescriptors == null)
{
classPropertyDescriptors = new HashMap();
}
else
{
propertyDescriptor = (PropertyDescriptor)classPropertyDescriptors.get(name);
}
if (propertyDescriptor == null)
{
try
{
final PropertyDescriptor[] descriptors =
java.beans.Introspector.getBeanInfo(type).getPropertyDescriptors();
final int descriptorNumber = descriptors.length;
for (int ctr = 0; ctr < descriptorNumber; ctr++)
{
final PropertyDescriptor descriptor = descriptors[ctr];
// - handle names that start with a lowercased letter and have an uppercase as the second letter
final String compareName =
name.matches("\\p{Lower}\\p{Upper}.*") ? StringUtils.capitalize(name) : name;
if (descriptor.getName().equals(compareName))
{
propertyDescriptor = descriptor;
break;
}
}
if (propertyDescriptor == null && name.indexOf(NESTED_DELIMITER) != -1)
{
int dotIndex = name.indexOf(NESTED_DELIMITER);
if (dotIndex >= name.length())
{
throw new IntrospectorException("Invalid property call --> '" + name + "'");
}
final PropertyDescriptor nextInstance =
this.getPropertyDescriptor(
type,
name.substring(
0,
dotIndex));
propertyDescriptor =
this.getPropertyDescriptor(
nextInstance.getPropertyType(),
name.substring(dotIndex + 1));
}
}
catch (final java.beans.IntrospectionException exception)
{