public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Object collection) { Object value = unmarshalRecord.getStringBuffer().toString(); unmarshalRecord.resetStringBuffer(); if (xmlCompositeDirectCollectionMapping.usesSingleNode()) { StringTokenizer stringTokenizer = new StringTokenizer((String) value); while (stringTokenizer.hasMoreTokens()) { addUnmarshalValue(unmarshalRecord, stringTokenizer.nextToken(), collection); } } else { addUnmarshalValue(unmarshalRecord, value, collection); } }
private void startElementProcessText(UnmarshalRecord unmarshalRecord, Object collection) { String value = unmarshalRecord.getStringBuffer().toString(); unmarshalRecord.resetStringBuffer(); //if (!XMLConstants.EMPTY_STRING.equals(value) && xmlAnyCollectionMapping.isMixedContent()) { if (value.length() > 0 && xmlAnyCollectionMapping.isMixedContent()) { unmarshalRecord.addAttributeValue(this, value); } }
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField(); if (!xmlField.getLastXPathFragment().nameIsText()) { return; } Object value = unmarshalRecord.getStringBuffer().toString(); Object collection = unmarshalRecord.getContainerInstance(this); unmarshalRecord.resetStringBuffer(); if (xmlCompositeDirectCollectionMapping.usesSingleNode()) { StringTokenizer stringTokenizer = new StringTokenizer((String) value); while (stringTokenizer.hasMoreTokens()) { addUnmarshalValue(unmarshalRecord, stringTokenizer.nextToken(), collection); } } else { if (value.equals(XMLConstants.EMPTY_STRING)) { if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByEmptyNode() || xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil()) { return; } } addUnmarshalValue(unmarshalRecord, value, collection); } }
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { unmarshalRecord.removeNullCapableValue(this); XPathFragment lastFrag = ((XMLField)xmlFragmentMapping.getField()).getLastXPathFragment(); SAXFragmentBuilder builder = unmarshalRecord.getFragmentBuilder(); if (lastFrag.nameIsText()) { Object attributeValue = builder.buildTextNode(unmarshalRecord.getStringBuffer().toString()); unmarshalRecord.resetStringBuffer(); xmlFragmentMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), attributeValue); } else if (!lastFrag.isAttribute()) { Object value = builder.getNodes().remove(builder.getNodes().size() -1); unmarshalRecord.setAttributeValue(value, xmlFragmentMapping); } }
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 endElement operation. Here we will create and populate an * org.eclipse.persistence.internal.oxm.Reference instance to be used during * the mapping resolution stage. In particular, the primary key value * for this element will be added to the Reference object's list of * target primary key values. Note that if a reference already exists * for the xmlObjectReferenceMapping's source object instance, we will * simply add to the target pk value list. The Reference object will * is stored on the ReferenceResolver associated with the UnmarshalRecord's * session. */ public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { if (!xmlField.getLastXPathFragment().nameIsText()) { return; } Object value = unmarshalRecord.getStringBuffer().toString(); unmarshalRecord.resetStringBuffer(); 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); } // build a reference which will be resolved after unmarshalling is complete xmlObjectReferenceMapping.buildReference(unmarshalRecord, xmlField, value, unmarshalRecord.getSession()); }
/** * Handle endElement operation. Here we will create and populate an * org.eclipse.persistence.internal.oxm.Reference instance to be used during * the mapping resolution stage. In particular, the primary key value * for this element will be added to the Reference object's map of * target primary key values - based on the target key field name. Note * that if a reference already exists for the xmlCollectionReferenceMapping's * source object instance, we will simply add to the target pk value list. * The Reference object is stored on the ReferenceResolver associated with * the UnmarshalRecord's session. */ public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { if (!xmlField.getLastXPathFragment().nameIsText()) { return; } Object value = unmarshalRecord.getStringBuffer().toString(); unmarshalRecord.resetStringBuffer(); 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); } // build a reference which will be resolved after unmarshalling is complete xmlCollectionReferenceMapping.buildReference(unmarshalRecord, xmlField, value, unmarshalRecord.getSession()); }
endElementProcessText(unmarshalRecord, xmlAnyObjectMapping.getConverter(), xPathFragment, null); } else { unmarshalRecord.resetStringBuffer();
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { unmarshalRecord.removeNullCapableValue(this); XMLField xmlField = (XMLField) xmlDirectMapping.getField(); if (!xmlField.getLastXPathFragment().nameIsText()) { return; } Object value; if(unmarshalRecord.getStringBuffer().length() == 0) { value = this.getMapping().getNullValue(); } else { value = unmarshalRecord.getStringBuffer().toString(); } unmarshalRecord.resetStringBuffer(); 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); } Object convertedValue = xmlDirectMapping.getAttributeValue(value, unmarshalRecord.getSession(), unmarshalRecord); unmarshalRecord.setAttributeValue(convertedValue, xmlDirectMapping); }
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) { Object value = unmarshalRecord.getStringBuffer().toString(); boolean isCDATA = unmarshalRecord.isBufferCDATA(); unmarshalRecord.resetStringBuffer(); XMLField toWrite = xmlField; if(xmlField.isCDATA() != isCDATA) { toWrite = new XMLField(xmlField.getName()); toWrite.setNamespaceResolver(xmlField.getNamespaceResolver()); toWrite.setIsCDATA(isCDATA); } //xmlField.setIsCDATA(isCDATA); 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); } // PUT VALUE INTO A RECORD KEYED ON XMLFIELD if (null == unmarshalRecord.getTransformationRecord()) { unmarshalRecord.setTransformationRecord(new XMLTransformationRecord("ROOT", unmarshalRecord)); } unmarshalRecord.getTransformationRecord().put(toWrite, value); } }
endElementProcessText(unmarshalRecord, xmlAnyCollectionMapping.getConverter(), xPathFragment, null); } else { unmarshalRecord.resetStringBuffer();