jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1207062 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
Date Mon, 28 Nov 2011 10:47:17 GMT
Author: thomasm
Date: Mon Nov 28 10:47:16 2011
New Revision: 1207062

URL: http://svn.apache.org/viewvc?rev=1207062&view=rev
Log:
Jsop object and array classes, to speed up sparse parsing of large jsop objects. Not used
in the code, so currently only in the test folder.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java?rev=1207062&r1=1207061&r2=1207062&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
Mon Nov 28 10:47:16 2011
@@ -39,12 +39,17 @@ public class JsopTokenizer implements Js
     private String lastToken;
     private boolean lastEscaped;
 
-    public JsopTokenizer(String json) {
+    public JsopTokenizer(String json, int pos) {
         this.jsop = json;
         this.length = json.length();
+        this.pos = pos;
         read();
     }
 
+    public JsopTokenizer(String json) {
+        this(json, 0);
+    }
+
     public String toString() {
         return jsop;
     }
@@ -92,6 +97,12 @@ public class JsopTokenizer implements Js
         throw getFormatException(jsop, pos, getTokenType(type));
     }
 
+    private void skip(int type) {
+        if (!matches(type)) {
+            throw getFormatException(jsop, pos, getTokenType(type));
+        }
+    }
+
     /**
      * Read a string.
      *
@@ -288,7 +299,7 @@ public class JsopTokenizer implements Js
         for (int i = 0; i < length; i++) {
             char c = s.charAt(i);
             if (c == '\\') {
-                if (i + 1 >= s.length()) {
+                if (i + 1 >= length) {
                     throw getFormatException(s, i);
                 }
                 c = s.charAt(++i);
@@ -394,7 +405,7 @@ public class JsopTokenizer implements Js
                 read();
                 if (!matches('}')) {
                     do {
-                        readString();
+                        skip(STRING);
                         read(':');
                         skipRawValue();
                     } while (matches(','));
@@ -415,4 +426,12 @@ public class JsopTokenizer implements Js
         }
     }
 
+    public int getPos() {
+        return pos;
+    }
+
+    public void setPos(int pos) {
+        this.pos = pos;
+    }
+
 }



Mime
View raw message