String prefix,
Attributes attributes,
DeserializationContext context)
throws SAXException
{
BeanPropertyDescriptor propDesc = null;
String encodingStyle = context.getMessageContext().getEncodingStyle();
boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);
QName elemQName = new QName(namespace, localName);
// The collectionIndex needs to be reset for Beans with multiple arrays
if ((prevQName == null) || (!prevQName.equals(elemQName))) {
collectionIndex = -1;
}
prevQName = elemQName;
if (typeDesc != null) {
// Lookup the name appropriately (assuming an unqualified
// name for SOAP encoding, using the namespace otherwise)
String fieldName = typeDesc.getFieldNameForElement(elemQName,
isEncoded);
propDesc = (BeanPropertyDescriptor)propertyMap.get(fieldName);
}
if (propDesc == null) {
// look for a field by this name.
propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
}
// try and see if this is an xsd:any namespace="##any" element before
// reporting a problem
if (propDesc == null) {
// try to put unknown elements into a SOAPElement property, if
// appropriate
propDesc = getAnyPropertyDesc();
if (propDesc != null) {
try {
MessageElement [] curElements = (MessageElement[])propDesc.get(value);
int length = 0;
if (curElements != null) {
length = curElements.length;
}
MessageElement [] newElements = new MessageElement[length + 1];
if (curElements != null) {
System.arraycopy(curElements, 0,
newElements, 0, length);
}
MessageElement thisEl = context.getCurElement();
newElements[length] = thisEl;
propDesc.set(value, newElements);
return new SOAPHandler();
} catch (Exception e) {
throw new SAXException(e);
}
}
}
if (propDesc == null) {
// No such field
throw new SAXException(
JavaUtils.getMessage("badElem00", javaType.getName(),
localName));
}
// Get the child's xsi:type if available
QName childXMLType = context.getTypeFromXSITypeAttr(namespace,
localName,
attributes);
// Get Deserializer for child, default to using DeserializerImpl
Deserializer dSer = getDeserializer(childXMLType, propDesc.getType(),
attributes.getValue("href"),
context);
// It is an error if the dSer is not found, the base
// deserializer impl is returned so that it can generate the correct message.
if (dSer == null) {
dSer = new DeserializerImpl();
return (SOAPHandler)dSer;
}
// Register value target
if (propDesc.isWriteable()) {
// If this is an indexed property, and the deserializer we found
// was NOT the ArrayDeserializer, this is a non-SOAP array:
// <bean>
// <field>value1</field>
// <field>value2</field>
// ...
// In this case, we want to use the collectionIndex and make sure
// the deserialized value for the child element goes into the
// right place in the collection.
if (propDesc.isIndexed() && !(dSer instanceof ArrayDeserializer)) {
collectionIndex++;
dSer.registerValueTarget(new BeanPropertyTarget(value,
propDesc, collectionIndex));
} else {
// If we're here, the element maps to a single field value,