Skip to main content

[jsonp~git:ddb2c89c] [JSONP-20] localizing tokenizer messages

  • From:
  • To:
  • Subject: [jsonp~git:ddb2c89c] [JSONP-20] localizing tokenizer messages
  • Date: Fri, 11 Oct 2013 23:09:51 +0000

Project:    jsonp
Repository: git
Revision:   ddb2c89ca49e93c214b6a164264f4debb5870af4
Author:     jitu
Date:       2013-10-11 23:09:38 UTC
Link:       

Log Message:
------------
[JSONP-20] localizing tokenizer messages



Revisions:
----------
ddb2c89ca49e93c214b6a164264f4debb5870af4


Modified Paths:
---------------
impl/src/main/java/org/glassfish/json/JsonMessages.java
impl/src/main/java/org/glassfish/json/JsonTokenizer.java
impl/src/main/resources/org/glassfish/json/messages.properties


Diffs:
------
--- a/impl/src/main/java/org/glassfish/json/JsonMessages.java
+++ b/impl/src/main/java/org/glassfish/json/JsonMessages.java
@@ -58,6 +58,10 @@ final class JsonMessages {
         return localize("tokenizer.unexpected.char", ch);
     }
 
+    static String TOKENIZER_EXPECTED_CHAR(char unexp, char exp) {
+        return localize("tokenizer.expected.char", unexp, exp);
+    }
+
     static String TOKENIZER_IO_ERR() {
         return localize("tokenizer.io.err");
     }--- a/impl/src/main/java/org/glassfish/json/JsonTokenizer.java
+++ b/impl/src/main/java/org/glassfish/json/JsonTokenizer.java
@@ -174,8 +174,6 @@ final class JsonTokenizer implements Closeable {
                     break;
                 case '"':
                     return;
-                case -1:
-                    throw new JsonException("Unexpected EOF");
                 default:
                     throw new 
JsonParsingException(JsonMessages.TOKENIZER_UNEXPECTED_CHAR(ch), 
getLastCharLocation());
             }
@@ -298,49 +296,69 @@ final class JsonTokenizer implements Closeable {
     private void readTrue() {
         char ch1 = (char) read();
         if (ch1 != 'r') {
-            throw new JsonParsingException("Unexpected Char="+ch1+" 
expecting 'r'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch1, 'r'),
+                getLastCharLocation());
         }
         char ch2 = (char) read();
         if (ch2 != 'u') {
-            throw new JsonParsingException("Unexpected Char="+ch2+" 
expecting 'u'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch2, 'u'),
+                getLastCharLocation());
         }
         char ch3 = (char) read();
         if (ch3 != 'e') {
-            throw new JsonParsingException("Unexpected Char="+ch3+" 
expecting 'e'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch3, 'e'),
+                getLastCharLocation());
         }
     }
 
     private void readFalse() {
         char ch1 = (char) read();
         if (ch1 != 'a') {
-            throw new JsonParsingException("Unexpected Char="+ch1+" 
expecting 'a'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch1, 'a'),
+                getLastCharLocation());
         }
         char ch2 = (char) read();
         if (ch2 != 'l') {
-            throw new JsonParsingException("Unexpected Char="+ch2+" 
expecting 'l'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch2, 'l'),
+                getLastCharLocation());
         }
         char ch3 = (char) read();
         if (ch3 != 's') {
-            throw new JsonParsingException("Unexpected Char="+ch3+" 
expecting 's'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch3, 's'),
+                getLastCharLocation());
         }
         char ch4 = (char) read();
         if (ch4 != 'e') {
-            throw new JsonParsingException("Unexpected Char="+ch4+" 
expecting 'e'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch4, 'e'),
+                getLastCharLocation());
         }
     }
 
     private void readNull() {
         char ch1 = (char) read();
         if (ch1 != 'u') {
-            throw new JsonParsingException("Unexpected Char="+ch1+" 
expecting 'u'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch1, 'u'),
+                getLastCharLocation());
         }
         char ch2 = (char) read();
         if (ch2 != 'l') {
-            throw new JsonParsingException("Unexpected Char="+ch2+" 
expecting 'l'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch2, 'l'),
+                getLastCharLocation());
         }
         char ch3 = (char) read();
         if (ch3 != 'l') {
-            throw new JsonParsingException("Unexpected Char="+ch3+" 
expecting 'l'", getLastCharLocation());
+            throw new JsonParsingException(
+                JsonMessages.TOKENIZER_EXPECTED_CHAR(ch3, 'l'),
+                getLastCharLocation());
         }
     }
 --- a/impl/src/main/resources/org/glassfish/json/messages.properties
+++ b/impl/src/main/resources/org/glassfish/json/messages.properties
@@ -35,5 +35,6 @@ arrbuilder.value.null=Cannot invoke add(null) while 
building JsonArray.
 arrbuilder.object.builder.null=Object builder that is used to add a value to 
JSON array cannot be null
 arrbuilder.array.builder.null=Array builder that is used to add a value to 
JSON array cannot be null
 
-tokenizer.unexpected.char=Unexpected Char {0}
+tokenizer.unexpected.char=Unexpected char {0}
+tokenizer.expected.char=Unexpected char {0} expecting {1}
 tokenizer.io.err=I/O error while parsing JSON





[jsonp~git:ddb2c89c] [JSONP-20] localizing tokenizer messages

jitu 10/11/2013
 
 
Close
loading
Please Confirm
Close