jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1333652 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemDelegate.java ItemImpl.java NodeDelegate.java NodeImpl.java PropertyImpl.java
Date Thu, 03 May 2012 22:03:45 GMT
Author: mduerig
Date: Thu May  3 22:03:45 2012
New Revision: 1333652

URL: http://svn.apache.org/viewvc?rev=1333652&view=rev
Log:
OAK-84: Delegates for Session, Node, Property and Item
Use AbstractItem from jcr-commons for the getDepth() and getAncestor() methods (Jukka's patch)


Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java?rev=1333652&r1=1333651&r2=1333652&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Thu May  3 22:03:45 2012
@@ -17,15 +17,9 @@
 
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.oak.commons.PathUtils;
-
 public abstract class ItemDelegate {
     
     abstract String getName();
 
     abstract String getPath();
-
-    public int getDepth() {
-        return PathUtils.getDepth(getPath());
-    }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1333652&r1=1333651&r2=1333652&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Thu May  3 22:03:45 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import org.apache.jackrabbit.commons.AbstractItem;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,7 +30,7 @@ import javax.jcr.ValueFactory;
 /**
  * {@code ItemImpl}...
  */
-abstract class ItemImpl implements Item {
+abstract class ItemImpl extends AbstractItem {
 
     protected final SessionDelegate sessionDelegate;
     protected final ItemDelegate dlg;
@@ -47,14 +48,6 @@ abstract class ItemImpl implements Item 
     //---------------------------------------------------------------< Item >---
 
     /**
-     * @see javax.jcr.Item#getDepth()
-     */
-    @Override
-    public int getDepth() throws RepositoryException {
-        return dlg.getDepth();
-    }
-
-    /**
      * @see javax.jcr.Item#getName()
      */
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1333652&r1=1333651&r2=1333652&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Thu May  3 22:03:45 2012
@@ -52,20 +52,6 @@ public class NodeDelegate extends ItemDe
         return new NodeDelegate(sessionDelegate, parentState.getChild(name));
     }
 
-    NodeDelegate getAncestor(int depth) throws RepositoryException {
-        int current = getDepth();
-        if (depth < 0 || depth > current) {
-            throw new ItemNotFoundException("ancestor at depth " + depth
-                    + " does not exist");
-        }
-        Tree ancestor = getTree();
-        while (depth < current) {
-            ancestor = ancestor.getParent();
-            current -= 1;
-        }
-        return new NodeDelegate(sessionDelegate, ancestor);
-    }
-
     Iterator<NodeDelegate> getChildren() throws RepositoryException {
         return nodeDelegateIterator(getTree().getChildren().iterator());
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1333652&r1=1333651&r2=1333652&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu May  3 22:03:45 2012
@@ -99,14 +99,6 @@ public class NodeImpl extends ItemImpl i
     }
 
     /**
-     * @see Item#getAncestor(int)
-     */
-    @Override
-    public Item getAncestor(int depth) throws RepositoryException {
-        return new NodeImpl(dlg.getAncestor(depth));
-    }
-
-    /**
      * @see javax.jcr.Item#isNew()
      */
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1333652&r1=1333651&r2=1333652&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
Thu May  3 22:03:45 2012
@@ -25,7 +25,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Binary;
-import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.Node;
@@ -78,21 +77,6 @@ public class PropertyImpl extends ItemIm
     }
 
     /**
-     * @see Item#getAncestor(int)
-     */
-    @Override
-    public Item getAncestor(int depth) throws RepositoryException {
-        int myDepth = getDepth();
-        if (depth == myDepth) {
-            return this;
-        } else if (depth == myDepth - 1) {
-            return getParent();
-        } else {
-            return getParent().getAncestor(depth);
-        }
-    }
-
-    /**
      * @see javax.jcr.Item#isNew()
      */
     @Override



Mime
View raw message