/** * INTERNAL: * Set the root element name of the document * @param rootElementName the root element name of the document */ public void setRootElementName(String rootElementName) { super.setLocalName(rootElementName); }
/** * INTERNAL: * Set the root element name of the document * @param rootElementName the root element name of the document */ public void setRootElementName(String rootElementName) { super.setLocalName(rootElementName); }
/** * Convenience method that builds an XMLRoot wrapping a given object. * The local name and uri are set using the given Node. */ protected XMLRoot buildXMLRoot(Node node, Object object) { XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setLocalName(node.getLocalName()); xmlRoot.setNamespaceURI(node.getNamespaceURI()); xmlRoot.setObject(object); return xmlRoot; }
/** * Convenience method that builds an XMLRoot wrapping a given object. * The local name and uri are set using the given Node. */ protected XMLRoot buildXMLRoot(Node node, Object object) { XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setLocalName(node.getLocalName()); xmlRoot.setNamespaceURI(node.getNamespaceURI()); xmlRoot.setObject(object); return xmlRoot; }
public Object getObject() { if(object == null) { if(this.descriptor != null) { object = this.descriptor.wrapObjectInXMLRoot(this.rootRecord, this.unmarshaller.isResultAlwaysXMLRoot()); } else if(documentBuilder != null) { Node node = (Node)documentBuilder.getDocument().getDocumentElement(); XMLRoot root = new XMLRoot(); root.setLocalName(node.getLocalName()); root.setNamespaceURI(node.getNamespaceURI()); root.setObject(node); object = root; } else { if(rootRecord != null) { object = this.rootRecord.getCurrentObject(); } } } return this.object; }
rootValue.setLocalName(node.getLocalName()); rootValue.setSchemaType(schemaTypeQName); rootValue.setNamespaceURI(node.getNamespaceURI());
rootValue.setLocalName(node.getLocalName()); rootValue.setSchemaType(schemaTypeQName); rootValue.setNamespaceURI(node.getNamespaceURI());
/** * INTERNAL: * Determines the appropriate object to return from the unmarshal * call. The method will either return the object created in the * xmlReader.parse() call or an instance of XMLRoot. An XMLRoot * instance will be returned if the DOMRecord element being * unmarshalled does not equal the descriptor's default root * element. * * @param object * @param elementNamespaceUri * @param elementLocalName * @param elementPrefix * @return object */ public Object wrapObjectInXMLRoot(Object object, String elementNamespaceUri, String elementLocalName, String elementPrefix, boolean forceWrap) { if (forceWrap || shouldWrapObject(object, elementNamespaceUri, elementLocalName, elementPrefix)) { // if the DOMRecord element != descriptor's default // root element, create an XMLRoot, populate and return it XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setLocalName(elementLocalName); xmlRoot.setNamespaceURI(elementNamespaceUri); xmlRoot.setObject(object); return xmlRoot; } return object; }
public Object wrapObjectInXMLRoot(Object object, String elementNamespaceUri, String elementLocalName, String elementPrefix, String encoding, String version, boolean forceWrap) { if (forceWrap || shouldWrapObject(object, elementNamespaceUri, elementLocalName, elementPrefix)) { // if the DOMRecord element != descriptor's default // root element, create an XMLRoot, populate and return it XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setLocalName(elementLocalName); xmlRoot.setNamespaceURI(elementNamespaceUri); xmlRoot.setObject(object); xmlRoot.setEncoding(encoding); xmlRoot.setVersion(version); return xmlRoot; } return object; }
/** * Validate the given object. * @param object A single object to validate * @return true if this is a valid object, otherwise false */ public boolean validate(Object object) throws XMLMarshalException { if (object == null) { throw XMLMarshalException.nullArgumentException(); } try { // Create a new XML Record using the object's class name (not fully qualified) as the root String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement(); if (name == null) { String qualifiedName = object.getClass().getName(); int idx = qualifiedName.lastIndexOf('.'); name = qualifiedName.substring(idx + 1); } XMLDescriptor descriptor = marshaller.getDescriptor(object); XMLRoot root = new XMLRoot(); root.setObject(object); root.setLocalName(name); XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); Document doc = xmlPlatform.createDocument(); marshaller.marshal(root, doc); return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler()); } catch (XMLPlatformException e) { throw XMLMarshalException.validateException(e); } }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
protected void setOrAddAttributeValue(UnmarshalRecord unmarshalRecord, Object value, XPathFragment xPathFragment, Object collection){ if (!xmlAnyObjectMapping.usesXMLRoot()) { unmarshalRecord.setAttributeValue(value, xmlAnyObjectMapping); } else { XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setNamespaceURI(xPathFragment.getNamespaceURI()); xmlRoot.setSchemaType(unmarshalRecord.getTypeQName()); xmlRoot.setLocalName(xPathFragment.getLocalName()); xmlRoot.setObject(value); unmarshalRecord.setAttributeValue(xmlRoot, xmlAnyObjectMapping); } }
protected void setOrAddAttributeValue(UnmarshalRecord unmarshalRecord, Object value, XPathFragment xPathFragment, Object collection){ if (!xmlAnyCollectionMapping.usesXMLRoot()) { unmarshalRecord.addAttributeValue(this, value); } else { XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setNamespaceURI(xPathFragment.getNamespaceURI()); xmlRoot.setSchemaType(unmarshalRecord.getTypeQName()); xmlRoot.setLocalName(xPathFragment.getLocalName()); xmlRoot.setObject(value); unmarshalRecord.addAttributeValue(this, xmlRoot); } }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
public Object convertDataValueToObjectValue(Object dataValue, Session session) { XMLRoot root = new XMLRoot(); root.setLocalName(this.rootFragment.getLocalName()); root.setNamespaceURI(this.rootFragment.getNamespaceURI()); if(mapping.isAbstractDirectMapping()){ if ((dataValue == null) || (dataValue.getClass() != mapping.getAttributeClassification())) { try { dataValue = session.getDatasourcePlatform().convertObject(dataValue, mapping.getAttributeClassification()); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, mapping.getDescriptor(), e); } } } root.setObject(dataValue); return root; }
/** * Return a populated XMLRoot object. */ public Object getCurrentObject() { // this assumes that since we're unmarshalling to a primitive wrapper, the root // element has a single text node. if, however, the root element doesn't have // a text node as a first child, we'll try converting null String val = null; if (characters != null) { val = characters.toString(); } XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setObject(((XMLConversionManager) session.getDatasourcePlatform().getConversionManager()).convertObject(val, targetClass)); xmlRoot.setLocalName(getRootElementName()); xmlRoot.setNamespaceURI(getRootElementNamespaceUri()); return xmlRoot; }
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
if (forceWrap || shouldWrapObject(unmarshalRecord.getCurrentObject(), elementNamespaceUri, elementLocalName, elementPrefix)) { XMLRoot xmlRoot = new XMLRoot(); xmlRoot.setLocalName(elementLocalName); xmlRoot.setNamespaceURI(elementNamespaceUri); xmlRoot.setObject(unmarshalRecord.getCurrentObject());
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
XMLRoot xmlRoot = new XMLRoot(); if (value instanceof XMLRoot) { xmlRoot.setLocalName(((XMLRoot) value).getLocalName()); xmlRoot.setNamespaceURI(((XMLRoot) value).getNamespaceURI()); xmlRoot.setObject(((XMLRoot) value).getObject()); } else { xmlRoot.setLocalName(sdoProperty.getName()); xmlRoot.setNamespaceURI(sdoProperty.getUri()); xmlRoot.setObject(value);