jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1330766 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemDelegate.java ItemImpl.java NodeDelegate.java NodeImpl.java PropertyDelegate.java PropertyImpl.java SessionImpl.java
Date Thu, 26 Apr 2012 10:40:20 GMT
Author: reschke
Date: Thu Apr 26 10:40:19 2012
New Revision: 1330766

URL: http://svn.apache.org/viewvc?rev=1330766&view=rev
Log:
Start moving code from *Delegate to ItemDelegate

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Modified:
    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/PropertyDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java

Added: 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=1330766&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java
Thu Apr 26 10:40:19 2012
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.oak.jcr;
+
+public abstract class ItemDelegate {
+    
+    abstract String getName();
+
+    abstract String 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=1330766&r1=1330765&r2=1330766&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 Apr 26 10:40:19 2012
@@ -34,17 +34,47 @@ import javax.jcr.ValueFactory;
 abstract class ItemImpl implements Item {
 
     protected final SessionContext<SessionImpl> sessionContext;
+    protected final ItemDelegate dlg;
 
     /**
      * logger instance
      */
     private static final Logger log = LoggerFactory.getLogger(ItemImpl.class);
 
-    protected ItemImpl(SessionContext<SessionImpl> sessionContext) {
+    protected ItemImpl(SessionContext<SessionImpl> sessionContext, ItemDelegate itemDelegate)
{
         this.sessionContext = sessionContext;
+        this.dlg = itemDelegate;
     }
 
     //---------------------------------------------------------------< Item >---
+
+    /**
+     * @see javax.jcr.Item#getDepth()
+     */
+    @Override
+    public int getDepth() throws RepositoryException {
+        return Paths.getDepth(dlg.getPath());
+    }
+
+    /**
+     * @see javax.jcr.Item#getName()
+     */
+    @Override
+    public String getName() throws RepositoryException {
+        String oakName = dlg.getName();
+        // special case name of root node
+        return oakName.isEmpty() ? "" : toJcrPath(dlg.getName());
+    }
+
+    /**
+     * @see javax.jcr.Property#getPath()
+     */
+    @Override
+    public String getPath() throws RepositoryException {
+        return toJcrPath(dlg.getPath());
+    }
+
+
     @Override
     public Session getSession() throws RepositoryException {
         return sessionContext.getSession();

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=1330766&r1=1330765&r2=1330766&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 Apr 26 10:40:19 2012
@@ -16,6 +16,13 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
@@ -25,13 +32,7 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.util.Function1;
 import org.apache.jackrabbit.oak.util.Iterators;
 
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import java.util.Iterator;
-import java.util.List;
-
-public class NodeDelegate {
+public class NodeDelegate extends ItemDelegate {
 
     private final SessionContext<SessionImpl> sessionContext;
     private Tree tree;
@@ -109,7 +110,7 @@ public class NodeDelegate {
     Iterator<PropertyDelegate> getProperties() throws RepositoryException {
         return propertyDelegateIterator(getTree().getProperties().iterator());
     }
-    
+
     long getPropertyCount() throws RepositoryException {
         return getTree().getPropertyCount();
     }
@@ -133,24 +134,27 @@ public class NodeDelegate {
     SessionContext<SessionImpl> getSessionContext() {
         return sessionContext;
     }
-    
+
     void remove() throws RepositoryException {
         getTree().getParent().removeChild(getName());
     }
 
-    PropertyDelegate setProperty(String oakName, CoreValue value) throws RepositoryException
{
+    PropertyDelegate setProperty(String oakName, CoreValue value)
+            throws RepositoryException {
 
         getState().setProperty(oakName, value);
         return getPropertyOrNull(oakName);
     }
 
-    PropertyDelegate setProperty(String oakName, List<CoreValue> value) throws RepositoryException
{
+    PropertyDelegate setProperty(String oakName, List<CoreValue> value)
+            throws RepositoryException {
 
         getState().setProperty(oakName, value);
         return getPropertyOrNull(oakName);
     }
 
-    // ------------------------------------------------------------< private >---
+    // ------------------------------------------------------------< private
+    // >---
 
     private Root getBranch() {
         return sessionContext.getBranch();

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=1330766&r1=1330765&r2=1330766&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 Apr 26 10:40:19 2012
@@ -16,24 +16,13 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.JcrConstants;
-import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
-import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
-import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.api.CoreValue;
-import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.api.Tree.Status;
-import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
-import org.apache.jackrabbit.oak.jcr.util.LogUtil;
-import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
-import org.apache.jackrabbit.oak.namepath.Paths;
-import org.apache.jackrabbit.oak.util.Function1;
-import org.apache.jackrabbit.oak.util.Iterators;
-import org.apache.jackrabbit.oak.util.Predicate;
-import org.apache.jackrabbit.value.ValueHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.jackrabbit.oak.util.Iterators.filter;
+
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.jcr.Binary;
 import javax.jcr.Item;
@@ -54,13 +43,21 @@ import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
 
-import static org.apache.jackrabbit.oak.util.Iterators.filter;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
+import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
+import org.apache.jackrabbit.oak.api.CoreValue;
+import org.apache.jackrabbit.oak.api.Tree.Status;
+import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
+import org.apache.jackrabbit.oak.jcr.util.LogUtil;
+import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
+import org.apache.jackrabbit.oak.util.Function1;
+import org.apache.jackrabbit.oak.util.Iterators;
+import org.apache.jackrabbit.oak.util.Predicate;
+import org.apache.jackrabbit.value.ValueHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@code NodeImpl}...
@@ -72,16 +69,10 @@ public class NodeImpl extends ItemImpl i
      */
     private static final Logger log = LoggerFactory.getLogger(NodeImpl.class);
 
-    // private Tree tree;
     private final NodeDelegate dlg;
     
-    NodeImpl(SessionContext<SessionImpl> sessionContext, Tree tree) {
-        super(sessionContext);
-        this.dlg = new NodeDelegate(sessionContext, tree);
-    }
-
     NodeImpl(NodeDelegate dlg) {
-        super(dlg.getSessionContext());
+        super(dlg.getSessionContext(), dlg);
         this.dlg = dlg;
     }
 
@@ -100,24 +91,6 @@ public class NodeImpl extends ItemImpl i
     }
 
     /**
-     * @see javax.jcr.Item#getName()
-     */
-    @Override
-    public String getName() throws RepositoryException {
-        String oakName = dlg.getName();
-        // special case name of root node
-        return oakName.isEmpty() ? "" : toJcrPath(dlg.getName());
-    }
-
-    /**
-     * @see javax.jcr.Property#getPath()
-     */
-    @Override
-    public String getPath() throws RepositoryException {
-        return toJcrPath(dlg.getPath());
-    }
-
-    /**
      * @see javax.jcr.Item#getParent()
      */
     @Override
@@ -134,14 +107,6 @@ public class NodeImpl extends ItemImpl i
     }
 
     /**
-     * @see javax.jcr.Item#getDepth()
-     */
-    @Override
-    public int getDepth() throws RepositoryException {
-        return dlg.getDepth();
-    }
-
-    /**
      * @see javax.jcr.Item#isNew()
      */
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java?rev=1330766&r1=1330765&r2=1330766&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java
Thu Apr 26 10:40:19 2012
@@ -27,7 +27,7 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.namepath.Paths;
 
-public class PropertyDelegate {
+public class PropertyDelegate extends ItemDelegate {
 
     private final SessionContext<SessionImpl> sessionContext;
     private Tree parent;

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=1330766&r1=1330765&r2=1330766&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 Apr 26 10:40:19 2012
@@ -34,11 +34,9 @@ import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.jcr.util.LogUtil;
 import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
-import org.apache.jackrabbit.oak.namepath.Paths;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,16 +53,9 @@ public class PropertyImpl extends ItemIm
 
     private final PropertyDelegate dlg;
     
-    PropertyImpl(SessionContext<SessionImpl> sessionContext, Tree parent,
-            PropertyState propertyState) {
-
-        super(sessionContext);
-        this.dlg = new PropertyDelegate(sessionContext, parent, propertyState);
-    }
-
     PropertyImpl(PropertyDelegate dlg) {
 
-        super(dlg.getSessionContext());
+        super(dlg.getSessionContext(), dlg);
         this.dlg = dlg;
     }
 
@@ -78,27 +69,12 @@ public class PropertyImpl extends ItemIm
     }
 
     /**
-     * @see javax.jcr.Item#getName()
-     */
-    @Override
-    public String getName() throws RepositoryException {
-        return toJcrPath(dlg.getName());
-    }
-
-    /**
-     * @see javax.jcr.Property#getPath()
-     */
-    @Override
-    public String getPath() throws RepositoryException {
-        return toJcrPath(dlg.getPath());
-    }
-
-    /**
      * @see javax.jcr.Item#getParent()
      */
     @Override
     public Node getParent() throws RepositoryException {
-        return new NodeImpl(sessionContext, dlg.getParentContentTree());
+        return new NodeImpl(new NodeDelegate(sessionContext,
+                dlg.getParentContentTree()));
     }
 
     /**
@@ -114,14 +90,6 @@ public class PropertyImpl extends ItemIm
     }
 
     /**
-     * @see javax.jcr.Item#getDepth()
-     */
-    @Override
-    public int getDepth() throws RepositoryException {
-        return Paths.getDepth(getPath());
-    }
-
-    /**
      * @see javax.jcr.Item#isNew()
      */
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1330766&r1=1330765&r2=1330766&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Thu Apr 26 10:40:19 2012
@@ -129,7 +129,7 @@ public class SessionImpl extends Abstrac
     @Override
     public Node getRootNode() throws RepositoryException {
         ensureIsAlive();
-        return new NodeImpl(sessionContext, root.getTree("/"));
+        return new NodeImpl(new NodeDelegate(sessionContext, root.getTree("/")));
     }
 
     @Override



Mime
View raw message