ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1608212 - in /webservices/axiom/trunk/modules: axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ axiom-dom/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/
Date Sun, 06 Jul 2014 14:49:25 GMT
Author: veithen
Date: Sun Jul  6 14:49:24 2014
New Revision: 1608212

URL: http://svn.apache.org/r1608212
Log:
More duplicate code reduction.

Added:
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java
  (with props)
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainerSupport.aj
Modified:
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerSupport.aj
    webservices/axiom/trunk/modules/axiom-dom/pom.xml
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
    webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerSupport.aj?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerSupport.aj
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerSupport.aj
Sun Jul  6 14:49:24 2014
@@ -18,11 +18,15 @@
  */
 package org.apache.axiom.om.impl.common;
 
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.sax.SAXResult;
 
 import org.apache.axiom.om.NodeUnavailableException;
 import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
@@ -35,6 +39,7 @@ import org.apache.axiom.om.impl.builder.
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.serializer.pull.OMXMLStreamReaderExAdapter;
 import org.apache.axiom.om.impl.common.serializer.pull.PullSerializer;
+import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
 import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -80,6 +85,10 @@ public aspect OMContainerSupport {
         return reader;
     }
     
+    public void IContainer.addChild(OMNode omNode) {
+        addChild(omNode, false);
+    }
+
     public void IContainer.addChild(OMNode omNode, boolean fromBuilder) {
         OMNodeEx child;
         if (fromBuilder) {
@@ -211,6 +220,61 @@ public aspect OMContainerSupport {
         }
     }
     
+    public Iterator OMContainer.getChildren() {
+        return new OMChildrenIterator(getFirstOMChild());
+    }
+
+    public Iterator OMContainer.getChildrenWithLocalName(String localName) {
+        return new OMChildrenLocalNameIterator(getFirstOMChild(), localName);
+    }
+
+    public Iterator OMContainer.getChildrenWithNamespaceURI(String uri) {
+        return new OMChildrenNamespaceIterator(getFirstOMChild(), uri);
+    }
+
+    public Iterator OMContainer.getChildrenWithName(QName elementQName) {
+        OMNode firstChild = getFirstOMChild();
+        Iterator it =  new OMChildrenQNameIterator(firstChild, elementQName);
+        
+        // The getChidrenWithName method used to tolerate an empty namespace
+        // and interpret that as getting any element that matched the local
+        // name.  There are custmers of axiom that have hard-coded dependencies
+        // on this semantic.
+        // The following code falls back to this legacy behavior only if
+        // (a) elementQName has no namespace, (b) the new iterator finds no elements
+        // and (c) there are children.
+        // TODO: DOOM actually supported elementQName == null; need to test and document
this
+        if (elementQName != null && elementQName.getNamespaceURI().length() == 0
&&
+            firstChild != null &&
+            !it.hasNext()) {
+            if (log.isTraceEnabled()) {
+                log.trace("There are no child elements that match the unqualifed name: "
+
+                          elementQName);
+                log.trace("Now looking for child elements that have the same local name.");
+            }
+            it = new OMChildrenLegacyQNameIterator(getFirstOMChild(), elementQName);
+        }
+        
+        return it;
+    }
+    
+    public Iterator OMContainer.getDescendants(boolean includeSelf) {
+        return new OMDescendantsIterator(this, includeSelf);
+    }
+
+    public OMElement OMContainer.getFirstChildWithName(QName elementQName) throws OMException
{
+        OMChildrenQNameIterator omChildrenQNameIterator =
+                new OMChildrenQNameIterator(getFirstOMChild(),
+                                            elementQName);
+        OMNode omNode = null;
+        if (omChildrenQNameIterator.hasNext()) {
+            omNode = (OMNode) omChildrenQNameIterator.next();
+        }
+
+        return ((omNode != null) && (OMNode.ELEMENT_NODE == omNode.getType())) ?
+                (OMElement) omNode : null;
+    }
+
     public SAXResult OMContainer.getSAXResult() {
         SAXResultContentHandler handler = new SAXResultContentHandler(this);
         SAXResult result = new SAXResult();

Modified: webservices/axiom/trunk/modules/axiom-dom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/pom.xml?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/pom.xml (original)
+++ webservices/axiom/trunk/modules/axiom-dom/pom.xml Sun Jul  6 14:49:24 2014
@@ -142,6 +142,7 @@
                     <instructions>
                         <Private-Package>org.apache.axiom.*</Private-Package>
                         <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+                        <Import-Package>!org.aspectj.*,*</Import-Package>
                     </instructions>
                 </configuration>
             </plugin>

Added: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java?rev=1608212&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java
(added)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java
Sun Jul  6 14:49:24 2014
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.dom;
+
+import org.apache.axiom.om.impl.common.IContainer;
+import org.w3c.dom.Node;
+
+public interface DOMContainer extends Node, IContainer {
+
+}

Propchange: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainerSupport.aj?rev=1608212&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainerSupport.aj
(added)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMContainerSupport.aj
Sun Jul  6 14:49:24 2014
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.dom;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.traverse.OMFilterIterator;
+import org.apache.axiom.om.impl.traverse.OMQNameFilterIterator;
+import org.apache.axiom.om.impl.traverse.OMQualifiedNameFilterIterator;
+import org.w3c.dom.NodeList;
+
+public aspect DOMContainerSupport {
+    declare parents: (NodeImpl+ && OMContainer+) implements DOMContainer;
+
+    private NodeList DOMContainer.getElementsWildcard() {
+        return new NodeListImpl() {
+            protected Iterator getIterator() {
+                return new OMFilterIterator(getDescendants(false)) {
+                    protected boolean matches(OMNode node) {
+                        return node.getType() == OMNode.ELEMENT_NODE;
+                    }
+                };
+            }
+        };
+    }
+    
+    public final NodeList DOMContainer.getElementsByTagNameNS(String namespaceURI, String
localName) {
+        if ("*".equals(namespaceURI) && "*".equals(localName)) {
+            return getElementsWildcard();
+        } else {
+            final QName qname = new QName(namespaceURI, localName);
+            return new NodeListImpl() {
+                protected Iterator getIterator() {
+                    return new OMQNameFilterIterator(getDescendants(false), qname);
+                }
+            };
+        }
+    }
+    
+    public final NodeList DOMContainer.getElementsByTagName(final String name) {
+        if (name.equals("*")) {
+            return getElementsWildcard();
+        } else {
+            return new NodeListImpl() {
+                protected Iterator getIterator() {
+                    return new OMQualifiedNameFilterIterator(getDescendants(false), name);
+                }
+            };
+        }
+    }
+
+    void DOMContainer.notifyChildComplete() {
+        if (!this.isComplete() && getBuilder() == null) {
+            Iterator iterator = getChildren();
+            while (iterator.hasNext()) {
+                OMNode node = (OMNode) iterator.next();
+                if (!node.isComplete()) {
+                    return;
+                }
+            }
+            this.setComplete(true);
+        }
+    }
+}

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Sun Jul  6 14:49:24 2014
@@ -1101,7 +1101,7 @@ public class ElementImpl extends ParentN
             if (!complete) {
                 parentNode.setComplete(false);
             } else {
-                parentNode.notifyChildComplete();
+                ((DOMContainer)parentNode).notifyChildComplete();
             }
         }
     }

