/** * INTERNAL: * @return */ public boolean hasLastXPathFragment() { return getLastXPathFragment() != null; }
/** * Assumes type is in the format prefix:localPart, or localPart. * * @param type */ public void setLeafElementType(QName type) { leafElementType = type; if (hasLastXPathFragment()) { getLastXPathFragment().setLeafElementType(type); } }
/** * Assumes type is in the format prefix:localPart, or localPart. * * @param type */ public void setLeafElementType(QName type) { leafElementType = type; if (hasLastXPathFragment()) { getLastXPathFragment().setLeafElementType(type); } }
/** * Assumes type is in the format prefix:localPart, or localPart. * * @param type */ public void setLeafElementType(QName type) { leafElementType = type; if (hasLastXPathFragment()) { getLastXPathFragment().setLeafElementType(type); } }
public QName getLeafElementType() { if (hasLastXPathFragment()) { return getLastXPathFragment().getLeafElementType(); } return leafElementType; }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().isAttribute()) { if (attributeValue instanceof Attr) { attributeValue = ((Attr)attributeValue).getValue(); } } else if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().isAttribute()) { if (attributeValue instanceof Attr) { attributeValue = ((Attr)attributeValue).getValue(); } } else if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().isAttribute()) { if (attributeValue instanceof Attr) { attributeValue = ((Attr)attributeValue).getValue(); } } else if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
public boolean isNullCapableValue() { XMLField xmlField = (XMLField)xmlCompositeObjectMapping.getField(); if (xmlField.getLastXPathFragment().isSelfFragment) { return false; } return xmlCompositeObjectMapping.getNullPolicy().getIsSetPerformedForAbsentNode(); }
public Object get(DatabaseField key) { XMLField xmlField = this.convertToXMLField(key); XPathFragment lastFragment = xmlField.getLastXPathFragment(); NamespaceResolver namespaceResolver = xmlField.getNamespaceResolver(); String namespaceURI = XMLConstants.EMPTY_STRING; if (null != namespaceResolver) { namespaceURI = namespaceResolver.resolveNamespacePrefix(lastFragment.getPrefix()); if (null == namespaceURI) { namespaceURI = XMLConstants.EMPTY_STRING; } } return attributes.getValue(namespaceURI, lastFragment.getLocalName()); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
private void writeXsiTypeAttribute(XMLDescriptor xmlDescriptor, DOMRecord row, String typeValue) { String xsiPrefix = null; boolean generated = false; xsiPrefix = row.getNamespaceResolver().resolveNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL); if (xsiPrefix == null) { xsiPrefix = xmlDescriptor.getNonNullNamespaceResolver().generatePrefix(XMLConstants.SCHEMA_INSTANCE_PREFIX); generated = true; writeXsiNamespace(row, xsiPrefix); } XMLField xmlField = (XMLField)xmlDescriptor.buildField(XMLConstants.ATTRIBUTE + xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE); if (generated) { xmlField.getLastXPathFragment().setGeneratedPrefix(true); } xmlField.getLastXPathFragment().setNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL); row.add(xmlField, typeValue); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
/** * Marshal an attribute for the give namespaceURI, localName, qualifiedName and value * @param namespaceURI * @param localName * @param qName * @param value */ public void attribute(String namespaceURI, String localName, String qName, String value){ XMLField xmlField = new XMLField(XMLConstants.ATTRIBUTE +qName); xmlField.setNamespaceResolver(getNamespaceResolver()); xmlField.getLastXPathFragment().setNamespaceURI(namespaceURI); add(xmlField, value); }
public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) { if (((XMLField)this.getField()).getLastXPathFragment().nameIsText()) { if (attributeValue instanceof Text) { attributeValue = ((Text)attributeValue).getNodeValue(); } } row.put(getField(), attributeValue); }
/** * Marshal an attribute for the give namespaceURI, localName, qualifiedName and value * @param namespaceURI * @param localName * @param qName * @param value */ public void attribute(String namespaceURI, String localName, String qName, String value){ XMLField xmlField = new XMLField(XMLConstants.ATTRIBUTE +qName); xmlField.setNamespaceResolver(getNamespaceResolver()); xmlField.getLastXPathFragment().setNamespaceURI(namespaceURI); add(xmlField, value); }
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); } }
/** * 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); } }
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { if(value == null) { return false; } XPathFragment groupingFragment = marshalRecord.openStartGroupingElements(namespaceResolver); if (getXMLField().getLastXPathFragment().isAttribute()) { marshalRecord.add(getXMLField(), value); marshalRecord.closeStartGroupingElements(groupingFragment); } else { marshalRecord.closeStartGroupingElements(groupingFragment); marshalRecord.add(getXMLField(), value); } return true; }
public boolean startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts) { try { unmarshalRecord.removeNullCapableValue(this); XMLField xmlField = (XMLField) xmlBinaryDataMapping.getField(); XPathFragment lastFragment = xmlField.getLastXPathFragment(); BinaryMappingContentHandler handler = new BinaryMappingContentHandler(unmarshalRecord, this, this.xmlBinaryDataMapping); String qnameString = xPathFragment.getLocalName(); if (xPathFragment.getPrefix() != null) { qnameString = xPathFragment.getPrefix() + XMLConstants.COLON + qnameString; } handler.startElement(xPathFragment.getNamespaceURI(), xPathFragment.getLocalName(), qnameString, atts); unmarshalRecord.getXMLReader().setContentHandler(handler); return true; } catch(SAXException ex) { throw XMLMarshalException.unmarshalException(ex); } }