jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1214159 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/json/ test/java/org/apache/jackrabbit/spi2microkernel/ test/java/org/apache/jackrabbit/spi2microkernel/json/
Date Wed, 14 Dec 2011 11:17:20 GMT
Author: mduerig
Date: Wed Dec 14 11:17:20 2011
New Revision: 1214159

URL: http://svn.apache.org/viewvc?rev=1214159&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
implement JSOP copy operator

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopHandler.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopParser.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/json/JsopParserTest.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopHandler.java?rev=1214159&r1=1214158&r2=1214159&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopHandler.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopHandler.java
Wed Dec 14 11:17:20 2011
@@ -30,8 +30,10 @@ public class JsopHandler {
     public void remove(Token path) { }
     public void set(Token path, Token value) { }
     public void set(Token path, Token[] values) { }
-    public void reorder(Token path, Token position, Token target) { }
     public void move(Token path, Token target) { }
+    public void reorder(Token path, Token position, Token target) { }
+    public void copy(Token path, Token target) { }
+    public void copy(Token path, Token position, Token target) { }
     public void test(Token path, Token value) { }
     public void test(Token path, Token[] values) { }
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopParser.java?rev=1214159&r1=1214158&r2=1214159&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopParser.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/json/JsopParser.java
Wed Dec 14 11:17:20 2011
@@ -26,11 +26,12 @@ import java.util.List;
 
 /*
  * DIFFS     ::= DIFF*
- * DIFF      ::= ADD | SET | REMOVE | MOVE | TEST | METADATA | EXTENSION
+ * DIFF      ::= ADD | SET | REMOVE | MOVE | COPY | TEST | METADATA | EXTENSION
  * ADD       ::= + STRING : (OBJECT | ATOM | ARRAY)
  * SET       ::= ^ STRING : ATOM | ARRAY
  * REMOVE    ::= - STRING
  * MOVE      ::= > STRING : (STRING | { STRING : STRING })
+ * COPY      ::= * STRING : (STRING | { STRING : STRING })
  * TEST      ::= = STRING : ATOM | ARRAY
  * METADATA  ::= @ OBJECT
  * EXTENSION ::= OP STRING ":" (OBJECT | ATOM | ARRAY)
@@ -70,6 +71,9 @@ public class JsopParser {
             case '>':
                 parseMove(tokenizer);
                 break;
+            case '*':
+                parseCopy(tokenizer);
+                break;
             case '=':
                 parseTest(tokenizer);
                 break;
@@ -135,6 +139,23 @@ public class JsopParser {
         }
     }
 
+    /* COPY      ::= * STRING : (STRING | { STRING : STRING }) */
+    public void parseCopy(JsonTokenizer tokenizer) {
+        Token path = tokenizer.read(Type.STRING);
+        tokenizer.read(Type.COLON);
+        if (tokenizer.peek(Type.BEGIN_OBJECT)) {
+            tokenizer.read(Type.BEGIN_OBJECT);
+            Token position = tokenizer.read(Type.STRING);
+            tokenizer.read(Type.COLON);
+            Token target = tokenizer.read(Type.STRING);
+            tokenizer.read(Type.END_OBJECT);
+            jsopHandler.copy(path, position, target);
+        }
+        else {
+            jsopHandler.copy(path, tokenizer.read(Type.STRING));
+        }
+    }
+
     /* TEST     ::= = STRING : ATOM | ARRAY */
     public void parseTest(JsonTokenizer tokenizer) {
         Token path = tokenizer.read(Type.STRING);

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java?rev=1214159&r1=1214158&r2=1214159&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Wed Dec 14 11:17:20 2011
@@ -557,6 +557,46 @@ public class MicrokernelTest {
         public void move(Token path, Token target) {
             fail();
         }
+
+        @Override
+        public void copy(Token path, Token target) {
+            fail();
+        }
+
+        @Override
+        public void copy(Token path, Token position, Token target) {
+            fail();
+        }
+
+        @Override
+        public void test(Token path, Token value) {
+            fail();
+        }
+
+        @Override
+        public void test(Token path, Token[] values) {
+            fail();
+        }
+
+        @Override
+        public void metaData(JsonTokenizer value) {
+            fail();
+        }
+
+        @Override
+        public void extension(char op, Token path, JsonTokenizer value) {
+            fail();
+        }
+
+        @Override
+        public void extension(char op, Token[] values) {
+            fail();
+        }
+
+        @Override
+        public void extension(char op, Token value) {
+            fail();
+        }
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/json/JsopParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/json/JsopParserTest.java?rev=1214159&r1=1214158&r2=1214159&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/json/JsopParserTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/json/JsopParserTest.java
Wed Dec 14 11:17:20 2011
@@ -17,6 +17,8 @@ public class JsopParserTest {
             "^ \"foo\" : \"bar\"" +
             "> \"foo\" : \"bar\"" +
             "> \"foo\" : {\"moo\" : \"bar\"}" +
+            "* \"foo\" : \"bar\"" +
+            "* \"foo\" : {\"moo\" : \"bar\"}" +
             "+ \"foo\" : [12, 34]" +
             "^ \"foo\" : [12, 34]" +
             "= \"foo\" : \"bar\"" +
@@ -73,6 +75,12 @@ public class JsopParserTest {
             }
 
             @Override
+            public void move(Token path, Token target) {
+                assertEquals("foo", path.text());
+                assertEquals("bar", target.text());
+            }
+
+            @Override
             public void reorder(Token path, Token position, Token target) {
                 assertEquals("foo", path.text());
                 assertEquals("moo", position.text());
@@ -80,12 +88,19 @@ public class JsopParserTest {
             }
 
             @Override
-            public void move(Token path, Token target) {
+            public void copy(Token path, Token target) {
                 assertEquals("foo", path.text());
                 assertEquals("bar", target.text());
             }
 
             @Override
+            public void copy(Token path, Token position, Token target) {
+                assertEquals("foo", path.text());
+                assertEquals("moo", position.text());
+                assertEquals("bar", target.text());
+            }
+
+            @Override
             public void test(Token path, Token value) {
                 assertEquals("foo", path.text());
                 assertEquals("bar", value.text());



Mime
View raw message