jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1146066 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem: MemoryKernelImpl.java NodeImpl.java
Date Wed, 13 Jul 2011 14:46:34 GMT
Author: thomasm
Date: Wed Jul 13 14:46:34 2011
New Revision: 1146066

URL: http://svn.apache.org/viewvc?rev=1146066&view=rev
Log:
Use PathUtils

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java?rev=1146066&r1=1146065&r2=1146066&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/MemoryKernelImpl.java
Wed Jul 13 14:46:34 2011
@@ -95,10 +95,7 @@ public class MemoryKernelImpl implements
     private String apply(String rootPath, String jsonDiff) {
         JsopBuilder w = new JsopBuilder();
         JsopTokenizer t = new JsopTokenizer(jsonDiff);
-        if (!PathUtils.denotesRoot(rootPath)) {
-            rootPath += "/";
-        }
-        String fromRoot = rootPath.substring(1);
+        String fromRoot = PathUtils.relativize("/", rootPath);
         while (true) {
             int r = t.read();
             if (r == JsopTokenizer.END) {
@@ -108,17 +105,17 @@ public class MemoryKernelImpl implements
             switch (r) {
             case '+':
                 path = t.readString();
-                w.append("+ ").key(rootPath + path);
+                w.append("+ ").key(PathUtils.concat(rootPath, path));
                 t.read(':');
                 t.read('{');
                 NodeImpl n = NodeImpl.parse(t, headRevId);
-                headRoot = headRoot.cloneAndAddChildNode(fromRoot + path, n, headRevId);
+                headRoot = headRoot.cloneAndAddChildNode(PathUtils.concat(fromRoot, path),
n, headRevId);
                 w.append(n.toString()).append("\n");
                 break;
             case '-':
                 path = t.readString();
-                w.append("- ").key(rootPath + path);
-                headRoot = headRoot.cloneAndRemoveChildNode(fromRoot + path, headRevId);
+                w.append("- ").key(PathUtils.concat(rootPath, path));
+                headRoot = headRoot.cloneAndRemoveChildNode(PathUtils.concat(fromRoot, path),
headRevId);
                 break;
             case '^':
                 path = t.readString();
@@ -126,20 +123,20 @@ public class MemoryKernelImpl implements
                 String value;
                 if (t.matches(JsopTokenizer.NULL)) {
                     value = null;
-                    w.append("^ ").key(rootPath + path);
+                    w.append("^ ").key(PathUtils.concat(rootPath, path));
                     w.value(null);
                 } else {
                     value = t.readRawValue().trim();
-                    String nodeName = fromRoot + PathUtils.getParentPath(path);
+                    String nodeName = PathUtils.concat(fromRoot, PathUtils.getParentPath(path));
                     String propertyName = PathUtils.getName(path);
                     if (headRoot.getNode(nodeName).hasProperty(propertyName)) {
-                        w.append("^ ").key(rootPath + path);
+                        w.append("^ ").key(PathUtils.concat(rootPath, path));
                     } else {
-                        w.append("+ ").key(rootPath + path);
+                        w.append("+ ").key(PathUtils.concat(rootPath, path));
                     }
                     w.append(value);
                 }
-                headRoot = headRoot.cloneAndSetProperty(fromRoot + path, value, headRevId);
+                headRoot = headRoot.cloneAndSetProperty(PathUtils.concat(fromRoot, path),
value, headRevId);
                 w.append("\n");
                 break;
             default:

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java?rev=1146066&r1=1146065&r2=1146066&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/mem/NodeImpl.java
Wed Jul 13 14:46:34 2011
@@ -29,7 +29,7 @@ public class NodeImpl {
     private HashMap<String, String> properties;
     private LinkedHashMap<String, NodeImpl> childNodes;
 
-    NodeImpl(long revId) {
+    public NodeImpl(long revId) {
         this.revId = revId;
     }
 
@@ -144,6 +144,10 @@ public class NodeImpl {
         return properties != null && properties.containsKey(propertyName);
     }
 
+    public String getProperty(String propertyName) {
+        return properties == null ? null : properties.get(propertyName);
+    }
+
     public String toString() {
         JsopBuilder json = new JsopBuilder();
         append(json, 0, 0, -1);
@@ -227,7 +231,7 @@ public class NodeImpl {
         }
     }
 
-    static NodeImpl parse(JsopTokenizer t, long revId) {
+    public static NodeImpl parse(JsopTokenizer t, long revId) {
         NodeImpl node = new NodeImpl(revId);
         if (!t.matches('}')) {
             do {



Mime
View raw message