Examples of OMDataSource


Examples of org.apache.axiom.om.OMDataSource

        // If not startAtNext, then seed the processing with the current element.
        boolean useCurrentEvent = !startAtNext;
       
        while (reader.hasNext() || useCurrentEvent) {
            int event = 0;
            OMDataSource ds = null;
            if (useCurrentEvent) {
                event = reader.getEventType();
                useCurrentEvent = false;
            } else {
                event = reader.next();
            }
           
            // If the reader is exposing a DataSourc
            // for this event, then simply serialize the
            // DataSource
            if (reader instanceof OMXMLStreamReaderEx) {
                ds = ((OMXMLStreamReaderEx) reader).getDataSource();
            }
            if (ds != null) {
                ds.serialize(writer);
            } else {
                switch (event) {
                case START_ELEMENT:
                    serializeElement(reader, writer);
                    depth++;
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

    }

    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
        // If already expanded or this is not an OMDataSourceExt, then
        // create a copy of the OM Tree
        OMDataSource ds = getDataSource();
        if (!options.isCopyOMDataSources() ||
            ds == null ||
            isExpanded() ||
            !(ds instanceof OMDataSourceExt)) {
            return super.clone(options, targetParent);
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

    /**
     * setOMDataSource
     */
    public OMDataSource setDataSource(OMDataSource dataSource) {
        if (!isExpanded()) {
            OMDataSource oldDS = this.dataSource;
            this.dataSource = dataSource;
            return oldDS;  // Caller is responsible for closing the data source
        } else {
            // TODO
            // Remove the entire subtree and replace with
            // new datasource.  There maybe a more performant way to do this.
            OMDataSource oldDS = this.dataSource;
            Iterator it = getChildren();
            while(it.hasNext()) {
                it.next();
                it.remove();
            }
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMDataSource ds = new ByteArrayDataSource("<root><a/></root>".getBytes("utf-8"), "utf-8");
        OMSourcedElement element = factory.createOMElement(ds);
        // Force expansion
        element.getFirstOMChild();
        OMXMLParserWrapper builder = element.getBuilder();
        try {
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        addTestProperty("copyOMDataSources", String.valueOf(copyOMDataSources));
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromDataSource(new QName("wrapper"),
                new ByteArrayDataSource("test".getBytes("utf-8")), Charset.forName("utf-8"));
        OMSourcedElement element = factory.createOMElement(ds);
        OMCloneOptions options = new OMCloneOptions();
        options.setCopyOMDataSources(copyOMDataSources);
        OMElement clone = (OMElement)element.clone(options);
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMDataSource ds = new ByteArrayDataSource("<p:element xmlns:p='urn:ns'>test</p:element>".getBytes("utf-8"), "utf-8");
        OMSourcedElement element = factory.createOMElement(ds);
        OMCloneOptions options = new OMCloneOptions();
        options.setCopyOMDataSources(true);
        OMElement clone = (OMElement)element.clone(options);
        assertTrue(clone instanceof OMSourcedElement);
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        private void addPayload() throws XMLStreamException {
            if (elementDepth <= 0 && !payloadAdded) {
                delegate.flush();
                if (baos.size() > 0) {
                    byte[] buf = baos.toByteArray();
                    OMDataSource dataSource = new ByteArrayDataSource(buf, encoding);
                    OMNamespace namespace =
                            getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix());
                    OMElement payloadElement =
                            getAxiomFactory().createOMElement(dataSource, name.getLocalPart(), namespace);
                    getAxiomBody().addChild(payloadElement);
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        return (SOAPBody) getAxiomElement();
    }

    public void setStreamingPayload(StreamingPayload payload) {
        Assert.notNull(payload, "'payload' must not be null");
        OMDataSource dataSource = new StreamingOMDataSource(payload);
        OMElement payloadElement = getAxiomFactory().createOMElement(dataSource, payload.getName());

        SOAPBody soapBody = getAxiomBody();
        AxiomUtils.removeContents(soapBody);
        soapBody.addChild(payloadElement);
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        if (getEventType() != XMLStreamReader.START_ELEMENT ||
                !(state == this.NAVIGABLE ||
                  state == this.SWITCH_AT_NEXT)) {
            return null;
        }
        OMDataSource ds = null;
        if (lastNode != null &&
            lastNode instanceof OMSourcedElement) {
            try {
                ds = ((OMSourcedElement) lastNode).getDataSource();
            } catch (UnsupportedOperationException e) {
View Full Code Here

Examples of org.apache.axiom.om.OMDataSource

        super(metaFactory);
    }

    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();
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.