Modified: webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Sun Jul  6 14:49:24 2014
@@ -21,34 +21,21 @@ package org.apache.axiom.om.impl.dom;
 
 import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.common.IContainer;
 import org.apache.axiom.om.impl.common.IParentNode;
-import org.apache.axiom.om.impl.common.OMChildrenLocalNameIterator;
-import org.apache.axiom.om.impl.common.OMChildrenNamespaceIterator;
-import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
-import org.apache.axiom.om.impl.common.OMDescendantsIterator;
 import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
-import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
-import org.apache.axiom.om.impl.traverse.OMFilterIterator;
-import org.apache.axiom.om.impl.traverse.OMQNameFilterIterator;
-import org.apache.axiom.om.impl.traverse.OMQualifiedNameFilterIterator;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
-import javax.xml.namespace.QName;
 import javax.xml.transform.sax.SAXSource;
 
-import java.util.Iterator;
-
 public abstract class ParentNode extends NodeImpl implements NodeList, IParentNode {
 
     protected NodeImpl firstChild;
@@ -67,58 +54,6 @@ public abstract class ParentNode extends
         insertBefore(node, null, false);
     }
     
-    public void addChild(OMNode omNode) {
-        ((IContainer)this).addChild(omNode, false);
-    }
-
-    public Iterator getChildren() {
-        return new OMChildrenIterator(getFirstOMChild());
-    }
-
-    public Iterator getDescendants(boolean includeSelf) {
-        return new OMDescendantsIterator((OMContainer)this, includeSelf);
-    }
-
-    /**
-     * Returns an iterator of child nodes having a given qname.
-     *
-     * @see org.apache.axiom.om.OMContainer#getChildrenWithName (javax.xml.namespace.QName)
-     */
-    public Iterator getChildrenWithName(QName elementQName) throws OMException {
-        return new OMChildrenQNameIterator(getFirstOMChild(), elementQName);
-    }
-    
-    public Iterator getChildrenWithLocalName(String localName) {
-        return new OMChildrenLocalNameIterator(getFirstOMChild(),
-                                               localName);
-    }
-
-
-    public Iterator getChildrenWithNamespaceURI(String uri) {
-        return new OMChildrenNamespaceIterator(getFirstOMChild(),
-                                               uri);
-    }
-
-    /**
-     * Returns the first OMElement child node.
-     *
-     * @see org.apache.axiom.om.OMContainer#getFirstChildWithName (javax.xml.namespace.QName)
-     */
-    public OMElement getFirstChildWithName(QName elementQName)
-            throws OMException {
-        Iterator children = new OMChildrenQNameIterator(getFirstOMChild(),
-                                                        elementQName);
-        while (children.hasNext()) {
-            OMNode node = (OMNode) children.next();
-
-            // Return the first OMElement node that is found
-            if (node instanceof OMElement) {
-                return (OMElement) node;
-            }
-        }
-        return null;
-    }
-
     public OMNode getFirstOMChildIfAvailable() {
         return (OMNode)firstChild;
     }
