jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r997227 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/ j...
Date Wed, 15 Sep 2010 08:34:40 GMT
Author: jukka
Date: Wed Sep 15 08:34:39 2010
New Revision: 997227

URL: http://svn.apache.org/viewvc?rev=997227&view=rev
Log:
JCR-2744: Avoid element arrays in PathImpl

Use relative paths instead of path elements in event states

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/AbstractPath.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/CurrentPath.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NamePath.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/ParentPath.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/RelativePath.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
Wed Sep 15 08:34:39 2010
@@ -273,7 +273,7 @@ public class ChangeLogRecord extends Clu
         NodeId parentId = record.readNodeId();
         Path parentPath = record.readPath();
         NodeId childId = record.readNodeId();
-        Path.Element childRelPath = record.readPathElement();
+        Path childRelPath = record.readPathElement();
         Name ntName = record.readQName();
 
         Set<Name> mixins = new HashSet<Name>();
@@ -324,7 +324,7 @@ public class ChangeLogRecord extends Clu
      * @return event state
      */
     private EventState createEventState(int type, NodeId parentId, Path parentPath,
-                                        NodeId childId, Path.Element childRelPath,
+                                        NodeId childId, Path childRelPath,
                                         Name ntName, Set<Name> mixins, String userId)
{
         switch (type) {
             case Event.NODE_ADDED:

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AbstractRecord.java
Wed Sep 15 08:34:39 2010
@@ -96,9 +96,9 @@ public abstract class AbstractRecord imp
     /**
      * {@inheritDoc}
      */
-    public void writePathElement(Path.Element element) throws JournalException {
-        writeQName(element.getName());
-        writeInt(element.getIndex());
+    public void writePathElement(Path path) throws JournalException {
+        writeQName(path.getName());
+        writeInt(path.getIndex());
     }
 
     /**
@@ -175,14 +175,14 @@ public abstract class AbstractRecord imp
     /**
      * {@inheritDoc}
      */
-    public Path.Element readPathElement() throws JournalException {
+    public Path readPathElement() throws JournalException {
         try {
             Name name = resolver.getQName(readString());
             int index = readInt();
             if (index != 0) {
-                return PathFactoryImpl.getInstance().createElement(name, index);
+                return PathFactoryImpl.getInstance().create(name, index);
             } else {
-                return PathFactoryImpl.getInstance().createElement(name);
+                return PathFactoryImpl.getInstance().create(name);
             }
         } catch (NameException e) {
             String msg = "Unknown prefix error while reading path element.";

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
Wed Sep 15 08:34:39 2010
@@ -113,12 +113,12 @@ public interface Record {
     Name readQName() throws JournalException;
 
     /**
-     * Read a <code>Path.Element</code> from the underlying stream.
+     * Read a named path element from the underlying stream.
      *
      * @return path element
      * @throws JournalException if an error occurs
      */
-    Path.Element readPathElement() throws JournalException;
+    Path readPathElement() throws JournalException;
 
     /**
      * Read a <code>Path</code> from the underlying stream.
@@ -222,7 +222,7 @@ public interface Record {
      * @param element path element
      * @throws JournalException if an error occurs
      */
-    void writePathElement(Path.Element element) throws JournalException;
+    void writePathElement(Path element) throws JournalException;
 
     /**
      * Write a <code>Path</code> to the underlying stream.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateManager.java
Wed Sep 15 08:34:39 2010
@@ -219,7 +219,7 @@ public class VirtualNodeTypeStateManager
                 parent.getNodeId(),
                 parent.getPrimaryPath(),
                 node.getNodeId(),
-                node.getPrimaryPath().getNameElement(),
+                node.getPrimaryPath().getLastElement(),
                 ((NodeTypeImpl) parent.getPrimaryNodeType()).getQName(),
                 parent.getMixinTypeNames(),
                 node.getSession()
@@ -231,7 +231,7 @@ public class VirtualNodeTypeStateManager
             events.add(EventState.propertyAdded(
                     (NodeId) node.getId(),
                     node.getPrimaryPath(),
-                    prop.getPrimaryPath().getNameElement(),
+                    prop.getPrimaryPath().getLastElement(),
                     ((NodeTypeImpl) node.getPrimaryNodeType()).getQName(),
                     node.getMixinTypeNames(),
                     node.getSession()
@@ -260,7 +260,7 @@ public class VirtualNodeTypeStateManager
                 parent.getNodeId(),
                 parent.getPrimaryPath(),
                 node.getNodeId(),
-                node.getPrimaryPath().getNameElement(),
+                node.getPrimaryPath().getLastElement(),
                 ((NodeTypeImpl) parent.getPrimaryNodeType()).getQName(),
                 parent.getMixinTypeNames(),
                 node.getSession()

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
Wed Sep 15 08:34:39 2010
@@ -164,7 +164,7 @@ public final class EventImpl implements 
     public Path getQPath() throws RepositoryException {
         try {
             Path parent = eventState.getParentPath();
-            Path.Element child = eventState.getChildRelPath();
+            Path child = eventState.getChildRelPath();
             int index = child.getIndex();
             if (index > 0) {
                 return PathFactoryImpl.getInstance().create(parent, child.getName(), index,
false);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventState.java
Wed Sep 15 08:34:39 2010
@@ -24,8 +24,6 @@ import org.apache.jackrabbit.core.value.
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.commons.name.PathBuilder;
-import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import javax.jcr.observation.Event;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -99,7 +97,7 @@ public class EventState {
      * The relative path of the child item associated with this event.
      * This is basically the name of the item with an optional index.
      */
-    private final Path.Element childRelPath;
+    private final Path childRelPath;
 
     /**
      * The node type name of the parent node.
@@ -170,7 +168,7 @@ public class EventState {
      * @param session    the {@link javax.jcr.Session} that caused this event.
      */
     private EventState(int type, NodeId parentId, Path parentPath,
-                       NodeId childId, Path.Element childPath, Name nodeType,
+                       NodeId childId, Path childPath, Name nodeType,
                        Set<Name> mixins, Session session, boolean external) {
 
         int mask = (Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED);
@@ -214,7 +212,7 @@ public class EventState {
     public static EventState childNodeAdded(NodeId parentId,
                                             Path parentPath,
                                             NodeId childId,
-                                            Path.Element childPath,
+                                            Path childPath,
                                             Name nodeType,
                                             Set<Name> mixins,
                                             Session session) {
@@ -242,7 +240,7 @@ public class EventState {
     public static EventState childNodeAdded(NodeId parentId,
                                             Path parentPath,
                                             NodeId childId,
-                                            Path.Element childPath,
+                                            Path childPath,
                                             Name nodeType,
                                             Set<Name> mixins,
                                             Session session,
@@ -270,7 +268,7 @@ public class EventState {
     public static EventState childNodeRemoved(NodeId parentId,
                                               Path parentPath,
                                               NodeId childId,
-                                              Path.Element childPath,
+                                              Path childPath,
                                               Name nodeType,
                                               Set<Name> mixins,
                                               Session session) {
@@ -298,7 +296,7 @@ public class EventState {
     public static EventState childNodeRemoved(NodeId parentId,
                                               Path parentPath,
                                               NodeId childId,
-                                              Path.Element childPath,
+                                              Path childPath,
                                               Name nodeType,
                                               Set<Name> mixins,
                                               Session session,
@@ -330,12 +328,11 @@ public class EventState {
     public static EventState nodeMoved(NodeId parentId,
                                        Path parentPath,
                                        NodeId childId,
-                                       Path.Element childPath,
+                                       Path childPath,
                                        Name nodeType,
                                        Set<Name> mixins,
                                        Session session,
                                        boolean external) {
-
         return new EventState(Event.NODE_MOVED, parentId, parentPath,
                 childId, childPath, nodeType, mixins, session, external);
     }
@@ -358,18 +355,13 @@ public class EventState {
      * @throws ItemStateException if <code>destPath</code> does not have a
      *                            parent.
      */
-    public static EventState nodeMoved(NodeId parentId,
-                                       Path destPath,
-                                       NodeId childId,
-                                       Path srcPath,
-                                       Name nodeType,
-                                       Set<Name> mixins,
-                                       Session session,
-                                       boolean external)
+    public static EventState nodeMovedWithInfo(
+            NodeId parentId, Path destPath, NodeId childId, Path srcPath,
+            Name nodeType, Set<Name> mixins, Session session, boolean external)
             throws ItemStateException {
         try {
             EventState es = nodeMoved(parentId, destPath.getAncestor(1),
-                    childId, destPath.getNameElement(), nodeType, mixins,
+                    childId, destPath, nodeType, mixins,
                     session, external);
             Map<String, InternalValue> info = new HashMap<String, InternalValue>();
             info.put(SRC_ABS_PATH, InternalValue.create(srcPath));
@@ -410,15 +402,16 @@ public class EventState {
     public static EventState nodeReordered(NodeId parentId,
                                            Path parentPath,
                                            NodeId childId,
-                                           Path.Element destChildPath,
-                                           Path.Element srcChildPath,
-                                           Path.Element beforeChildPath,
+                                           Path destChildPath,
+                                           Path srcChildPath,
+                                           Path beforeChildPath,
                                            Name nodeType,
                                            Set<Name> mixins,
                                            Session session,
                                            boolean external) {
-        EventState es = nodeMoved(parentId, parentPath, childId, destChildPath,
-               nodeType, mixins, session, external);
+        EventState es = nodeMoved(
+                parentId, parentPath, childId, destChildPath,
+                nodeType, mixins, session, external);
         Map<String, InternalValue> info = new HashMap<String, InternalValue>();
         info.put(SRC_CHILD_REL_PATH, createValue(srcChildPath));
         InternalValue value = null;
@@ -446,7 +439,7 @@ public class EventState {
      */
     public static EventState propertyAdded(NodeId parentId,
                                            Path parentPath,
-                                           Path.Element childPath,
+                                           Path childPath,
                                            Name nodeType,
                                            Set<Name> mixins,
                                            Session session) {
@@ -472,7 +465,7 @@ public class EventState {
      */
     public static EventState propertyAdded(NodeId parentId,
                                            Path parentPath,
-                                           Path.Element childPath,
+                                           Path childPath,
                                            Name nodeType,
                                            Set<Name> mixins,
                                            Session session,
@@ -498,7 +491,7 @@ public class EventState {
      */
     public static EventState propertyRemoved(NodeId parentId,
                                              Path parentPath,
-                                             Path.Element childPath,
+                                             Path childPath,
                                              Name nodeType,
                                              Set<Name> mixins,
                                              Session session) {
@@ -524,7 +517,7 @@ public class EventState {
      */
     public static EventState propertyRemoved(NodeId parentId,
                                              Path parentPath,
-                                             Path.Element childPath,
+                                             Path childPath,
                                              Name nodeType,
                                              Set<Name> mixins,
                                              Session session,
@@ -550,7 +543,7 @@ public class EventState {
      */
     public static EventState propertyChanged(NodeId parentId,
                                              Path parentPath,
-                                             Path.Element childPath,
+                                             Path childPath,
                                              Name nodeType,
                                              Set<Name> mixins,
                                              Session session) {
@@ -576,7 +569,7 @@ public class EventState {
      */
     public static EventState propertyChanged(NodeId parentId,
                                              Path parentPath,
-                                             Path.Element childPath,
+                                             Path childPath,
                                              Name nodeType,
                                              Set<Name> mixins,
                                              Session session,
@@ -626,9 +619,9 @@ public class EventState {
      * Returns the relative {@link Path} of the child
      * {@link javax.jcr.Item} associated with this event.
      *
-     * @return the <code>Path.Element</code> associated with this event.
+     * @return the <code>Path</code> associated with this event.
      */
-    public Path.Element getChildRelPath() {
+    public Path getChildRelPath() {
         return childRelPath;
     }
 
@@ -846,19 +839,12 @@ public class EventState {
     }
 
     /**
-     * Creates an internal path value from the given path <code>element</code>.
+     * Creates an internal path value from the given path.
      *
-     * @param element the path element.
-     * @return an internal value wrapping the path element.
+     * @param path the path
+     * @return an internal value wrapping the path
      */
-    private static InternalValue createValue(Path.Element element) {
-        PathBuilder builder = new PathBuilder();
-        builder.addFirst(element);
-        try {
-            return InternalValue.create(builder.getPath());
-        } catch (MalformedPathException e) {
-            // this exception is only thrown when number of element is zero
-            throw new InternalError();
-        }
+    private static InternalValue createValue(Path path) {
+        return InternalValue.create(path);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Wed Sep 15 08:34:39 2010
@@ -209,7 +209,7 @@ public final class EventStateCollection 
                             NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session);
                             events.add(EventState.childNodeRemoved(oldParentId,
                                     getParent(oldPath), n.getNodeId(),
-                                    oldPath.getNameElement(),
+                                    oldPath.getLastElement(),
                                     oldParentNodeType.getQName(),
                                     oldParent.getMixinTypeNames(), session));
                         } else {
@@ -230,12 +230,12 @@ public final class EventStateCollection 
                         Path newPath = getPath(n.getNodeId(), hmgr);
                         events.add(EventState.childNodeAdded(newParentId,
                                 getParent(newPath), n.getNodeId(),
-                                newPath.getNameElement(),
+                                newPath.getLastElement(),
                                 newParentNodeType.getQName(),
                                 mixins, session));
 
-                        events.add(EventState.nodeMoved(newParentId,
-                                newPath, n.getNodeId(), oldPath,
+                        events.add(EventState.nodeMovedWithInfo(
+                                newParentId, newPath, n.getNodeId(), oldPath,
                                 newParentNodeType.getQName(), mixins,
                                 session, false));
                     } else {
@@ -283,15 +283,15 @@ public final class EventStateCollection 
                                 }
                                 events.add(EventState.childNodeRemoved(
                                         parent.getNodeId(), parentPath,
-                                        n.getNodeId(), oldPath.getNameElement(),
+                                        n.getNodeId(), oldPath.getLastElement(),
                                         nodeType.getQName(), mixins, session));
 
                                 events.add(EventState.childNodeAdded(
                                         parent.getNodeId(), parentPath,
-                                        n.getNodeId(), newPath.getNameElement(),
+                                        n.getNodeId(), newPath.getLastElement(),
                                         nodeType.getQName(), mixins, session));
 
-                                events.add(EventState.nodeMoved(
+                                events.add(EventState.nodeMovedWithInfo(
                                         parent.getNodeId(), newPath, n.getNodeId(),
                                         oldPath, nodeType.getQName(), mixins,
                                         session, false));
@@ -308,7 +308,7 @@ public final class EventStateCollection 
                     // create a node removed and a node added event for every
                     // reorder
                     for (ChildNodeEntry child : reordered) {
-                        Path.Element addedElem = getPathElement(child);
+                        Path addedElem = getPathElement(child);
                         Path parentPath = getPath(n.getNodeId(), hmgr);
                         // get removed index
                         NodeState overlayed = (NodeState) n.getOverlayedState();
@@ -316,7 +316,7 @@ public final class EventStateCollection 
                         if (entry == null) {
                             throw new ItemStateException("Unable to retrieve old child index
for item: " + child.getId());
                         }
-                        Path.Element removedElem = getPathElement(entry);
+                        Path removedElem = getPathElement(entry);
 
                         events.add(EventState.childNodeRemoved(n.getNodeId(),
                                 parentPath, child.getId(), removedElem,
@@ -330,7 +330,7 @@ public final class EventStateCollection 
                         // index of the child node entry before which this
                         // child node entry was reordered
                         int idx = cne.indexOf(child) + 1;
-                        Path.Element beforeElem = null;
+                        Path beforeElem = null;
                         if (idx < cne.size()) {
                             beforeElem = getPathElement(cne.get(idx));
                         }
@@ -351,7 +351,7 @@ public final class EventStateCollection 
                 NodeTypeImpl nodeType = getNodeType(parent, session);
                 Set<Name> mixins = parent.getMixinTypeNames();
                 events.add(EventState.propertyChanged(state.getParentId(),
-                        getParent(path), path.getNameElement(),
+                        getParent(path), path.getLastElement(),
                         nodeType.getQName(), mixins, session));
             }
         }
@@ -368,7 +368,7 @@ public final class EventStateCollection 
                 events.add(EventState.childNodeRemoved(n.getParentId(),
                         getParent(path),
                         n.getNodeId(),
-                        path.getNameElement(),
+                        path.getLastElement(),
                         nodeType.getQName(),
                         mixins,
                         session));
@@ -386,7 +386,7 @@ public final class EventStateCollection 
                     Path path = getZombiePath(state.getId(), hmgr);
                     events.add(EventState.propertyRemoved(state.getParentId(),
                             getParent(path),
-                            path.getNameElement(),
+                            path.getLastElement(),
                             nodeType.getQName(),
                             mixins,
                             session));
@@ -415,7 +415,7 @@ public final class EventStateCollection 
                 events.add(EventState.childNodeAdded(parentId,
                         getParent(path),
                         n.getNodeId(),
-                        path.getNameElement(),
+                        path.getLastElement(),
                         nodeType.getQName(),
                         mixins,
                         session));
@@ -435,7 +435,7 @@ public final class EventStateCollection 
                 Path path = getPath(state.getId(), hmgr);
                 events.add(EventState.propertyAdded(state.getParentId(),
                         getParent(path),
-                        path.getNameElement(),
+                        path.getLastElement(),
                         nodeType.getQName(),
                         mixins,
                         session));
@@ -695,15 +695,12 @@ public final class EventStateCollection 
      * @return the name element for the node.
      * @throws ItemStateException if an error occurs while resolving the name.
      */
-    private Path.Element getNameElement(NodeId nodeId,
-                                        NodeId parentId,
-                                        HierarchyManager hmgr)
+    private Path getNameElement(
+            NodeId nodeId, NodeId parentId, HierarchyManager hmgr)
             throws ItemStateException {
         try {
             Name name = hmgr.getName(nodeId, parentId);
-            PathBuilder builder = new PathBuilder();
-            builder.addFirst(name);
-            return builder.getPath().getNameElement();
+            return PathFactoryImpl.getInstance().create(name);
         } catch (RepositoryException e) {
             String msg = "Unable to get name for node with id: " + nodeId;
             throw new ItemStateException(msg, e);
@@ -722,15 +719,12 @@ public final class EventStateCollection 
      * @return the name element for the node.
      * @throws ItemStateException if an error occurs while resolving the name.
      */
-    private Path.Element getZombieNameElement(NodeId nodeId,
-                                              NodeId parentId,
-                                              ChangeLogBasedHierarchyMgr hmgr)
+    private Path getZombieNameElement(
+            NodeId nodeId, NodeId parentId, ChangeLogBasedHierarchyMgr hmgr)
             throws ItemStateException {
         try {
             Name name = hmgr.getZombieName(nodeId, parentId);
-            PathBuilder builder = new PathBuilder();
-            builder.addFirst(name);
-            return builder.getPath().getNameElement();
+            return PathFactoryImpl.getInstance().create(name);
         } catch (RepositoryException e) {
             // should never happen actually
             String msg = "Unable to resolve zombie name for item: " + nodeId;
@@ -788,10 +782,10 @@ public final class EventStateCollection 
      * @param entry a child node entry.
      * @return the path element for the given entry.
      */
-    private Path.Element getPathElement(ChildNodeEntry entry) {
+    private Path getPathElement(ChildNodeEntry entry) {
         Name name = entry.getName();
         int index = (entry.getIndex() != 1) ? entry.getIndex() : 0;
-        return PathFactoryImpl.getInstance().createElement(name, index);
+        return PathFactoryImpl.getInstance().create(name, index);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
Wed Sep 15 08:34:39 2010
@@ -187,7 +187,7 @@ public class UpdateEventFactory {
      */
     protected EventState createEventState(NodeState n, int type, String name,
                                           Session session) {
-        Path.Element relPath = pathFactory.createElement(nameFactory.create(name));
+        Path relPath = pathFactory.create(nameFactory.create(name));
 
         switch (type) {
         case Event.NODE_ADDED:
@@ -215,7 +215,7 @@ public class UpdateEventFactory {
      */
     protected EventState createEventState(PropertyState p, NodeState parent, int type,
                                           Session session) {
-        Path.Element relPath = pathFactory.createElement(p.getName());
+        Path relPath = pathFactory.create(p.getName());
 
         switch (type) {
         case Event.PROPERTY_ADDED:

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/AbstractPath.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/AbstractPath.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/AbstractPath.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/AbstractPath.java
Wed Sep 15 08:34:39 2010
@@ -98,6 +98,26 @@ abstract class AbstractPath implements P
         return false;
     }
 
+    /**
+     * Returns this path, except when overridden by the {@link RelativePath}
+     * subclasses.
+     *
+     * @return this path
+     */
+    public Path getLastElement() {
+        return this;
+    }
+
+    /**
+     * Returns <code>null</code>, except when overridden by the
+     * {@link RelativePath} subclass.
+     *
+     * @return <code>null</code>
+     */
+    public Path getFirstElements() {
+        return null;
+    }
+
     public final Path resolve(Element element) {
         if (element.denotesName()) {
             return new NamePath(this, element);

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/CurrentPath.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/CurrentPath.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/CurrentPath.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/CurrentPath.java
Wed Sep 15 08:34:39 2010
@@ -96,6 +96,16 @@ final class CurrentPath extends Relative
         return CurrentElement.INSTANCE;
     }
 
+    /**
+     * Returns the current path ".".
+     *
+     * @return current path
+     */
+    @Override
+    public Path getLastElement() {
+        return new CurrentPath(null);
+    }
+
     public String getString() {
         if (parent != null) {
             return parent.getString() + Path.DELIMITER + ".";

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NamePath.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NamePath.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NamePath.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/NamePath.java
Wed Sep 15 08:34:39 2010
@@ -108,6 +108,16 @@ final class NamePath extends RelativePat
         return element;
     }
 
+    /**
+     * Returns the last element of this path.
+     *
+     * @return last element of this path
+     */
+    @Override
+    public Path getLastElement() {
+        return new NamePath(null, element);
+    }
+
     public String getString() {
         if (parent != null) {
             return parent.getString() + Path.DELIMITER + element.getString();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/ParentPath.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/ParentPath.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/ParentPath.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/ParentPath.java
Wed Sep 15 08:34:39 2010
@@ -106,6 +106,16 @@ final class ParentPath extends RelativeP
         return ParentElement.INSTANCE;
     }
 
+    /**
+     * Returns the parent path "..".
+     *
+     * @return parent path
+     */
+    @Override
+    public Path getLastElement() {
+        return new ParentPath(null);
+    }
+
     public String getString() {
         if (parent != null) {
             return parent.getString() + Path.DELIMITER + "..";

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/RelativePath.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/RelativePath.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/RelativePath.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/name/RelativePath.java
Wed Sep 15 08:34:39 2010
@@ -124,6 +124,16 @@ abstract class RelativePath extends Abst
         return elements;
     }
 
+    /**
+     * Returns the first elements of this path.
+     *
+     * @return first elements of this path, or <code>null</code>
+     */
+    @Override
+    public Path getFirstElements() {
+        return parent;
+    }
+
     //--------------------------------------------------------------< Object >
 
     public final boolean equals(Object that) {

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java?rev=997227&r1=997226&r2=997227&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java (original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/Path.java Wed
Sep 15 08:34:39 2010
@@ -445,6 +445,23 @@ public interface Path extends Serializab
     public Element getNameElement();
 
     /**
+     * Returns a path that consists of only the last element of this path.
+     *
+     * @see #getFirstElements()
+     * @return last element of this path
+     */
+    Path getLastElement();
+
+    /**
+     * Returns a path that consists of all but the last element of this path.
+     * Returns <code>null</code> if this path contains just a single element.
+     *
+     * @see #getLastElement()
+     * @return first elements of this path, or <code>null</code>
+     */
+    Path getFirstElements();
+
+    /**
      * Returns the String representation of this Path as it is used
      * by {@link PathFactory#create(String)}.<p/>
      * The String representation must consist of the String representation of



Mime
View raw message