aboutsummaryrefslogtreecommitdiff
path: root/src/org/json/simple/parser
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-18 17:53:00 +0200
committerPacien TRAN-GIRARD2014-05-18 17:53:00 +0200
commitdb373254f918ef75062698757e6cd6e13e26289f (patch)
treee1975b38b06c88f469f3f3e2e0d9cf515778f9f1 /src/org/json/simple/parser
parent0d4651e54f40f4dad929c419e92e37a15926f7be (diff)
downloadesieequest-db373254f918ef75062698757e6cd6e13e26289f.tar.gz
Format code (100 chars line)
Diffstat (limited to 'src/org/json/simple/parser')
-rw-r--r--src/org/json/simple/parser/JSONParser.java39
-rw-r--r--src/org/json/simple/parser/ParseException.java9
-rw-r--r--src/org/json/simple/parser/Yylex.java68
3 files changed, 88 insertions, 28 deletions
diff --git a/src/org/json/simple/parser/JSONParser.java b/src/org/json/simple/parser/JSONParser.java
index 4874eea..85472bb 100644
--- a/src/org/json/simple/parser/JSONParser.java
+++ b/src/org/json/simple/parser/JSONParser.java
@@ -78,7 +78,8 @@ public class JSONParser {
78 return this.parse(s, (ContainerFactory) null); 78 return this.parse(s, (ContainerFactory) null);
79 } 79 }
80 80
81 public Object parse(final String s, final ContainerFactory containerFactory) throws ParseException { 81 public Object parse(final String s, final ContainerFactory containerFactory)
82 throws ParseException {
82 final StringReader in = new StringReader(s); 83 final StringReader in = new StringReader(s);
83 try { 84 try {
84 return this.parse(in, containerFactory); 85 return this.parse(in, containerFactory);
@@ -109,7 +110,8 @@ public class JSONParser {
109 * @throws ParseException 110 * @throws ParseException
110 */ 111 */
111 @SuppressWarnings({ "rawtypes", "unchecked" }) 112 @SuppressWarnings({ "rawtypes", "unchecked" })
112 public Object parse(final Reader in, final ContainerFactory containerFactory) throws IOException, ParseException { 113 public Object parse(final Reader in, final ContainerFactory containerFactory)
114 throws IOException, ParseException {
113 this.reset(in); 115 this.reset(in);
114 final LinkedList statusStack = new LinkedList(); 116 final LinkedList statusStack = new LinkedList();
115 final LinkedList valueStack = new LinkedList(); 117 final LinkedList valueStack = new LinkedList();
@@ -144,7 +146,8 @@ public class JSONParser {
144 if (this.token.type == Yytoken.TYPE_EOF) { 146 if (this.token.type == Yytoken.TYPE_EOF) {
145 return valueStack.removeFirst(); 147 return valueStack.removeFirst();
146 } else { 148 } else {
147 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 149 throw new ParseException(this.getPosition(),
150 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
148 } 151 }
149 152
150 case S_IN_OBJECT: 153 case S_IN_OBJECT:
@@ -250,17 +253,20 @@ public class JSONParser {
250 }// inner switch 253 }// inner switch
251 break; 254 break;
252 case S_IN_ERROR: 255 case S_IN_ERROR:
253 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 256 throw new ParseException(this.getPosition(),
257 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
254 }// switch 258 }// switch
255 if (this.status == JSONParser.S_IN_ERROR) { 259 if (this.status == JSONParser.S_IN_ERROR) {
256 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 260 throw new ParseException(this.getPosition(),
261 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
257 } 262 }
258 } while (this.token.type != Yytoken.TYPE_EOF); 263 } while (this.token.type != Yytoken.TYPE_EOF);
259 } catch (final IOException ie) { 264 } catch (final IOException ie) {
260 throw ie; 265 throw ie;
261 } 266 }
262 267
263 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 268 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN,
269 this.token);
264 } 270 }
265 271
266 private void nextToken() throws ParseException, IOException { 272 private void nextToken() throws ParseException, IOException {
@@ -298,7 +304,8 @@ public class JSONParser {
298 this.parse(s, contentHandler, false); 304 this.parse(s, contentHandler, false);
299 } 305 }
300 306
301 public void parse(final String s, final ContentHandler contentHandler, final boolean isResume) throws ParseException { 307 public void parse(final String s, final ContentHandler contentHandler, final boolean isResume)
308 throws ParseException {
302 final StringReader in = new StringReader(s); 309 final StringReader in = new StringReader(s);
303 try { 310 try {
304 this.parse(in, contentHandler, isResume); 311 this.parse(in, contentHandler, isResume);
@@ -310,7 +317,8 @@ public class JSONParser {
310 } 317 }
311 } 318 }
312 319
313 public void parse(final Reader in, final ContentHandler contentHandler) throws IOException, ParseException { 320 public void parse(final Reader in, final ContentHandler contentHandler) throws IOException,
321 ParseException {
314 this.parse(in, contentHandler, false); 322 this.parse(in, contentHandler, false);
315 } 323 }
316 324
@@ -331,7 +339,8 @@ public class JSONParser {
331 * @throws ParseException 339 * @throws ParseException
332 */ 340 */
333 @SuppressWarnings({ "unchecked", "rawtypes" }) 341 @SuppressWarnings({ "unchecked", "rawtypes" })
334 public void parse(final Reader in, final ContentHandler contentHandler, boolean isResume) throws IOException, ParseException { 342 public void parse(final Reader in, final ContentHandler contentHandler, boolean isResume)
343 throws IOException, ParseException {
335 if (!isResume) { 344 if (!isResume) {
336 this.reset(in); 345 this.reset(in);
337 this.handlerStatusStack = new LinkedList<>(); 346 this.handlerStatusStack = new LinkedList<>();
@@ -386,7 +395,8 @@ public class JSONParser {
386 return; 395 return;
387 } else { 396 } else {
388 this.status = JSONParser.S_IN_ERROR; 397 this.status = JSONParser.S_IN_ERROR;
389 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 398 throw new ParseException(this.getPosition(),
399 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
390 } 400 }
391 401
392 case S_IN_OBJECT: 402 case S_IN_OBJECT:
@@ -518,10 +528,12 @@ public class JSONParser {
518 return; 528 return;
519 529
520 case S_IN_ERROR: 530 case S_IN_ERROR:
521 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 531 throw new ParseException(this.getPosition(),
532 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
522 }// switch 533 }// switch
523 if (this.status == JSONParser.S_IN_ERROR) { 534 if (this.status == JSONParser.S_IN_ERROR) {
524 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 535 throw new ParseException(this.getPosition(),
536 ParseException.ERROR_UNEXPECTED_TOKEN, this.token);
525 } 537 }
526 } while (this.token.type != Yytoken.TYPE_EOF); 538 } while (this.token.type != Yytoken.TYPE_EOF);
527 } catch (final IOException ie) { 539 } catch (final IOException ie) {
@@ -539,6 +551,7 @@ public class JSONParser {
539 } 551 }
540 552
541 this.status = JSONParser.S_IN_ERROR; 553 this.status = JSONParser.S_IN_ERROR;
542 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN, this.token); 554 throw new ParseException(this.getPosition(), ParseException.ERROR_UNEXPECTED_TOKEN,
555 this.token);
543 } 556 }
544} 557}
diff --git a/src/org/json/simple/parser/ParseException.java b/src/org/json/simple/parser/ParseException.java
index df1b1d1..6bd8d8c 100644
--- a/src/org/json/simple/parser/ParseException.java
+++ b/src/org/json/simple/parser/ParseException.java
@@ -75,13 +75,16 @@ public class ParseException extends Exception {
75 75
76 switch (this.errorType) { 76 switch (this.errorType) {
77 case ERROR_UNEXPECTED_CHAR: 77 case ERROR_UNEXPECTED_CHAR:
78 sb.append("Unexpected character (").append(this.unexpectedObject).append(") at position ").append(this.position).append("."); 78 sb.append("Unexpected character (").append(this.unexpectedObject).append(
79 ") at position ").append(this.position).append(".");
79 break; 80 break;
80 case ERROR_UNEXPECTED_TOKEN: 81 case ERROR_UNEXPECTED_TOKEN:
81 sb.append("Unexpected token ").append(this.unexpectedObject).append(" at position ").append(this.position).append("."); 82 sb.append("Unexpected token ").append(this.unexpectedObject).append(" at position ")
83 .append(this.position).append(".");
82 break; 84 break;
83 case ERROR_UNEXPECTED_EXCEPTION: 85 case ERROR_UNEXPECTED_EXCEPTION:
84 sb.append("Unexpected exception at position ").append(this.position).append(": ").append(this.unexpectedObject); 86 sb.append("Unexpected exception at position ").append(this.position).append(": ")
87 .append(this.unexpectedObject);
85 break; 88 break;
86 default: 89 default:
87 sb.append("Unkown error at position ").append(this.position).append("."); 90 sb.append("Unkown error at position ").append(this.position).append(".");
diff --git a/src/org/json/simple/parser/Yylex.java b/src/org/json/simple/parser/Yylex.java
index 10049c4..c1cf09d 100644
--- a/src/org/json/simple/parser/Yylex.java
+++ b/src/org/json/simple/parser/Yylex.java
@@ -24,7 +24,10 @@ class Yylex {
24 /** 24 /**
25 * Translates characters to character classes 25 * Translates characters to character classes
26 */ 26 */
27 private static final String ZZ_CMAP_PACKED = "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0" + "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5" + "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21" + "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20" + "\5\0\1\25\1\0\1\26\uff82\0"; 27 private static final String ZZ_CMAP_PACKED = "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"
28 + "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"
29 + "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"
30 + "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20" + "\5\0\1\25\1\0\1\26\uff82\0";
28 31
29 /** 32 /**
30 * Translates characters to character classes 33 * Translates characters to character classes
@@ -36,7 +39,9 @@ class Yylex {
36 */ 39 */
37 private static final int[] ZZ_ACTION = Yylex.zzUnpackAction(); 40 private static final int[] ZZ_ACTION = Yylex.zzUnpackAction();
38 41
39 private static final String ZZ_ACTION_PACKED_0 = "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6" + "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0" + "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24" + "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0" + "\1\30"; 42 private static final String ZZ_ACTION_PACKED_0 = "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"
43 + "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0" + "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"
44