Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMNode


     */
    public Collection getValidElements(OMDocument document) {
        ArrayList list = new ArrayList();
        Iterator itr = document.getChildren();
        while (itr.hasNext()) {
            OMNode node = (OMNode) itr.next();
            if (node.getType() == OMNode.ELEMENT_NODE || node.getType() == OMNode.PI_NODE)
                list.add(node);
        }
        return list;
    }
View Full Code Here


    public OMNode detach() throws OMException {
        // detach without expanding the tree
        boolean complete = isComplete();
        setComplete(true);
        OMNode result = super.detach();
        setComplete(complete);
        return result;
    }
View Full Code Here

        // we don't want to walk the children (because this will result
        // in an unnecessary translation from OMDataSource to a full OM tree).
        if (isExpanded()) {
            Iterator iterator = getChildren();
            while (iterator.hasNext()) {
                OMNode node = (OMNode) iterator.next();
                node.buildWithAttachments();
            }
        }
    }
View Full Code Here

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(
                metaFactory.getOMFactory(), root.getXMLStreamReader());
        OMDocument omDocument = builder.getDocument();
        Iterator it = omDocument.getChildren();
        while (it.hasNext()) {
            OMNode omNode = (OMNode) it.next();
            // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
            omNode.getNextOMSibling();
            omNode.serializeAndConsume(xmlwriter);
        }
        xmlwriter.flush();
        String result = writer.toString();
        // We can't test for equivalence because the underlying OMSourceElement is
        // changed as it is serialized.  So I am testing for an internal value.
View Full Code Here

        super(firstNode);
    }

    protected OMNode getNextNode(OMNode currentNode) {
        if (currentNode instanceof OMContainer) {
            OMNode firstChild = ((OMContainer)currentNode).getFirstOMChild();
            if (firstChild != null) {
                level++;
                return firstChild;
            }
        }
        OMNode node = currentNode;
        while (true) {
            OMNode nextSibling = node.getNextOMSibling();
            if (nextSibling != null) {
                return nextSibling;
            } else if (level == 0) {
                return null;
            } else {
View Full Code Here

       
        OMFactory factory = metaFactory.getOMFactory();
        OMElement parent = factory.createOMElement("parent", null);
        OMSourcedElement omse = factory.createOMElement(bads1, "myPayload", factory.createOMNamespace("urn://test", "tns"));
        parent.addChild(omse);
        OMNode firstChild = parent.getFirstOMChild();
        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
        OMSourcedElement child = (OMSourcedElement) firstChild;
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
                   child.getDataSource() instanceof ByteArrayDataSource);
View Full Code Here

            return false;
        } else if (nextNode != null) {
            return true;
        } else {
            while (parent.hasNext()) {
                OMNode node = (OMNode)parent.next();
                if (matches(node)) {
                    nextNode = node;
                    return true;
                }
            }
View Full Code Here

        }
    }

    public Object next() {
        if (hasNext()) {
            OMNode result = nextNode;
            nextNode = null;
            return result;
        } else {
            throw new NoSuchElementException();
        }
View Full Code Here

        InputStreamDataSource isds1 = new InputStreamDataSource(bais1, encoding);
       
        OMElement parent = factory.createOMElement("root", null);
        OMSourcedElement omse = factory.createOMElement(isds1, localName, ns);
        parent.addChild(omse);
        OMNode firstChild = parent.getFirstOMChild();
        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
        OMSourcedElement child = (OMSourcedElement) firstChild;
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a InputStreamDataSource",
                   child.getDataSource() instanceof InputStreamDataSource);
View Full Code Here

        builder.releaseParserOnClose(true);
        try {
            OMDocument omDocument = builder.getDocument();
            Iterator it = omDocument.getChildren();
            while (it.hasNext()) {
                OMNode omNode = (OMNode) it.next();
                omNode.serializeAndConsume(writer);
            }
        } finally {
            builder.close();
        }
    }
View Full Code Here

TOP

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

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.