// Now go through the element and dispatch its attributes, remembering
// that constructor arguments get first dibs
for (int i = elem.getAttributeCount() - 1; i >= 0; i--) {
// Backward traversal b/c we're deleting attributes from the xml element
XMLAttribute attribute = elem.getAttribute(i);
// Ignore xmlns attributes
if (attribute.getName().startsWith("xmlns:")) {
continue;
}
String propertyName = attribute.getLocalName();
if (setterValues.keySet().contains(propertyName)
|| requiredValues.containsKey(propertyName)) {
writer.die(elem, "Duplicate attribute name: %s", propertyName);
}
if (unfilledRequiredParams.keySet().contains(propertyName)) {
JType paramType = unfilledRequiredParams.get(propertyName);
String value = elem.consumeAttributeWithDefault(attribute.getName(),
null, paramType);
if (value == null) {
writer.die(elem, "Unable to parse %s as constructor argument "
+ "of type %s", attribute, paramType.getSimpleSourceName());
}
requiredValues.put(propertyName, value);
unfilledRequiredParams.remove(propertyName);
} else {
JMethod setter = ownerFieldClass.getSetter(propertyName);
if (setter == null) {
writer.die(elem, "Class %s has no appropriate set%s() method",
elem.getLocalName(), initialCap(propertyName));
}
String n = attribute.getName();
String value = elem.consumeAttributeWithDefault(n, null,
getParamTypes(setter));
if (value == null) {
writer.die(elem, "Unable to parse %s.", attribute);