jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r424996 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java
Date Mon, 24 Jul 2006 10:30:29 GMT
Author: mreutegg
Date: Mon Jul 24 03:30:28 2006
New Revision: 424996

URL: http://svn.apache.org/viewvc?rev=424996&view=rev
Log:
Added method to get/create element from a given PathMap.Element using a relative path.

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java?rev=424996&r1=424995&r2=424996&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/PathMap.java Mon
Jul 24 03:30:28 2006
@@ -561,6 +561,33 @@
             }
             return result.iterator();
         }
+
+        /**
+         * Map a relPath starting at <code>this</code> Element. If
+         * <code>exact</code> is <code>false</code>, returns the
last available
+         * item along the relPath that is stored in the map.
+         *
+         * @param relPath relPath to map
+         * @param exact   flag indicating whether an exact match is required
+         * @return descendant, maybe <code>null</code> if <code>exact</code>
is
+         *         <code>true</code>
+         */
+        public Element getDescendant(Path relPath, boolean exact) {
+            Path.PathElement[] elements = relPath.getElements();
+            Element current = this;
+
+            for (int i = 0; i < elements.length; i++) {
+                Element next = current.getChild(elements[i]);
+                if (next == null) {
+                    if (exact) {
+                        return null;
+                    }
+                    break;
+                }
+                current = next;
+            }
+            return current;
+        }
     }
 
     /**



Mime
View raw message