public void initializeNodeValue() { XMLMapping xmlMapping = xmlChoiceMapping.getChoiceElementMappings().get(xmlField); if(xmlMapping instanceof XMLDirectMapping) { choiceElementNodeValue = new XMLDirectMappingNodeValue((XMLDirectMapping)xmlMapping); } else { choiceElementNodeValue = new XMLCompositeObjectMappingNodeValue((XMLCompositeObjectMapping)xmlMapping); } }
public boolean marshal(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver) { return marshal(xPathFragment, marshalRecord, object, session, namespaceResolver, ObjectMarshalContext.getInstance()); }
public boolean marshal(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { if (xmlCompositeObjectMapping.isReadOnly()) { return false; } Object objectValue = marshalContext.getAttributeValue(object, xmlCompositeObjectMapping); return this.marshalSingleValue(xPathFragment, marshalRecord, object, objectValue, session, namespaceResolver, marshalContext); }
xmlDescriptor = findReferenceDescriptor(xPathFragment, unmarshalRecord, atts, xmlCompositeObjectMapping,xmlCompositeObjectMapping.getKeepAsElementPolicy()); Class theClass = (Class)((XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName()); if(theClass == null){ setupHandlerForKeepAsElementPolicy(unmarshalRecord, xPathFragment, atts); return true; setupHandlerForKeepAsElementPolicy(unmarshalRecord, xPathFragment, atts); return true; unmarshalRecord.setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType()); processChild(xPathFragment, unmarshalRecord, atts, xmlDescriptor, xmlCompositeObjectMapping);
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object objectValue, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { boolean isNilFlag = isNil(objectValue); objectValue = xmlCompositeObjectMapping.convertObjectValueToDataValue(objectValue, session, marshalRecord.getMarshaller()); if (null == objectValue) { CoreAttributeItem item = group.getItem(getMapping().getAttributeName()); CoreAttributeGroup nestedGroup = XMLRecord.DEFAULT_ATTRIBUTE_GROUP; if(item != null) { if (!marshalRecord.hasEqualNamespaceResolvers()) { extraNamespaces = objectBuilder.addExtraNamespacesToNamespaceResolver(descriptor, marshalRecord, session, true, false); writeExtraNamespaces(extraNamespaces, marshalRecord, session); updateNamespaces(schemaType, marshalRecord,((Field)xmlCompositeObjectMapping.getField())); marshalRecord.characters(schemaType, objectValue, null, false);
getXPathNode().startElement(marshalRecord, xPathFragment, object, session, namespaceResolver, objectBuilder, objectValue); writeExtraNamespaces(extraNamespaces, marshalRecord, session); if ((xmlCompositeObjectMapping.getReferenceDescriptor() == null) && (descriptor.getSchemaReference() != null)) { addTypeAttributeIfNeeded(descriptor, xmlCompositeObjectMapping, marshalRecord); } else { if (!xPathFragment.isSelfFragment()) { getXPathNode().startElement(marshalRecord, xPathFragment, object, session, namespaceResolver, null, objectValue); QName schemaType = getSchemaType((XMLField) xmlCompositeObjectMapping.getField(), objectValue, session); String stringValue = getValueToWrite(schemaType, objectValue, (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), namespaceResolver); updateNamespaces(schemaType, marshalRecord,((XMLField)xmlCompositeObjectMapping.getField())); marshalRecord.characters(stringValue);
if(theClass != null){ endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping, xPathFragment, null); return; setOrAddAttributeValueForKeepAsElement(builder, xmlCompositeObjectMapping, xmlCompositeObjectMapping, unmarshalRecord, false, null); return; endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping, xPathFragment, null); return; setAttributeValue(object, unmarshalRecord); unmarshalRecord.setChildRecord(null);
CompositeObjectMapping m = new XMLCompositeObjectMapping(); m.setXPath("."); XMLCompositeObjectMappingNodeValue nv = new XMLCompositeObjectMappingNodeValue(m); n.setMarshalNodeValue(nv); nv.marshalSingleValue(new XPathFragment("."), marshalRecord, null, object, session, namespaceResolver, marshalContext); } else { for (int x = 0, size = marshalContext.getNonAttributeChildrenSize(node); x < size; x++) {
if(theClass != null){ endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping.getConverter(), xPathFragment, null); return; setOrAddAttributeValueForKeepAsElement(builder, (XMLMapping) xmlCompositeObjectMapping, (XMLConverter) xmlCompositeObjectMapping.getConverter(), unmarshalRecord, false, null); return; endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping.getConverter(), xPathFragment, null); return;
@Override protected void processEmptyElement() throws SAXException { // Remove original startElement event as it has been precluded by the nodeValue call below getEvents().remove(0); // Prerequisite: We know that (nullPolicy.isNullRepresentedByEmptyNode() || nullPolicy.isNullRepresentedByXsiNil()) is true // Null: Set the object to null on the node value if we are empty with inrben=true nodeValue.setNullValue(getParent().getCurrentObject(), getParent().getSession()); executeEvents(getParent()); }
Descriptor xmlDescriptor = (Descriptor)xmlCompositeObjectMapping.getReferenceDescriptor(); if (null == xmlDescriptor) { xmlDescriptor = findReferenceDescriptor(null, unmarshalRecord, atts, xmlCompositeObjectMapping,xmlCompositeObjectMapping.getKeepAsElementPolicy());
if(theClass != null){ endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping.getConverter(), null, null); return;
/** * INTERNAL: * Create an empty object to be used by empty, complex or simple events. * A childRecord is created on the parent UnmarshalRecord. */ private void createEmptyObject() { try { // Instantiate a new object XMLField xmlFld = (XMLField)mapping.getField(); if (xmlFld.hasLastXPathFragment()) { getParent().setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType()); } // Create a childRecord on the parent UnmarshalRecord nodeValue.processChild(xPathFragment, getParent(), attributes, xmlDescriptor, mapping); } catch (SAXException e) { throw XMLMarshalException.unmarshalException(e); } }
xmlDescriptor = findReferenceDescriptor(xPathFragment, unmarshalRecord, atts, xmlCompositeObjectMapping,xmlCompositeObjectMapping.getKeepAsElementPolicy()); Class theClass = unmarshalRecord.getConversionManager().javaType(schemaType); if(theClass == null){ setupHandlerForKeepAsElementPolicy(unmarshalRecord, xPathFragment, atts); return true; setupHandlerForKeepAsElementPolicy(unmarshalRecord, xPathFragment, atts); return true; unmarshalRecord.setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType()); processChild(xPathFragment, unmarshalRecord, atts, xmlDescriptor, xmlCompositeObjectMapping);
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object objectValue, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { boolean isNilFlag = isNil(objectValue); objectValue = xmlCompositeObjectMapping.convertObjectValueToDataValue(objectValue, session, marshalRecord.getMarshaller()); if (null == objectValue) { CoreAttributeItem item = group.getItem(getMapping().getAttributeName()); CoreAttributeGroup nestedGroup = XMLRecord.DEFAULT_ATTRIBUTE_GROUP; if(item != null) { writeExtraNamespaces(extraNamespaces, marshalRecord, session); updateNamespaces(schemaType, marshalRecord,((Field)xmlCompositeObjectMapping.getField())); marshalRecord.characters(schemaType, objectValue, null, false);
if(theClass != null){ endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping, xPathFragment, null); return; setOrAddAttributeValueForKeepAsElement(builder, xmlCompositeObjectMapping, xmlCompositeObjectMapping, unmarshalRecord, false, null); return; endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping, xPathFragment, null); return; setAttributeValue(object, unmarshalRecord); unmarshalRecord.setChildRecord(null);
CompositeObjectMapping m = new XMLCompositeObjectMapping(); m.setXPath("."); XMLCompositeObjectMappingNodeValue nv = new XMLCompositeObjectMappingNodeValue(m); n.setMarshalNodeValue(nv); nv.marshalSingleValue(new XPathFragment("."), marshalRecord, null, object, session, namespaceResolver, marshalContext); } else { for (int x = 0, size = marshalContext.getNonAttributeChildrenSize(node); x < size; x++) {
@Override protected void processEmptyElement() throws SAXException { // Remove original startElement event as it has been precluded by the nodeValue call below getEvents().remove(0); // Prerequisite: We know that (nullPolicy.isNullRepresentedByEmptyNode() || nullPolicy.isNullRepresentedByXsiNil()) is true // Null: Set the object to null on the node value if we are empty with inrben=true nodeValue.setNullValue(getParent().getCurrentObject(), getParent().getSession()); executeEvents(getParent()); }
Descriptor xmlDescriptor = (Descriptor)xmlCompositeObjectMapping.getReferenceDescriptor(); if (null == xmlDescriptor) { xmlDescriptor = findReferenceDescriptor(null, unmarshalRecord, atts, xmlCompositeObjectMapping,xmlCompositeObjectMapping.getKeepAsElementPolicy());
if(theClass != null){ endElementProcessText(unmarshalRecord, xmlCompositeObjectMapping, null, null); return;