@@ -255,11 +190,9 @@ public abstract class ParentNode extends
                 newDomChild.setParent(this, useDomSemantics);
             }
         } else {
-            Iterator children = this.getChildren();
+            NodeImpl tempNode = (NodeImpl)getFirstChild();
             boolean found = false;
-            while (children.hasNext()) {
-                NodeImpl tempNode = (NodeImpl) children.next();
-
+            while (tempNode != null) {
                 if (tempNode.equals(refChild)) {
                     // RefChild found
                     if (this.firstChild == tempNode) { // If the refChild is the
@@ -331,6 +264,7 @@ public abstract class ParentNode extends
                     found = true;
                     break;
                 }
+                tempNode = (NodeImpl)tempNode.getNextSibling();
             }
 
             if (!found) {
@@ -365,10 +299,9 @@ public abstract class ParentNode extends
 
         checkSameOwnerDocument(newDomChild);
 
-        Iterator children = this.getChildren();
+        NodeImpl tempNode = (NodeImpl)getFirstChild();
         boolean found = false;
-        while (!found && children.hasNext()) {
-            NodeImpl tempNode = (NodeImpl) children.next();
+        while (!found && tempNode != null) {
             if (tempNode == oldChild) {
                 NodeImpl head; // The first child to insert
                 NodeImpl tail; // The last child to insert
@@ -420,6 +353,7 @@ public abstract class ParentNode extends
                 oldDomChild.internalSetPreviousSibling(null);
                 oldDomChild.setParent(null, true);
             }
+            tempNode = (NodeImpl)tempNode.getNextSibling();
         }
 
         if (!found)
@@ -510,7 +444,7 @@ public abstract class ParentNode extends
         }
         // create a Text node to hold the given content
         if (textContent != null && textContent.length() != 0) {
-            addChild(factory.createOMText(textContent));
+            insertBefore((NodeImpl)factory.createOMText(textContent), null, false);
         }
     }
 
@@ -518,19 +452,6 @@ public abstract class ParentNode extends
         return new SAXSource(new XMLReaderImpl((IContainer)this, cache), new InputSource());
     }
 
-    void notifyChildComplete() {
-        if (!this.isComplete() && getBuilder() == null) {
-            Iterator iterator = getChildren();
-            while (iterator.hasNext()) {
-                OMNode node = (OMNode) iterator.next();
-                if (!node.isComplete()) {
-                    return;
-                }
-            }
-            this.setComplete(true);
-        }
-    }
-
     void normalize(DOMConfigurationImpl config) {
         OMNode child = getFirstOMChild();
         while (child != null) {
@@ -538,41 +459,4 @@ public abstract class ParentNode extends
             child = child.getNextOMSibling();
         }
     }
-    
-    private NodeList getElementsWildcard() {
-        return new NodeListImpl() {
-            protected Iterator getIterator() {
-                return new OMFilterIterator(getDescendants(false)) {
-                    protected boolean matches(OMNode node) {
-                        return node.getType() == OMNode.ELEMENT_NODE;
-                    }
-                };
-            }
-        };
-    }
-    
-    public final NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
-        if ("*".equals(namespaceURI) && "*".equals(localName)) {
-            return getElementsWildcard();
-        } else {
-            final QName qname = new QName(namespaceURI, localName);
-            return new NodeListImpl() {
-                protected Iterator getIterator() {
-                    return new OMQNameFilterIterator(getDescendants(false), qname);
-                }
-            };
-        }
-    }
-
-    public final NodeList getElementsByTagName(final String name) {
-        if (name.equals("*")) {
-            return getElementsWildcard();
-        } else {
-            return new NodeListImpl() {
-                protected Iterator getIterator() {
-                    return new OMQualifiedNameFilterIterator(getDescendants(false), name);
-                }
-            };
-        }
-    }
 }

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
Sun Jul  6 14:49:24 2014
@@ -29,18 +29,13 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.IDocument;
-import org.apache.axiom.om.impl.common.OMChildrenLocalNameIterator;
-import org.apache.axiom.om.impl.common.OMChildrenNamespaceIterator;
 import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
