jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r482702 - /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java
Date Tue, 05 Dec 2006 16:29:33 GMT
Author: angela
Date: Tue Dec  5 08:29:32 2006
New Revision: 482702

URL: http://svn.apache.org/viewvc?view=rev&rev=482702
Log:
work in progress

- simplify (not yet tested). index is available from position in the linkNode-list

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java?view=diff&rev=482702&r1=482701&r2=482702
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChildNodeEntries.java
Tue Dec  5 08:29:32 2006
@@ -622,20 +622,16 @@
         }
 
         if (listOrLinkNode instanceof List) {
-            // has same name sibling
-            for (Iterator it = ((List) listOrLinkNode).iterator(); it.hasNext();) {
-                LinkedEntries.LinkNode n = (LinkedEntries.LinkNode) it.next();
-                ChildNodeEntry cne = n.getChildNodeEntry();
-                if (cne.getIndex() == index) {
-                    return n;
-                }
-            }
-        } else {
-            // single child node with this name
-            ChildNodeEntry cne = ((LinkedEntries.LinkNode) listOrLinkNode).getChildNodeEntry();
-            if (cne.getIndex() == index) {
-                return (LinkedEntries.LinkNode) listOrLinkNode;
+            // has same name sibling -> check if list size matches
+            int listIndex = index - 1;
+            List lnList = (List) listOrLinkNode;
+            if (listIndex < lnList.size()) {
+                return (LinkedEntries.LinkNode) lnList.get(listIndex);
             }
+        } else if (index == Path.INDEX_DEFAULT) {
+            // single child node with this name -> matches is requested index
+            // equals to the default index.
+            return (LinkedEntries.LinkNode) listOrLinkNode;
         }
 
         // no matching entry



Mime
View raw message