Package org.apache.axiom.om

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


        element.setNamespace(ns);
        element.setLocalName("dummy");
        // TODO: See https://issues.apache.org/jira/browse/WSCOMMONS-226
        // element.getBuilder().setCache(true);
        StringWriter writer = new StringWriter();
        element.serializeAndConsume(writer);
        // System.out.println(writer);
    }

}
View Full Code Here


            //otherwise serialize the OM by expanding the tree
        } else {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                XMLStreamWriter jsonWriter = getJSONWriter(bytesOut, format);
                element.serializeAndConsume(jsonWriter);
                jsonWriter.writeEndDocument();

                return bytesOut.toByteArray();

            } catch (XMLStreamException e) {
View Full Code Here

                    jsonString = getStringToWrite(((OMSourcedElement)
                            dataOut).getDataSource());
                } else {
                    StringWriter out = new StringWriter();
                    XMLStreamWriter jsonWriter = getJSONWriter(out);
                    dataOut.serializeAndConsume(jsonWriter);
                    jsonWriter.writeEndDocument();
                    jsonString = out.toString();
                }
                jsonString = URIEncoderDecoder.quoteIllegal(jsonString,
                        WSDL2Constants.LEGAL_CHARACTERS_IN_URL);
View Full Code Here

        element.setNamespace(ns);
        element.setLocalName("dummy");
        // TODO: See https://issues.apache.org/jira/browse/WSCOMMONS-226
        // element.getBuilder().setCache(true);
        StringWriter writer = new StringWriter();
        element.serializeAndConsume(writer);
        // System.out.println(writer);
    }

}
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

        // Serialize and consume.  This should not cause expansion and currently won't update
        // the name of the element.
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.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 = StAXUtils.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 = StAXUtils.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

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.