public XMLInlineBinaryHandler(UnmarshalRecord parent, NodeValue nodeValue, DatabaseMapping mapping, Converter converter, boolean isCollection) { super(null); this.nodeValue = nodeValue; this.isCollection = isCollection; this.mapping = mapping; this.parent = parent; this.setUnmarshaller(parent.getUnmarshaller()); }
public StrBuffer getStringBuffer() { return getUnmarshaller().getStringBuffer(); }
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if ((currentDataObjects.size() == 0) && (currentProperties.size() == 0)) { return; } if ((currentDataObjects.size() == 1) && (currentProperties.size() == 0)) { parentRecord.getUnmarshaller().getUnmarshalListener().afterUnmarshal(currentDataObjects.peek(), null); currentDataObjects.pop(); depth--; return; } else { setElementPropertyValue(); return; } }
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if ((currentDataObjects.size() == 0) && (currentProperties.size() == 0)) { return; } if ((currentDataObjects.size() == 1) && (currentProperties.size() == 0)) { parentRecord.getUnmarshaller().getUnmarshalListener().afterUnmarshal(currentDataObjects.peek(), null); currentDataObjects.pop(); depth--; return; } else { setElementPropertyValue(); return; } }
private Object getValue(Object value, UnmarshalRecord unmarshalRecord) { if(converter instanceof XMLConverter) { return ((XMLConverter) converter).convertDataValueToObjectValue(value, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } return converter.convertDataValueToObjectValue(value, unmarshalRecord.getSession()); }
protected void setOrAddAttributeValueForKeepAsElement(SAXFragmentBuilder builder, XMLMapping mapping, XMLConverter converter, UnmarshalRecord unmarshalRecord, boolean isCollection, Object collection) { Object node = builder.getNodes().remove(builder.getNodes().size() -1); if (converter != null) { node = converter.convertDataValueToObjectValue(node, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } if (isCollection) { if(collection != null){ unmarshalRecord.addAttributeValue((ContainerValue) this, node, collection); }else{ unmarshalRecord.addAttributeValue((ContainerValue) this, node); } } else { unmarshalRecord.setAttributeValue(node, (DatabaseMapping) mapping); } }
protected XMLDescriptor findReferenceDescriptor(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts, DatabaseMapping mapping, UnmarshalKeepAsElementPolicy policy) { XMLDescriptor referenceDescriptor = super.findReferenceDescriptor(xPathFragment, unmarshalRecord, atts, mapping, policy); if (referenceDescriptor == null) { XMLContext xmlContext = unmarshalRecord.getUnmarshaller().getXMLContext(); QName qname = new QName(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName()); referenceDescriptor = xmlContext.getDescriptor(qname); // Check if descriptor is for a wrapper, if it is null it out and let continue if (referenceDescriptor != null && referenceDescriptor.isWrapper()) { referenceDescriptor = null; } } return referenceDescriptor; }
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(); }
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(); }
public void startUnmappedElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if ((null != selfRecords) || (null == xmlReader) || isSelfRecord()) { return; } Class unmappedContentHandlerClass = getUnmarshaller().getUnmappedContentHandlerClass(); UnmappedContentHandler unmappedContentHandler; if (null == unmappedContentHandlerClass) { unmappedContentHandler = DEFAULT_UNMAPPED_CONTENT_HANDLER; } else { try { PrivilegedNewInstanceFromClass privilegedNewInstanceFromClass = new PrivilegedNewInstanceFromClass(unmappedContentHandlerClass); unmappedContentHandler = (UnmappedContentHandler)privilegedNewInstanceFromClass.run(); } catch (ClassCastException e) { throw XMLMarshalException.unmappedContentHandlerDoesntImplement(e, unmappedContentHandlerClass.getName()); } catch (IllegalAccessException e) { throw XMLMarshalException.errorInstantiatingUnmappedContentHandler(e, unmappedContentHandlerClass.getName()); } catch (InstantiationException e) { throw XMLMarshalException.errorInstantiatingUnmappedContentHandler(e, unmappedContentHandlerClass.getName()); } } UnmappedContentHandlerWrapper unmappedContentHandlerWrapper = new UnmappedContentHandlerWrapper(this, unmappedContentHandler); unmappedContentHandlerWrapper.startElement(namespaceURI, localName, qName, atts); xmlReader.setContentHandler(unmappedContentHandlerWrapper); }
public UnmappedContentHandlerWrapper(UnmarshalRecord parentRecord, UnmappedContentHandler unmappedContentHandler) { super(null); this.depth = 0; this.unmappedContentHandler = unmappedContentHandler; setParentRecord(parentRecord); setUnmarshaller(parentRecord.getUnmarshaller()); setXMLReader(parentRecord.getXMLReader()); setUnmarshalNamespaceResolver(parentRecord.getUnmarshalNamespaceResolver()); unmappedContentHandler.setUnmarshalRecord(this); }
protected void processComplexElement() throws SAXException { getParent().unmappedContent(); Class unmappedContentHandlerClass = getParent().getUnmarshaller().getUnmappedContentHandlerClass(); UnmappedContentHandler unmappedContentHandler; if (null == unmappedContentHandlerClass) { unmappedContentHandler = UnmarshalRecord.DEFAULT_UNMAPPED_CONTENT_HANDLER; } else { try { PrivilegedNewInstanceFromClass privilegedNewInstanceFromClass = new PrivilegedNewInstanceFromClass(unmappedContentHandlerClass); unmappedContentHandler = (UnmappedContentHandler)privilegedNewInstanceFromClass.run(); } catch (ClassCastException e) { throw XMLMarshalException.unmappedContentHandlerDoesntImplement(e, unmappedContentHandlerClass.getName()); } catch (IllegalAccessException e) { throw XMLMarshalException.errorInstantiatingUnmappedContentHandler(e, unmappedContentHandlerClass.getName()); } catch (InstantiationException e) { throw XMLMarshalException.errorInstantiatingUnmappedContentHandler(e, unmappedContentHandlerClass.getName()); } } UnmappedContentHandlerWrapper unmappedContentHandlerWrapper = new UnmappedContentHandlerWrapper(getParent(), unmappedContentHandler); executeEvents(unmappedContentHandlerWrapper); } }
XMLContext xmlContext = unmarshalRecord.getUnmarshaller().getXMLContext(); String schemaType = atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL, XMLConstants.SCHEMA_TYPE_ATTRIBUTE); if(schemaType != null){
protected void endElementProcessText(UnmarshalRecord unmarshalRecord, Converter converter, XPathFragment xPathFragment, Object collection) { Object value = unmarshalRecord.getStringBuffer().toString(); if(converter != null) { if(converter instanceof XMLConverter){ value = ((XMLConverter)converter).convertDataValueToObjectValue(value, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); }else{ value = converter.convertDataValueToObjectValue(value, unmarshalRecord.getSession()); } } unmarshalRecord.resetStringBuffer(); if (!XMLConstants.EMPTY_STRING.equals(value)) { QName qname = unmarshalRecord.getTypeQName(); if (qname != null) { Class theClass = (Class) XMLConversionManager.getDefaultXMLTypes().get(qname); if (theClass != null) { value = ((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(value, theClass, qname); } } setOrAddAttributeValue(unmarshalRecord, value, xPathFragment, collection); } }
/** * Handle swaRef and inline attribute cases. */ public void attribute(UnmarshalRecord unmarshalRecord, String URI, String localName, String value) { unmarshalRecord.removeNullCapableValue(this); XMLField xmlField = (XMLField) xmlBinaryDataMapping.getField(); XPathFragment lastFragment = xmlField.getLastXPathFragment(); Object fieldValue = null; if (xmlBinaryDataMapping.isSwaRef()) { if (unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller() != null) { if (xmlBinaryDataMapping.getAttributeClassification() == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) { fieldValue = unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsDataHandler(value); } else { fieldValue = unmarshalRecord.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsByteArray(value); } xmlBinaryDataMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(fieldValue, xmlBinaryDataMapping.getAttributeClassification(), unmarshalRecord.getSession())); } } else { // value should be base64 binary string fieldValue = ((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(value); xmlBinaryDataMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(fieldValue, xmlBinaryDataMapping.getAttributeClassification(), unmarshalRecord.getSession())); } }
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);
private void addUnmarshalValue(UnmarshalRecord unmarshalRecord, Object value, Object collection) { if (null == value) { return; } if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil() && xmlCompositeDirectCollectionMapping.getNullPolicy().valueIsNull(unmarshalRecord.getAttributes())) { return; } if ((!isWhitespaceAware() && XMLConstants.EMPTY_STRING.equals(value))) { return; } XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField(); XMLConversionManager xmlConversionManager = (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager(); if (unmarshalRecord.getTypeQName() != null) { Class typeClass = xmlField.getJavaClass(unmarshalRecord.getTypeQName()); value = xmlConversionManager.convertObject(value, typeClass, unmarshalRecord.getTypeQName()); } else { value = xmlField.convertValueBasedOnSchemaType(value, xmlConversionManager, unmarshalRecord); } if (xmlCompositeDirectCollectionMapping.hasValueConverter()) { if (xmlCompositeDirectCollectionMapping.getValueConverter() instanceof XMLConverter) { value = ((XMLConverter) xmlCompositeDirectCollectionMapping.getValueConverter()).convertDataValueToObjectValue(value, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } else { value = xmlCompositeDirectCollectionMapping.getValueConverter().convertDataValueToObjectValue(value, unmarshalRecord.getSession()); } } unmarshalRecord.addAttributeValue(this, value, collection); }
XMLContext xmlContext = unmarshalRecord.getUnmarshaller().getXMLContext();
childObject = xmlAnyObjectMapping.getConverter().convertDataValueToObjectValue(childObject, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller());
Converter converter = xmlCompositeCollectionMapping.getConverter(); if (converter instanceof XMLConverter) { objectValue = ((XMLConverter)converter).convertDataValueToObjectValue(objectValue, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller()); } else { objectValue = converter.convertObjectValueToDataValue(objectValue, unmarshalRecord.getSession());