Package org.eclipse.persistence.oxm

Examples of org.eclipse.persistence.oxm.XMLRoot


            }

            if (!xmlAnyObjectMapping.usesXMLRoot()) {
                unmarshalRecord.setAttributeValue(value, xmlAnyObjectMapping);
            } else {
                XMLRoot xmlRoot = new XMLRoot();
                xmlRoot.setNamespaceURI(xPathFragment.getNamespaceURI());
                xmlRoot.setSchemaType(qname);
                xmlRoot.setLocalName(xPathFragment.getLocalName());
                xmlRoot.setObject(value);
                unmarshalRecord.setAttributeValue(xmlRoot, xmlAnyObjectMapping);
            }
        }
    }
View Full Code Here


            String propertyName = null;
            String propertyUri = null;
            Object value = null;
            Type theType = null;
            if (next instanceof XMLRoot) {
                XMLRoot nextXMLRoot = (XMLRoot)next;
                value = nextXMLRoot.getObject();
                propertyName = nextXMLRoot.getLocalName();
                propertyUri = nextXMLRoot.getNamespaceURI();
                if (value instanceof DataObject) {
                    theType = ((DataObject)value).getType();
                } else {
                    theType = ((SDOTypeHelper)aHelperContext.getTypeHelper()).getTypeForSimpleJavaType(value.getClass());
                }
View Full Code Here

    public List _getOpenContentPropertiesWithXMLRoots() {
        List returnList = new ArrayList();
        for (int i = 0, size = openContentProperties.size(); i < size; i++) {
            Property next = (Property)openContentProperties.get(i);

            XMLRoot root = new XMLRoot();
            String localName = ((SDOProperty)next).getXPath();
            if (next.getType() != null) {
                if (!next.getType().isDataType()) {
                    String uri = ((SDOProperty)next).getUri();
                    root.setNamespaceURI(uri);
                } else {
                    String uri = ((SDOProperty)next).getUri();
                    root.setNamespaceURI(uri);
                }
            }

            root.setLocalName(localName);

            Object value = get(next);
            if (next.isMany()) {
                for (int j = 0, sizel = ((List)value).size(); j < sizel; j++) {
                    XMLRoot nextRoot = new XMLRoot();
                    nextRoot.setNamespaceURI(root.getNamespaceURI());
                    nextRoot.setLocalName(root.getLocalName());
                    Object nextItem = ((List)value).get(j);
                    if ((next.getType() != null) && (((SDOType)next.getType()).getXmlDescriptor() == null)) {
                        nextItem = XMLConversionManager.getDefaultXMLManager().convertObject(nextItem, String.class);
                    }
                    nextRoot.setObject(nextItem);
                    returnList.add(nextRoot);
                }
            } else {
                if ((next.getType() != null) && (((SDOType)next.getType()).getXmlDescriptor() == null)) {
                    value = XMLConversionManager.getDefaultXMLManager().convertObject(value, String.class);
View Full Code Here

        return value;
    }

    @SuppressWarnings("unchecked")
    public Object createSimpleXMLFormat(XRServiceAdapter xrService, Object value) {
        XMLRoot xmlRoot = new XMLRoot();
        SimpleXMLFormat simpleXMLFormat = result.getSimpleXMLFormat();
        String tempSimpleXMLFormatTag = SimpleXMLFormat.DEFAULT_SIMPLE_XML_FORMAT_TAG;
        String simpleXMLFormatTag = simpleXMLFormat.getSimpleXMLFormatTag();
        if (simpleXMLFormatTag != null && !"".equals(simpleXMLFormatTag)) {
            tempSimpleXMLFormatTag = simpleXMLFormatTag;
        }
        xmlRoot.setLocalName(tempSimpleXMLFormatTag);
        String tempXMLTag = DEFAULT_SIMPLE_XML_TAG;
        String xmlTag = simpleXMLFormat.getXMLTag();
        if (xmlTag != null && !"".equals(xmlTag)) {
            tempXMLTag = xmlTag;
        }
        Vector<DatabaseRecord> records = null;
        if (value instanceof Vector) {
            records = (Vector<DatabaseRecord>)value;
        }
        else {
            records = new Vector<DatabaseRecord>();
            DatabaseRecord dr = new DatabaseRecord();
            dr.add(new DatabaseField("result"), value);
            records.add(dr);
        }
        SimpleXMLFormatModel simpleXMLFormatModel = new SimpleXMLFormatModel();
        XMLConversionManager conversionManager =
            (XMLConversionManager) xrService.getOXSession().getDatasourcePlatform().getConversionManager();
        for (DatabaseRecord dr : records) {
            Element rowElement = TEMP_DOC.createElement(tempXMLTag);
            for (DatabaseField field : (Vector<DatabaseField>)dr.getFields()) {
                Object fieldValue = dr.get(field);
                if (fieldValue != null) {
                    if (fieldValue instanceof Calendar) {
                        Calendar cValue = (Calendar)fieldValue;
                        fieldValue = conversionManager.convertObject(cValue, STRING,
                          DATE_TIME_QNAME);
                    }
                    if (fieldValue instanceof Date) {
                        Date dValue = (Date)fieldValue;
                        fieldValue = conversionManager.convertObject(dValue, STRING,
                          DATE_QNAME);
                    }
                    else if (fieldValue instanceof Time) {
                        Time tValue = (Time)fieldValue;
                        fieldValue = conversionManager.convertObject(tValue, STRING,
                          TIME_QNAME);
                    }
                    else if (fieldValue instanceof Timestamp) {
                        Timestamp tsValue = (Timestamp)fieldValue;
                        fieldValue = conversionManager.convertObject(tsValue, STRING,
                          DATE_TIME_QNAME);
                    }
                    String elementName = sqlToXmlName(field.getName());
                    Element columnElement = TEMP_DOC.createElement(elementName);
                    rowElement.appendChild(columnElement);
                    columnElement.appendChild(TEMP_DOC.createTextNode(fieldValue.toString()));
                }
            }
            simpleXMLFormatModel.simpleXML.add(rowElement);
        }
        xmlRoot.setObject(simpleXMLFormatModel);
        return xmlRoot;
    }
View Full Code Here

      Object iterator = containerPolicy.iteratorFor(value);
      while(containerPolicy.hasNext(iterator)) {
        Object next = containerPolicy.next(iterator, null);
        if(next instanceof JAXBElement) {
          JAXBElement element = (JAXBElement)next;
          XMLRoot root = new XMLRoot();
          root.setLocalName(element.getName().getLocalPart());
          root.setNamespaceURI(element.getName().getNamespaceURI());
          root.setObject(element.getValue());
          containerPolicy.addInto(root, results, null);
        } else {
          containerPolicy.addInto(next, results, null);
        }
      }
      value = results;
    } else {
      if(value instanceof JAXBElement) {
        JAXBElement element = (JAXBElement)value;
        XMLRoot root = new XMLRoot();
        root.setLocalName(element.getName().getLocalPart());
        root.setNamespaceURI(element.getName().getNamespaceURI());
        root.setObject(element.getValue());
        value = root;
      }
    }
    return value;
  }
View Full Code Here

      Object results = containerPolicy.containerInstance(containerPolicy.sizeFor(attributeValue));
      Object iterator = containerPolicy.iteratorFor(attributeValue);
      while(containerPolicy.hasNext(iterator)) {
        Object next = containerPolicy.next(iterator, null);
        if(next instanceof XMLRoot) {
          XMLRoot root = (XMLRoot)next;
          QName name = new QName(root.getNamespaceURI(), root.getLocalName());
          JAXBElement element = new JAXBElement(name, root.getObject().getClass(), root.getObject());
          containerPolicy.addInto(element, results, null);
        } else {
          containerPolicy.addInto(next, results, null);
        }
      }
      attributeValue = results;
    } else {
      if(attributeValue instanceof XMLRoot) {
        XMLRoot root = (XMLRoot)attributeValue;
        QName name = new QName(root.getNamespaceURI(), root.getLocalName());
        JAXBElement element = new JAXBElement(name, root.getObject().getClass(), root.getObject());
        attributeValue = element;
      }     
    }
    nestedAccessor.setAttributeValueInObject(object, attributeValue);
  }