-import org.apache.axiom.om.impl.common.OMDescendantsIterator;
 import org.apache.axiom.om.impl.common.OMDocumentHelper;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
 import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
-import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
 import org.xml.sax.InputSource;
 
-import javax.xml.namespace.QName;
 import javax.xml.transform.sax.SAXSource;
 
 import java.util.Iterator;
@@ -142,10 +137,6 @@ public class OMDocumentImpl extends OMSe
         state = DISCARDED;
     }
 
-    public void addChild(OMNode child) {
-        addChild(child, false);
-    }
-
     public final void checkChild(OMNode child) {
         if (child instanceof OMElement) {
             if (getOMDocumentElement() != null) {
@@ -159,44 +150,6 @@ public class OMDocumentImpl extends OMSe
     protected void checkDocumentElement(OMElement element) {
     }
 
-    /**
-     * Returns a collection of this element. Children can be of types OMElement, OMText.
-     *
-     * @return Returns iterator.
-     */
-    public Iterator getChildren() {
-        return new OMChildrenIterator(getFirstOMChild());
-    }
-
-    public Iterator getDescendants(boolean includeSelf) {
-        return new OMDescendantsIterator(this, includeSelf);
-    }
-
-    /**
-     * Searches for children with a given QName and returns an iterator to traverse through
the
-     * OMNodes. The QName can contain any combination of prefix, localname and URI.
-     *
-     * @param elementQName
-     * @return Returns Iterator.
-     * @throws org.apache.axiom.om.OMException
-     *
-     */
-    public Iterator getChildrenWithName(QName elementQName) {
-        return new OMChildrenQNameIterator(getFirstOMChild(),
-                                           elementQName);
-    }
-
-    public Iterator getChildrenWithLocalName(String localName) {
-        return new OMChildrenLocalNameIterator(getFirstOMChild(),
-                                               localName);
-    }
-
-
-    public Iterator getChildrenWithNamespaceURI(String uri) {
-        return new OMChildrenNamespaceIterator(getFirstOMChild(),
-                                               uri);
-    }
-
     public OMNode getFirstOMChildIfAvailable() {
         return firstChild;
     }
@@ -206,27 +159,6 @@ public class OMDocumentImpl extends OMSe
     }
 
     /**
-     * Method getFirstChildWithName.
-     *
-     * @param elementQName
-     * @return Returns OMElement.
-     * @throws OMException
-     */
-    public OMElement getFirstChildWithName(QName elementQName) throws OMException {
-        OMChildrenQNameIterator omChildrenQNameIterator =
-                new OMChildrenQNameIterator(getFirstOMChild(),
-                                            elementQName);
-        OMNode omNode = null;
-        if (omChildrenQNameIterator.hasNext()) {
-            omNode = (OMNode) omChildrenQNameIterator.next();
-        }
-
-        return ((omNode != null) && (OMNode.ELEMENT_NODE == omNode.getType())) ?
-                (OMElement) omNode : null;
-
-    }
-
-    /**
      * Method setFirstChild.
      *
      * @param firstChild

Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1608212&r1=1608211&r2=1608212&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
(original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
Sun Jul  6 14:49:24 2014
@@ -35,18 +35,12 @@ import org.apache.axiom.om.impl.common.I
 import org.apache.axiom.om.impl.common.IElement;
 import org.apache.axiom.om.impl.common.NamespaceIterator;
 import org.apache.axiom.om.impl.common.OMChildElementIterator;
-import org.apache.axiom.om.impl.common.OMChildrenLegacyQNameIterator;
-import org.apache.axiom.om.impl.common.OMChildrenLocalNameIterator;
-import org.apache.axiom.om.impl.common.OMChildrenNamespaceIterator;
-import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
-import org.apache.axiom.om.impl.common.OMDescendantsIterator;
 import org.apache.axiom.om.impl.common.OMElementHelper;
 import org.apache.axiom.om.impl.common.OMNamedInformationItemHelper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
 import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
-import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
 import org.apache.axiom.om.impl.util.EmptyIterator;
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.om.util.StAXUtils;
@@ -196,90 +190,10 @@ public class OMElementImpl extends OMNod
         }
     }
 
-    public void addChild(OMNode omNode) {
-        addChild(omNode, false);
-    }
-
     public void checkChild(OMNode child) {
     }
 
     /**
-     * Searches for children with a given QName and returns an iterator to traverse through
the
-     * OMNodes. This QName can contain any combination of prefix, localname and URI.
-     *
-     * @throws OMException
-     */
-    public Iterator getChildrenWithName(QName elementQName) {
-        OMNode firstChild = getFirstOMChild();
-        Iterator it =  new OMChildrenQNameIterator(firstChild, elementQName);
-        
-        // The getChidrenWithName method used to tolerate an empty namespace
-        // and interpret that as getting any element that matched the local
-        // name.  There are custmers of axiom that have hard-coded dependencies
-        // on this semantic.
-        // The following code falls back to this legacy behavior only if
-        // (a) elementQName has no namespace, (b) the new iterator finds no elements
-        // and (c) there are children.
-        if (elementQName.getNamespaceURI().length() == 0 &&
-            firstChild != null &&
-            !it.hasNext()) {
-            if (log.isTraceEnabled()) {
-                log.trace("There are no child elements that match the unqualifed name: "
+
-                          elementQName);
-                log.trace("Now looking for child elements that have the same local name.");
-            }
-            it = new OMChildrenLegacyQNameIterator(getFirstOMChild(), elementQName);
-        }
-        
-        return it;
-    }
-    
-
-    public Iterator getChildrenWithLocalName(String localName) {
-        return new OMChildrenLocalNameIterator(getFirstOMChild(),
-                                               localName);
-    }
-
-
-    public Iterator getChildrenWithNamespaceURI(String uri) {
-        return new OMChildrenNamespaceIterator(getFirstOMChild(),
-                                               uri);
-    }
-
-
-    /**
-     * Method getFirstChildWithName.
-     *
-     * @throws OMException
-     */
-    public OMElement getFirstChildWithName(QName elementQName) throws OMException {
-        OMChildrenQNameIterator omChildrenQNameIterator =
-                new OMChildrenQNameIterator(getFirstOMChild(),
-                                            elementQName);
-        OMNode omNode = null;
-        if (omChildrenQNameIterator.hasNext()) {
-            omNode = (OMNode) omChildrenQNameIterator.next();
-        }
-
-        return ((omNode != null) && (OMNode.ELEMENT_NODE == omNode.getType())) ?
-                (OMElement) omNode : null;
-
-    }
-
-    /**
-     * Returns a collection of this element. Children can be of types OMElement, OMText.
-     *
-     * @return Returns children.
-     */
-    public Iterator getChildren() {
-        return new OMChildrenIterator(getFirstOMChild());
-    }
-
-    public Iterator getDescendants(boolean includeSelf) {
-        return new OMDescendantsIterator(this, includeSelf);
-    }
-
-    /**
      * Returns a filtered list of children - just the elements.
      *
      * @return Returns an iterator of the child elements.



Mime
View raw message