Examples of transform()


Examples of org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReaderTransformer.transform()

        bean.str = "ABC";
        bean.i = 1;
        bean.arr = new long[] {1, 2, 3};
        bean.bean = new AnotherBean();
        bean.bean.setName("Name");
        XMLStreamReader reader = t2.transform(bean, null);
        XMLStreamReader2String t3 = new XMLStreamReader2String();
        String xml = t3.transform(reader, null);
        XMLAssert.assertXMLEqual(XML_RESULT, xml);

    }

Examples of org.apache.tuscany.sca.databinding.jaxb.JAXB2Node.transform()

        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
        expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
        replay(tContext1);

        JAXB2Node t1 = new JAXB2Node();
        Node node = t1.transform(object1, tContext1);

        Assert.assertNotNull(node);

        Node2JAXB t2 = new Node2JAXB();
        Object object2 = t2.transform(node, tContext);

Examples of org.apache.tuscany.sca.databinding.jaxb.Node2JAXB.transform()

        Node node = t1.transform(object1, tContext1);

        Assert.assertNotNull(node);

        Node2JAXB t2 = new Node2JAXB();
        Object object2 = t2.transform(node, tContext);
        Assert.assertNotNull(object2);

    }

    public void testTransform2() throws Exception {

Examples of org.apache.tuscany.sca.databinding.jaxb.Reader2JAXB.transform()

        TransformationContext tContext = createMock(TransformationContext.class);
        expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
        replay(tContext);

        Object object1 = t0.transform(new StringReader(IPO_XML), tContext);

        DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);

        TransformationContext tContext1 = createMock(TransformationContext.class);
        expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();

Examples of org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement.transform()

        // Force the JAXBContext to be cached
        contextHelper.createJAXBContext(tContext, true);

        long start = System.currentTimeMillis();
        JAXB2OMElement t1 = new JAXB2OMElement(registry);
        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());

Examples of org.apache.tuscany.sca.databinding.json.JSON2XMLStreamReader.transform()

    }

    public void testJSON2XML() throws Exception {
        JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
        XMLStreamReader reader2 = t2.transform(new JSONObject(JSON_STR), null);
        StringWriter sw = new StringWriter();
        XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
        new XMLStreamSerializer().serialize(reader2, streamWriter);
        streamWriter.flush();
        Assert.assertTrue(sw.toString()

Examples of org.apache.tuscany.sca.databinding.json.XMLStreamReader2JSON.transform()

    private static final String JSON_STR = "{\"xsl:root\":{\"@xmlns\":{\"xsl\":\"http://foo.com\"},\"data\":{\"$\":\"my json string\"}}}";

    public void testXML2JSON() throws Exception {
        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(IPO_XML));
        XMLStreamReader2JSON t1 = new XMLStreamReader2JSON();
        JSONObject json = t1.transform(reader, null);
        Assert.assertNotNull(json);

        // Cannot round-trip as we hit a bug in Jettison
        /*
         JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();

Examples of org.apache.tuscany.sca.databinding.json.axiom.JSON2OMElement.transform()

    public void testJSON2OMElement() throws Exception {
        JSON2OMElement t1 = new JSON2OMElement();
        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
    }

Examples of org.apache.tuscany.sca.databinding.xml.InputStream2Node.transform()

            InputStream2Node t1 = new InputStream2Node();
            FastInfoset2Node t2 = new FastInfoset2Node();
            InputStream is1 = new ByteArrayInputStream(str);
            InputStream is2 = new ByteArrayInputStream(fast);
            long s1 = System.currentTimeMillis();
            Node n1 = t1.transform(is1, null);
            long s2 = System.currentTimeMillis();
            Node n2 = t2.transform(is2, null);
            long s3 = System.currentTimeMillis();
            d1 += s2 - s1; // from plain xml
            d2 += s3 - s2; // from fastinfoset

Examples of org.apache.tuscany.sca.databinding.xml.Node2OutputStream.transform()

            Node2OutputStream t3 = new Node2OutputStream();
            Node2FastInfoset t4 = new Node2FastInfoset();
            ByteArrayOutputStream os1 = new ByteArrayOutputStream();
            ByteArrayOutputStream os2 = new ByteArrayOutputStream();
            long s4 = System.currentTimeMillis();
            t3.transform(n1, os1, null);
            long s5 = System.currentTimeMillis();
            t4.transform(n2, os2, null);
            long s6 = System.currentTimeMillis();
            d1 += s5 - s4; // to plain xml
            d2 += s6 - s5; // to fastinfoset
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.