Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMSourcedElement


        if (targetDS == null) {
            copyOMElement(factory, targetParent, sourceOMSE);
            return;
        }
        // Otherwise create a target OMSE with the copied DataSource
        OMSourcedElement targetOMSE =
            factory.createOMElement(targetDS,
                                    sourceOMSE.getLocalName(),
                                    sourceOMSE.getNamespace());
        targetParent.addChild(targetOMSE);
View Full Code Here


        // Create a payload
        String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
        String encoding = "UTF-8";
        ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
        OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
        OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
        body.addChild(omse);
        copyAndCheck(sourceEnv, true);
    }
View Full Code Here

       
        // Create a payload
        String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
        ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
        OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
        OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
        body.addChild(omse);
       
        copyAndCheck(sourceEnv, true);
       
        // The source SOAPHeaderBlock should not be expanded in the process
View Full Code Here

    public void testGetTextAsStreamWithOMSourcedElement() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        DataSource ds = new RandomDataSource(445566, 32, 128, 20000000);
        QName qname = new QName("a");
        Charset cs = Charset.forName("ascii");
        OMSourcedElement element = new OMSourcedElementImpl(qname, factory,
                new WrappedTextNodeOMDataSourceFromDataSource(qname, ds, cs));
        Reader in = ElementHelper.getTextAsStream(element, true);
        assertFalse(in instanceof StringReader);
        IOTestUtils.compareStreams(new InputStreamReader(ds.getInputStream(), cs), in);
    }
View Full Code Here

   
    public void testWriteTextToWithOMSourcedElement() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        DataSource ds = new RandomDataSource(665544, 32, 128, 20000000);
        QName qname = new QName("a");
        OMSourcedElement element = new OMSourcedElementImpl(qname, factory,
                new WrappedTextNodeOMDataSourceFromDataSource(qname, ds, Charset.forName("ascii")));
        Reader in = new InputStreamReader(ds.getInputStream(), "ascii");
        Writer out = new CharacterStreamComparator(in);
        ElementHelper.writeTextTo(element, out, true); // cache doesn't matter here
        out.close();
View Full Code Here

        // Create a payload
        String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
        String encoding = "UTF-8";
        ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
        OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
        OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
        body.addChild(omse);
        copyAndCheck(sourceEnv, true);
    }
View Full Code Here

       
        // Create a payload
        String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
        ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
        OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
        OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
        body.addChild(omse);
       
        copyAndCheck(sourceEnv, true);
       
        // The source SOAPHeaderBlock should not be expanded in the process
View Full Code Here

        }
        String testData = buffer.toString();
        QName qname = new QName("data");
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader(testData));
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMSourcedElement element = new OMSourcedElementImpl(qname, factory, ds);
        assertEquals(testData, element.getText());
    }
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory omFactory = metaFactory.getOMFactory();
        OMDataSource ds = new CharArrayDataSource("<a>test</a>".toCharArray());
        OMElement root = omFactory.createOMElement(new QName("root"));
        OMSourcedElement child = omFactory.createOMElement(ds, "a", null);
        root.addChild(child);
        assertFalse(child.isExpanded());
        XMLStreamReader stream = root.getXMLStreamReader();
        assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
        assertEquals("root", stream.getLocalName());
        assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
        assertEquals(XMLStreamReader.CHARACTERS, stream.next());
        assertEquals("test", stream.getText());
        assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
        assertEquals(XMLStreamReader.END_ELEMENT, stream.next());
        assertEquals(XMLStreamReader.END_DOCUMENT, stream.next());
        assertFalse(child.isExpanded());
    }
View Full Code Here

        if (targetDS == null) {
            copyOMElement(factory, targetParent, sourceOMSE);
            return;
        }
        // Otherwise create a target OMSE with the copied DataSource
        OMSourcedElement targetOMSE =
            factory.createOMElement(targetDS,
                                    sourceOMSE.getLocalName(),
                                    sourceOMSE.getNamespace());
        targetParent.addChild(targetOMSE);
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMSourcedElement

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.