List fields = g.getFields();
iter2 = fields.iterator();
while (iter2.hasNext())
{
XmlField field = (XmlField)iter2.next();
String className = field.getMapToObject();
String propName = field.getMapToProperty();
// an unlikely but possible error
if ( className == null &&
!field.getName().equals(propName) )
{
Log.error("Field, " + field.getName() +
", has a property, " + propName +
" but no class is defined.");
}
if ( className != null && propName != null )
{
// Uses bean introspection to set writable properties
// of bean from the parameters, where a
// (case-insensitive) name match between the bean
// property and the parameter is looked for.
PropertyDescriptor[] beanProps = Introspector
.getBeanInfo(Class.forName(className))
.getPropertyDescriptors();
boolean noMatch = true;
for (int j=beanProps.length-1; j>=0; j--)
{
if (propName
.equalsIgnoreCase(beanProps[j].getName()))
{
((HashMap)getterMap.get(className))
.put(propName,
beanProps[j].getReadMethod());
((HashMap)setterMap.get(className))
.put(propName,
beanProps[j].getWriteMethod());
noMatch = false;
break;
}
}
if ( noMatch )
{
Log.error("Field, " + field.getName() +
", has a property, " + propName +
" for class, " + className +
", but the property could not be found.");
}
}