jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1344749 - in /jackrabbit/oak/trunk/oak-mk: pom.xml src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
Date Thu, 31 May 2012 14:38:16 GMT
Author: thomasm
Date: Thu May 31 14:38:16 2012
New Revision: 1344749

URL: http://svn.apache.org/viewvc?rev=1344749&view=rev
Log:
OAK-19 JSON utilities: javadocs, CheckForNull annotation

Modified:
    jackrabbit/oak/trunk/oak-mk/pom.xml
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java

Modified: jackrabbit/oak/trunk/oak-mk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/pom.xml?rev=1344749&r1=1344748&r2=1344749&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mk/pom.xml Thu May 31 14:38:16 2012
@@ -121,6 +121,14 @@
       <version>2.7.1</version>
       <optional>true</optional>
     </dependency>
+    
+    <!-- Findbugs annotations -->
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <version>2.0.0</version>
+      <scope>provided</scope>
+    </dependency>
 
     <!--Test Dependencies-->
     <dependency>

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java?rev=1344749&r1=1344748&r2=1344749&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopReader.java
Thu May 31 14:38:16 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.mk.json;
 
+import javax.annotation.CheckForNull;
+
 /**
  * A reader for Json and Jsop strings.
  */
@@ -24,7 +26,7 @@ public interface JsopReader {
     /**
      * The token type that signals the end of the stream.
      */
-    public static final int END = 0;
+    static final int END = 0;
 
     /**
      * The token type of a string value.
@@ -70,7 +72,7 @@ public interface JsopReader {
      * Read a token which must match a given token type.
      *
      * @param type the token type
-     * @return the token (a null object when reading a null value)
+     * @return the token (null when reading a null value)
      * @throws IllegalStateException if the token type doesn't match
      */
     String read(int type);
@@ -78,9 +80,10 @@ public interface JsopReader {
     /**
      * Read a string.
      *
-     * @return the de-escaped string
+     * @return the de-escaped string (null when reading a null value)
      * @throws IllegalStateException if the token type doesn't match
      */
+    @CheckForNull
     String readString();
 
     /**
@@ -98,6 +101,12 @@ public interface JsopReader {
      */
     boolean matches(int type);
 
+    /**
+     * Return the row (escaped) token.
+     *
+     * @return the escaped string (null when reading a null value)
+     */
+    @CheckForNull
     String readRawValue();
 
     /**
@@ -107,6 +116,7 @@ public interface JsopReader {
      *
      * @return the token
      */
+    @CheckForNull
     String getToken();
 
     /**

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java?rev=1344749&r1=1344748&r2=1344749&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/json/JsopTokenizer.java
Thu May 31 14:38:16 2012
@@ -262,10 +262,13 @@ public class JsopTokenizer implements Js
                     }
                     String s = jsop.substring(start, pos);
                     if ("null".equals(s)) {
+                        currentToken = null;
                         return NULL;
                     } else if ("true".equals(s)) {
+                        currentToken = s;
                         return TRUE;
                     } else if ("false".equals(s)) {
+                        currentToken = s;
                         return FALSE;
                     } else {
                         currentToken = s;

Modified: jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java?rev=1344749&r1=1344748&r2=1344749&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
Thu May 31 14:38:16 2012
@@ -63,8 +63,16 @@ public class JsopTest extends TestCase {
     }
 
     public void testNull() {
-        JsopTokenizer t = new JsopTokenizer("null");
+        JsopTokenizer t = new JsopTokenizer("null, 1, null, true, false");
         assertEquals(null, t.read(JsopReader.NULL));
+        assertEquals(",", t.read(','));
+        assertEquals("1", t.read(JsopReader.NUMBER));
+        assertEquals(",", t.read(','));
+        assertEquals(null, t.read(JsopReader.NULL));
+        assertEquals(",", t.read(','));
+        assertEquals("true", t.read(JsopReader.TRUE));
+        assertEquals(",", t.read(','));
+        assertEquals("false", t.read(JsopReader.FALSE));
     }
 
     public void testLineLength() {



Mime
View raw message