unmarshalRecord = new UnmarshalRecord((TreeObjectBuilder)xmlDescriptor.getObjectBuilder()); unmarshalRecord.setUnmarshalNamespaceResolver(unmarshalNamespaceResolver); unmarshalRecord.setAttributes(atts); if(parentRecord != null){ unmarshalRecord.setXMLReader(parentRecord.getXMLReader()); unmarshalRecord.setParentRecord(parentRecord); unmarshalRecord.setUnmarshaller(parentRecord.getUnmarshaller()); unmarshalRecord.setXMLReader(parentRecord.getXMLReader()); unmarshalRecord.startDocument(); unmarshalRecord.setUnmarshalNamespaceResolver(unmarshalNamespaceResolver); unmarshalRecord.startElement(namespaceURI, localName, qName, atts); parentRecord.getXMLReader().setContentHandler(unmarshalRecord); unmarshalRecord.getXMLReader().setProperty("http://xml.org/sax/properties/lexical-handler", unmarshalRecord); } catch (SAXNotRecognizedException ex) { } catch (SAXNotSupportedException ex) { currentDataObjects.push(unmarshalRecord.getCurrentObject()); depth++;
@Override public Class<?> extractClassFromRow(Record record, Session session) { Class<?> clz = Result.class; UnmarshalRecord uRecord = (UnmarshalRecord)record; Attributes attrs = uRecord.getAttributes(); if (attrs != null) { for (int i = 0, l = attrs.getLength(); i < l; i++) { String attributeName = attrs.getQName(i); if (attributeName.equals("isCollection")) { String value = attrs.getValue(i); if (value.equalsIgnoreCase("true")) { clz = CollectionResult.class; break; } } } } return clz; } });
public void setUnmarshalRecord(UnmarshalRecord unmarshalRecord) { parentRecord = unmarshalRecord; aHelperContext = (HelperContext)unmarshalRecord.getUnmarshaller().getProperty(SDOConstants.SDO_HELPER_CONTEXT); if (parentRecord.getParentRecord() == null) { rootProcessed = false; } else { rootProcessed = true; if (parentRecord.getParentRecord().getCurrentObject() instanceof DataObject) { currentDataObjects.push(parentRecord.getParentRecord().getCurrentObject()); depth++; } } unmarshalNamespaceResolver = parentRecord.getUnmarshalNamespaceResolver(); }
/** * Create a new row/record for the object builder. * This allows subclasses to define different record types. */ public AbstractRecord createRecord(AbstractSession session) { UnmarshalRecord uRec = new UnmarshalRecord(this); uRec.setSession(session); return uRec; }
public String resolveNamespacePrefix(String prefix) { String namespaceURI = getUnmarshalNamespaceResolver().getNamespaceURI(prefix); if(null == namespaceURI && null != getParentRecord()) { namespaceURI = getParentRecord().resolveNamespacePrefix(prefix); } return namespaceURI; }
public String resolveNamespaceUri(String uri) { String prefix = getUnmarshalNamespaceResolver().getPrefix(uri); if (null == prefix) { if (null != getParentRecord()) { prefix = getParentRecord().resolveNamespaceUri(uri); } } return prefix; }
if (isPrimitiveType) { unmarshalRecord = new XMLRootRecord(primitiveWrapperClass); unmarshalRecord.setSession((AbstractSession) unmarshaller.getXMLContext().getSession(0)); } else if (xmlDescriptor.hasInheritance()) { unmarshalRecord = new UnmarshalRecord(null); unmarshalRecord.setUnmarshalNamespaceResolver(unmarshalNamespaceResolver); unmarshalRecord.setAttributes(atts); Class classValue = xmlDescriptor.getInheritancePolicy().classFromRow(unmarshalRecord, session); if (classValue == null) { this.rootRecord = unmarshalRecord; if (locator != null) { unmarshalRecord.setDocumentLocator(locator); unmarshalRecord.setUnmarshaller(this.unmarshaller); unmarshalRecord.setXMLReader(this.getXMLReader()); unmarshalRecord.setAttributes(atts); unmarshalRecord.setUnmarshalNamespaceResolver(unmarshalNamespaceResolver); unmarshalRecord.startDocument(); xmlReader.setContentHandler(unmarshalRecord); unmarshalRecord.startElement(namespaceURI, localName, qName, atts); try { unmarshalRecord.getXMLReader().setProperty("http://xml.org/sax/properties/lexical-handler", unmarshalRecord); } catch (SAXNotRecognizedException ex) { } catch (SAXNotSupportedException ex) { unmarshalRecord.setRootElementName(qName); unmarshalRecord.setRootElementNamespaceUri(namespaceURI);
unmarshalRecord.setSession((AbstractSession) xmlUnmarshaller.getXMLContext().getSession(0)); } else if(clazz == ClassConstants.OBJECT) { SAXUnmarshallerHandler saxUnmarshallerHandler = new SAXUnmarshallerHandler(xmlUnmarshaller.getXMLContext()); extendedXMLReader = new XMLReader(xmlReader); unmarshalRecord.setXMLReader(extendedXMLReader); unmarshalRecord.setUnmarshaller(xmlUnmarshaller); extendedXMLReader.setContentHandler(unmarshalRecord); try { return unmarshalRecord.getCurrentObject();
unmarshalRecord.setAttributes(atts); Class clazz = xmlDescriptor.getInheritancePolicy().classFromRow(unmarshalRecord, unmarshalRecord.getSession()); if (clazz == null) { QName leafElementType = unmarshalRecord.getLeafElementType(); xmlDescriptor = (XMLDescriptor)unmarshalRecord.getSession().getDescriptor(clazz); } else { UnmarshalRecord childRecord = (UnmarshalRecord)stob2.createRecord(unmarshalRecord.getSession()); childRecord.setUnmarshaller(unmarshalRecord.getUnmarshaller()); childRecord.setSelfRecord(true); unmarshalRecord.setChildRecord(childRecord); childRecord.setXMLReader(unmarshalRecord.getXMLReader()); childRecord.startDocument(this.xmlCompositeObjectMapping);
unmarshalRecord.getXMLReader().setContentHandler(handler); return; unmarshalRecord.setAttributes(atts); Class classValue = xmlDescriptor.getInheritancePolicy().classFromRow(unmarshalRecord, unmarshalRecord.getSession()); if (classValue == null) { QName leafElementType = unmarshalRecord.getLeafElementType(); xmlDescriptor = (XMLDescriptor)unmarshalRecord.getSession().getDescriptor(classValue); } else { UnmarshalRecord childRecord = unmarshalRecord.getChildUnmarshalRecord(targetObjectBuilder); unmarshalRecord.setChildRecord(childRecord); childRecord.setAttributes(atts); childRecord.startDocument(); childRecord.startElement(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName(), xPathFragment.getShortName(), atts); unmarshalRecord.getXMLReader().setContentHandler(unmarshalRecord.getChildRecord()); try { unmarshalRecord.getXMLReader().setProperty("http://xml.org/sax/properties/lexical-handler", unmarshalRecord.getChildRecord()); } catch (SAXNotRecognizedException ex) { } catch (SAXNotSupportedException ex) {
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { Object collection = unmarshalRecord.getContainerInstance(this); if (null != unmarshalRecord.getChildRecord()) { Object objectValue = unmarshalRecord.getChildRecord().getCurrentObject(); if(xmlAnyCollectionMapping.getConverter() != null) { objectValue = xmlAnyCollectionMapping.getConverter().convertDataValueToObjectValue(objectValue, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); unmarshalRecord.addAttributeValue(this, objectValue); Object childObject = unmarshalRecord.getChildRecord().getCurrentObject(); prefix = unmarshalRecord.resolveNamespaceUri(xPathFragment.getNamespaceURI()); childObject = xmlAnyCollectionMapping.getConverter().convertDataValueToObjectValue(childObject, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); unmarshalRecord.addAttributeValue(this, childObject); unmarshalRecord.setChildRecord(null); workingDescriptor = null; } else { SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); endElementProcessText(unmarshalRecord, xmlAnyCollectionMapping.getConverter(), xPathFragment, null); } else { unmarshalRecord.resetStringBuffer();
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { unmarshalRecord.removeNullCapableValue(this); UnmarshalRecord childRecord = unmarshalRecord.getChildRecord(); if (null != childRecord) { Object childObject = childRecord.getCurrentObject(); XMLDescriptor workingDescriptor = childRecord.getDescriptor(); if (workingDescriptor != null) { String prefix = xPathFragment.getPrefix(); if ((prefix == null) && (xPathFragment.getNamespaceURI() != null)) { prefix = unmarshalRecord.resolveNamespaceUri(xPathFragment.getNamespaceURI()); childObject = xmlAnyObjectMapping.getConverter().convertDataValueToObjectValue(childObject, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); unmarshalRecord.setAttributeValue(childObject, xmlAnyObjectMapping); } else { SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); endElementProcessText(unmarshalRecord, xmlAnyObjectMapping.getConverter(), xPathFragment, null); } else { unmarshalRecord.resetStringBuffer();
public UnmarshalRecord getChildUnmarshalRecord(TreeObjectBuilder treeObjectBuilder) { if(childRecordPool.isEmpty()) { UnmarshalRecord childRecord = (UnmarshalRecord) treeObjectBuilder.createRecord(session); childRecord.setUnmarshaller(unmarshaller); childRecord.session = this.session; childRecord.xmlReader = this.xmlReader; childRecord.setFragmentBuilder(fragmentBuilder); childRecord.setUnmarshalNamespaceResolver(this.getUnmarshalNamespaceResolver()); childRecord.childRecordPool = this.childRecordPool; return childRecord; } else { return childRecordPool.remove(childRecordPool.size() - 1).initialize(treeObjectBuilder); } }
XMLAttachmentUnmarshaller attachmentUnmarshaller = record.getUnmarshaller().getAttachmentUnmarshaller(); Object data = null; Class attributeClassification = null; Converter converter = this.converter; if (converter instanceof XMLConverter) { data = ((XMLConverter) converter).convertDataValueToObjectValue(data, record.getSession(), record.getUnmarshaller()); } else { data = converter.convertDataValueToObjectValue(data, record.getSession()); data = XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(data, mapping.getAttributeClassification(), record.getSession()); record.addAttributeValue((ContainerValue)nodeValue, data); record.setAttributeValue(data, mapping); record.getXMLReader().setContentHandler(record); record.getXMLReader().setContentHandler(record); record.endElement(namespaceURI, localName, qName);
public boolean startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts) { try { unmarshalRecord.removeNullCapableValue(this); XMLContext xmlContext = unmarshalRecord.getUnmarshaller().getXMLContext(); xmlDescriptor = xmlContext.getDescriptorByGlobalType(frag); if(unmarshalRecord.getTypeQName() != null){ Class theClass = (Class)((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName()); if(theClass == null){ setupHandlerForKeepAsElementPolicy(unmarshalRecord, xPathFragment, atts); unmarshalRecord.getXMLReader().setContentHandler(aHandler); xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), null); } else { XMLField xmlFld = (XMLField)this.xmlCompositeObjectMapping.getField(); if (xmlFld.hasLastXPathFragment()) { unmarshalRecord.setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType());
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Object collection) { if (null == unmarshalRecord.getChildRecord()) { SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); UnmarshalKeepAsElementPolicy keepAsElementPolicy = xmlCompositeCollectionMapping.getKeepAsElementPolicy(); if(unmarshalRecord.getTypeQName() != null){ Class theClass = (Class)((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName()); if(theClass != null){ Object objectValue = unmarshalRecord.getChildRecord().getCurrentObject(); if (xmlCompositeCollectionMapping.hasConverter()) { Converter converter = xmlCompositeCollectionMapping.getConverter(); if (converter instanceof XMLConverter) { objectValue = ((XMLConverter)converter).convertDataValueToObjectValue(objectValue, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } else { objectValue = converter.convertObjectValueToDataValue(objectValue, unmarshalRecord.getSession()); unmarshalRecord.addAttributeValue(this, objectValue, collection); xmlCompositeCollectionMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(objectValue, unmarshalRecord.getCurrentObject()); } else { Object backpointerContainer = xmlCompositeCollectionMapping.getInverseReferenceMapping().getAttributeAccessor().getAttributeValueFromObject(objectValue); xmlCompositeCollectionMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(objectValue, backpointerContainer); xmlCompositeCollectionMapping.getInverseReferenceMapping().getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(), backpointerContainer, unmarshalRecord.getSession()); unmarshalRecord.setChildRecord(null);
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { if (null == unmarshalRecord.getChildRecord()) { SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); UnmarshalKeepAsElementPolicy keepAsElementPolicy = xmlCompositeObjectMapping.getKeepAsElementPolicy(); if(unmarshalRecord.getTypeQName() != null){ Class theClass = (Class)((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName()); if(theClass != null){ Object object = unmarshalRecord.getChildRecord().getCurrentObject(); if (xmlCompositeObjectMapping.getConverter() != null) { Converter converter = xmlCompositeObjectMapping.getConverter(); if (converter instanceof XMLConverter) { object = ((XMLConverter)converter).convertDataValueToObjectValue(object, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } else { object = converter.convertDataValueToObjectValue(object, unmarshalRecord.getSession()); unmarshalRecord.setAttributeValue(object, xmlCompositeObjectMapping); if(xmlCompositeObjectMapping.getInverseReferenceMapping() != null) { if(xmlCompositeObjectMapping.getInverseReferenceMapping().getContainerPolicy() == null) { xmlCompositeObjectMapping.getInverseReferenceMapping().getAttributeAccessor().setAttributeValueInObject(object, unmarshalRecord.getCurrentObject()); } else { Object backpointerContainer = xmlCompositeObjectMapping.getInverseReferenceMapping().getAttributeAccessor().getAttributeValueFromObject(object); xmlCompositeObjectMapping.getInverseReferenceMapping().getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(), backpointerContainer, unmarshalRecord.getSession()); unmarshalRecord.setChildRecord(null);
@Override public Class classFromRow(org.eclipse.persistence.internal.oxm.record.UnmarshalRecord unmarshalRecord, AbstractSession session) { UnmarshalRecord inheritanceRecord = new UnmarshalRecord(unmarshalRecord); return descriptor.getInheritancePolicy().classFromRow(inheritanceRecord, session); }
public void endSelfNodeValue(UnmarshalRecord unmarshalRecord, Attributes attributes) { if(xmlCompositeObjectMapping.getNullPolicy().valueIsNull(attributes)){ xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), null); return; if (unmarshalRecord.getFragmentBuilder().getDocument() != null) { UnmarshalKeepAsElementPolicy keepAsElementPolicy = xmlCompositeObjectMapping.getKeepAsElementPolicy(); SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); if ((((keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT) || (keepAsElementPolicy == UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT)))&& (builder.getNodes().size() != 0) ) { if(unmarshalRecord.getTypeQName() != null){ Class theClass = (Class)((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName()); if(theClass != null){ if (colonIndex > -1) { String prefix = xsiType.substring(0, colonIndex); namespace = unmarshalRecord.resolveNamespacePrefix(prefix); if(null == namespace) { namespace = XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(element, prefix); Class theClass = (Class) XMLConversionManager.getDefaultXMLTypes().get(qName); if (theClass != null) { value = ((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(element.getTextContent(), theClass, qName); xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), value); } else { xmlCompositeObjectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), element); Object valueToSet = unmarshalRecord.getChildRecord().getCurrentObject(); if (xmlCompositeObjectMapping.getConverter() != null) {
unmarshalRecord.getXMLReader().setContentHandler(handler); } else if (lastFragment.isAttribute()) { Object fieldValue = null; if (xmlBinaryDataCollectionMapping.isSwaRef()) { if (unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller() != null) { if (xmlBinaryDataCollectionMapping.getAttributeClassification() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { fieldValue = unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsDataHandler(value); } else { fieldValue = unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsByteArray(value); xmlBinaryDataCollectionMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(fieldValue, xmlBinaryDataCollectionMapping.getAttributeClassification(), unmarshalRecord.getSession())); fieldValue = ((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(value); xmlBinaryDataCollectionMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(fieldValue, xmlBinaryDataCollectionMapping.getAttributeClassification(), unmarshalRecord.getSession()));