ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1735343 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl: common/OMChildrenQNameIterator.java mixin/AxiomContainerSupport.aj
Date Wed, 16 Mar 2016 23:21:20 GMT
Author: veithen
Date: Wed Mar 16 23:21:20 2016
New Revision: 1735343

URL: http://svn.apache.org/viewvc?rev=1735343&view=rev
Log:
Rewrite getFirstChildWithName and remove class that is now unused.

Removed:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMChildrenQNameIterator.java
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj?rev=1735343&r1=1735342&r2=1735343&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
Wed Mar 16 23:21:20 2016
@@ -31,6 +31,7 @@ import javax.xml.transform.sax.SAXSource
 
 import org.apache.axiom.core.Axis;
 import org.apache.axiom.core.Builder;
+import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.core.CoreElement;
 import org.apache.axiom.core.CoreModelException;
 import org.apache.axiom.core.ElementMatcher;
@@ -53,7 +54,6 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
-import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
 import org.apache.axiom.om.impl.common.SAXResultContentHandler;
 import org.apache.axiom.om.impl.common.serializer.push.NamespaceContextPreservationFilterHandler;
 import org.apache.axiom.om.impl.common.serializer.push.XmlDeclarationRewriterHandler;
@@ -188,17 +188,22 @@ public aspect AxiomContainerSupport {
         return coreGetNodes(includeSelf ? Axis.DESCENDANTS_OR_SELF : Axis.DESCENDANTS, AxiomSerializable.class,
Mappers.<OMSerializable>identity(), AxiomSemantics.INSTANCE);
     }
 
-    public OMElement AxiomContainer.getFirstChildWithName(QName elementQName) throws OMException
{
-        OMChildrenQNameIterator omChildrenQNameIterator =
-                new OMChildrenQNameIterator(getFirstOMChild(),
-                                            elementQName);
-        OMNode omNode = null;
-        if (omChildrenQNameIterator.hasNext()) {
-            omNode = (OMNode) omChildrenQNameIterator.next();
+    public final OMElement AxiomContainer.getFirstChildWithName(QName name) throws OMException
{
+        try {
+            CoreChildNode child = coreGetFirstChild();
+            while (child != null) {
+                if (child instanceof AxiomElement) {
+                    AxiomElement element = (AxiomElement)child;
+                    if (name.getLocalPart().equals(element.coreGetLocalName()) &&
name.getNamespaceURI().equals(element.coreGetNamespaceURI())) {
+                        return element;
+                    }
+                }
+                child = child.coreGetNextSibling();
+            }
+            return null;
+        } catch (CoreModelException ex) {
+            throw AxiomExceptionTranslator.translate(ex);
         }
-
-        return ((omNode != null) && (OMNode.ELEMENT_NODE == omNode.getType())) ?
-                (OMElement) omNode : null;
     }
 
     public final SAXSource AxiomContainer.getSAXSource(boolean cache) {



Mime
View raw message