Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement.serializeAndConsume()


        // Serialize and consume.  This should not cause expansion and currently won't update
        // the name of the element.
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
        root.serializeAndConsume(writer);
        xmlwriter.flush();
        String result = writer.toString();

        assertTrue(element.getLocalName().equals("DUMMYNAME"));
        assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
View Full Code Here


        // Serialize and consume.  This should not cause expansion and currently won't update
        // the name of the element.
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
        root.serializeAndConsume(writer);
        xmlwriter.flush();
        String result = writer.toString();

        assertTrue(element.getLocalName().equals("library"));
        assertTrue(element.getNamespace().getNamespaceURI().equals(""));
View Full Code Here

        // Serialize and consume.  This should not cause expansion and currently won't update
        // the name of the element.
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
        root.serializeAndConsume(writer);
        xmlwriter.flush();
        String result = writer.toString();

        assertTrue(element.getLocalName().equals("DUMMYNAME"));
        assertTrue(element.getNamespace().getNamespaceURI().equals("http://DUMMYNS"));
View Full Code Here

        JAXB2OMElement t1 = new JAXB2OMElement();
        OMElement om = t1.transform(po, tContext);
        long duration1 = System.currentTimeMillis() - start;
        StringWriter sw = new StringWriter();
        // serializeAndConsume() will trigger the JAXBDataSource.serialize(Writer, OMOutputFormat)
        om.serializeAndConsume(sw);
        System.out.println(sw.toString());

        start = System.currentTimeMillis();
        Node node = new JAXB2Node().transform(po, tContext);
        XMLStreamReader reader = new Node2XMLStreamReader().transform(node, null);
View Full Code Here

        start = System.currentTimeMillis();
        Node node = new JAXB2Node().transform(po, tContext);
        XMLStreamReader reader = new Node2XMLStreamReader().transform(node, null);
        om = new StAXOMBuilder(reader).getDocumentElement();
        sw = new StringWriter();
        om.serializeAndConsume(sw);
        long duration2 = System.currentTimeMillis() - start;
        System.out.println(sw.toString());
        System.out.println(duration1 + " vs. " + duration2);
    }
View Full Code Here

        TransformationContext tContext = new TransformationContextImpl();
        tContext.setSourceDataType(sourceDataType);
        tContext.setTargetDataType(targetDataType);
        OMElement om = new JAXB2OMElement().transform(po.getValue(), tContext);
        StringWriter sw = new StringWriter();
        om.serializeAndConsume(sw);
        System.out.println(sw.toString());
    }

    private JAXBElement<PurchaseOrderType> createPO() {
        ObjectFactory factory = new ObjectFactory();
View Full Code Here

                }
            } else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
                if (firstChild instanceof OMSourcedElementImpl) {
                    baos = new ByteArrayOutputStream();
                    try {
                        firstChild.serializeAndConsume(baos);
                    } catch (XMLStreamException e) {
                        handleException("Error serializing 'text' payload from OMSourcedElement", e);
                    }
                    dataHandler = new DataHandler(new String(
                        baos.toByteArray(), format.getCharSetEncoding()), MailConstants.TEXT_PLAIN);
View Full Code Here

            } else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
                try {
                    OutputStream os = responseFile.getContent().getOutputStream();
                    try {
                        if (firstChild instanceof OMSourcedElementImpl) {
                            firstChild.serializeAndConsume(os);
                        } else {
                            os.write(firstChild.getText().getBytes());
                        }
                    } finally {
                      os.close();
View Full Code Here

                                .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);

                format.setDoOptimize(false);
                format.setDoingSWA(false);
                format.setCharSetEncoding(charSetEnc);
                outputMessage.serializeAndConsume(out, format);
                out.flush();
            } catch (Exception e) {
                throw AxisFault.makeFault(e);
            }
        } else {
View Full Code Here

            OMOutputFormat format = new OMOutputFormat();
            format.setCharSetEncoding(
                    getProperty(msgContext, Constants.Configuration.CHARACTER_SET_ENCODING));
            format.setDoOptimize(msgContext.isDoingMTOM());
            try {
                msgElement.serializeAndConsume(baos, format);
                baos.flush();
            } catch (XMLStreamException e) {
                handleException("XML serialization error creating BytesMessage", e);
            } catch (IOException e) {
                handleException("IO Error while creating BytesMessage", e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.