View Full Code Here

                /* safe to ignore */
            }
            throw new SOAPFaultException(soapFault);
        }

        XMLRoot xmlRoot = null;
        try {
            XMLContext xmlContext = dbwsAdapter.getXMLContext();
            xmlRoot = (XMLRoot)xmlContext.createUnmarshaller().unmarshal(body,
                Invocation.class);
        }
        catch (XMLMarshalException e) {
            SOAPFault soapFault = null;
            try {
                soapFault = getSOAPFactory().createFault("SOAPMessage request format error - " +
                    e.getMessage(),new QName(URI_NS_SOAP_1_1_ENVELOPE, "Client"));
            }
            catch (SOAPException se) {
                // ignore
            }
            throw new SOAPFaultException(soapFault);
        }

        Invocation invocation = (Invocation)xmlRoot.getObject();
        invocation.setName(xmlRoot.getLocalName());
        Operation op = dbwsAdapter.getOperation(invocation.getName());
        /*
         * Fix up types for arguments - scan the extended schema for the operation's Request type.
         *
         * For most parameters, the textual node content is fine, but for date/time and
View Full Code Here

    public void marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
      NodeValue associatedNodeValue = null;
      XMLField associatedField = null;
      Object fieldValue = value;
      if(value instanceof XMLRoot) {
        XMLRoot rootValue = (XMLRoot)value;
        String localName = rootValue.getLocalName();
        String namespaceUri = rootValue.getNamespaceURI();
        fieldValue = rootValue.getObject();
        associatedField = getFieldForName(localName, namespaceUri);
        if(associatedField == null) {
          associatedField = xmlChoiceCollectionMapping.getClassToFieldMappings().get(value.getClass());
        }
      } else {
View Full Code Here

                // try converting null
                nodeVal = null;
            }
 
            Object obj = ((XMLConversionManager) xmlContext.getSession(0).getDatasourcePlatform().getConversionManager()).convertObject(nodeVal, referenceClass);
            XMLRoot xmlRoot = new XMLRoot();
            xmlRoot.setObject(obj);
            String lName = xmlRow.getDOM().getLocalName();
            if (lName == null) {
                lName = xmlRow.getDOM().getNodeName();
            }
            xmlRoot.setLocalName(lName);
            xmlRoot.setNamespaceURI(xmlRow.getDOM().getNamespaceURI());
            xmlRoot.setEncoding(xmlEncoding);
            xmlRoot.setVersion(xmlVersion);
            return xmlRoot;
        }

        // for XMLObjectReferenceMappings we need a non-shared cache, so
        // try and get a Unit Of Work from the XMLContext
View Full Code Here

    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()).getXmlMarshaller();
        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();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.oxm.XMLRoot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.