}
attributeDesc.setXmlType(attribute.getType().getName());
fields[i++] = attributeDesc;
} else {
ElementDesc elementDesc = new ElementDesc();
elementDesc.setFieldName(fieldName);
Class javaType = (Class) properties.get(fieldName);
if (javaType == null) {
//see if it is a public field
try {
Field field = javaClass.getField(fieldName);
javaType = field.getType();
} catch (NoSuchFieldException e) {
throw new DeploymentException("field name " + fieldName + " not found in " + properties, e);
}
}
QName xmlName = new QName("", variableMapping.getXmlElementName());
SchemaParticle particle = (SchemaParticle) paramNameToType.get(xmlName);
if (null == particle) {
xmlName = new QName(ns, variableMapping.getXmlElementName());
particle = (SchemaParticle) paramNameToType.get(xmlName);
if (null == particle) {
throw new DeploymentException("element " + xmlName + " not found in schema " + schemaType.getName());
}
} else if (SchemaParticle.ELEMENT != particle.getParticleType()) {
throw new DeploymentException(xmlName + " is not an element in schema " + schemaType.getName());
}
elementDesc.setNillable(particle.isNillable() || hasEncoded);
elementDesc.setXmlName(xmlName);
if (null != particle.getType().getName()) {
elementDesc.setXmlType(particle.getType().getName());
} else {
QName anonymousName;
if (key.isAnonymous()) {
anonymousName = new QName(key.getqName().getNamespaceURI(), key.getqName().getLocalPart() +
">" + particle.getName().getLocalPart());
} else {
anonymousName = new QName(key.getqName().getNamespaceURI(),
">" + key.getqName().getLocalPart() + ">" + particle.getName().getLocalPart());
}
elementDesc.setXmlType(anonymousName);
}
if (javaType.isArray()) {
elementDesc.setMinOccurs(particle.getIntMinOccurs());
elementDesc.setMaxOccurs(particle.getIntMaxOccurs());
//TODO axis seems to have the wrong name for this property based on how it is used
elementDesc.setMaxOccursUnbounded(particle.getIntMaxOccurs() > 1);
}
fields[i++] = elementDesc;
}
}