You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mb...@apache.org on 2007/01/10 23:44:19 UTC

svn commit: r495019 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java

Author: mbenson
Date: Wed Jan 10 14:44:18 2007
New Revision: 495019

URL: http://svn.apache.org/viewvc?view=rev&rev=495019
Log:
[JXPATH-20] removeAll() only removed the first matching element; slightly inelegant fix

Modified:
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java?view=diff&rev=495019&r1=495018&r2=495019
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Wed Jan 10 14:44:18 2007
@@ -52,6 +52,7 @@
 import org.apache.commons.jxpath.ri.model.beans.CollectionPointerFactory;
 import org.apache.commons.jxpath.ri.model.container.ContainerPointerFactory;
 import org.apache.commons.jxpath.ri.model.dynamic.DynamicPointerFactory;
+import org.apache.commons.jxpath.util.ReverseComparator;
 import org.apache.commons.jxpath.util.TypeUtils;
 
 /**
@@ -576,10 +577,14 @@
             while (it.hasNext()) {
                 list.add(it.next());
             }
-            Collections.sort(list);
-            for (int i = list.size() - 1; i >= 0; i--) {
-                NodePointer pointer = (NodePointer) list.get(i);
+            Collections.sort(list, ReverseComparator.INSTANCE);
+            it = list.iterator();
+            if (it.hasNext()) {
+                NodePointer pointer = (NodePointer) it.next();
                 pointer.remove();
+                while (it.hasNext()) {
+                    removePath(((NodePointer) it.next()).asPath());
+                }
             }
         }
         catch (Throwable ex) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org