Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMDataSource


    }
   
    // Test for WSCOMMONS-453
    public void _testOMSourcedElementDescendent() throws Exception {
        OMFactory omFactory = omMetaFactory.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


        // 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 OMStAXWrapper) {
                ds = ((OMStAXWrapper) reader).getDataSource();
            }
            if (ds != null) {
                ds.serialize(writer);
            } else {
                switch (event) {
                case START_ELEMENT:
                    serializeElement(reader, writer);
                    depth++;
View Full Code Here

        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

     * @return true if this OMNode should be considered a leaf node
     */
    private boolean isLeaf(OMSerializable n) {
        if (n instanceof OMContainer) {
            if (this.isDataSourceALeaf && (n instanceof OMSourcedElement) && n != root) {
                OMDataSource ds = null;
                try {
                    ds = ((OMSourcedElement) n).getDataSource();
                } catch (UnsupportedOperationException e) {
                    ; // Operation unsupported for some implementations
                }
View Full Code Here

    private static void copyOMSourcedElement(SOAPFactory factory,
                                             OMContainer targetParent,
                                             OMSourcedElement sourceOMSE) {
        // If already expanded or this is not an OMDataSourceExt, then
        // create a copy of the OM Tree
        OMDataSource ds = sourceOMSE.getDataSource();
        if (ds == null ||
            sourceOMSE.isExpanded() ||
            !(ds instanceof OMDataSourceExt)) {
            copyOMElement(factory, targetParent, sourceOMSE);
            return;
View Full Code Here

    private static void copySOAPHeaderBlock(SOAPFactory factory,
                                            OMContainer targetParent,
                                            SOAPHeaderBlock sourceSHB) {
        // If already expanded or this is not an OMDataSourceExt, then
        // create a copy of the OM Tree
        OMDataSource ds = sourceSHB.getDataSource();
        if (ds == null ||
            sourceSHB.isExpanded() ||
            !(ds instanceof OMDataSourceExt)) {
            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
            return;
View Full Code Here

        // 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

    /**
     * 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

     * @param key
     * @return requested OMDataSourceExt property or null
     */
    protected boolean hasOMDataSourceProperty(String key) {
        if (!this.isExpanded()) {
            OMDataSource ds = this.getDataSource();
            if (ds instanceof OMDataSourceExt) {
                return ((OMDataSourceExt)ds).hasProperty(key);
            }
        }
        return false;
View Full Code Here

        for (int i=0; i<40000; i++) {
            buffer.append((char)(32 + random.nextInt(96)));
        }
        String testData = buffer.toString();
        QName qname = new QName("data");
        OMDataSource ds = new WrappedTextNodeOMDataSourceFromReader(qname, new StringReader(testData));
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMSourcedElement element = factory.createOMElement(ds, qname);
        assertEquals(testData, element.getText());
    }
View Full Code Here

TOP

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

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.