@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
//Since we know this was a simple or empty element, we know that we only got a characters event and then this. Process the
//text.
Field field = null;
Object value = this.getCharacters();
Class attributeClassification = null;
AbstractNullPolicy nullPolicy;
boolean isSwaRef = false;
CoreContainerPolicy cp = null;
if(isCollection) {
isSwaRef = ((BinaryDataCollectionMapping)mapping).isSwaRef();
field = (Field)((BinaryDataCollectionMapping)mapping).getField();
attributeClassification =((BinaryDataCollectionMapping)mapping).getAttributeElementClass();
nullPolicy =((BinaryDataCollectionMapping)mapping).getNullPolicy();
cp = ((BinaryDataCollectionMapping)mapping).getContainerPolicy();
} else {
isSwaRef = ((BinaryDataMapping)mapping).isSwaRef();
field = (Field)((BinaryDataMapping)mapping).getField();
attributeClassification =((BinaryDataMapping)mapping).getAttributeClassification();
nullPolicy =((BinaryDataMapping)mapping).getNullPolicy();
}
if (isSwaRef && (parent.getUnmarshaller().getAttachmentUnmarshaller() != null)) {
if(attributeClassification != null && attributeClassification == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) {
value = parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsDataHandler(value.toString());
} else {
value = parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsByteArray(value.toString());
}
} else {
Object valueFromReader = this.parent.getXMLReader().getValue(getCharacters(), attributeClassification);
if(parent.isNil() && parent.getXMLReader().isNullRepresentedByXsiNil(nullPolicy)){
value = null;
isCollection = isCollection && parent.getXMLReader().isInCollection();
}
else{
if(null != valueFromReader) {
value = valueFromReader;
} else {
String valueString = value.toString();
if(valueString.length() == 0 && nullPolicy.isNullRepresentedByEmptyNode()){
value = null;
}else{
if(field.usesSingleNode()){
value = parent.getConversionManager().convertSchemaBase64ListToByteArrayList(valueString, cp, parent.getSession());
}else{
value = parent.getConversionManager().convertSchemaBase64ToByteArray(valueString);
}
}
}
value = XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(value, attributeClassification, parent.getSession(), cp);
}
}
value = converter.convertDataValueToObjectValue(value, parent.getSession(), parent.getUnmarshaller());
if(isCollection) {
parent.addAttributeValue((ContainerValue)nodeValue, value);
} else {
parent.setAttributeValue(value, mapping);
}
if(!field.isSelfField()){
//Return control to the parent record
parent.getXMLReader().setContentHandler(parent);
parent.endElement(namespaceURI, localName, qName);
}
resetStringBuffer();