Skip to content

Commit da8fd05

Browse files
JAVA-356: make JSONParseException public
1 parent e8af1e2 commit da8fd05

File tree

2 files changed

+52
-35
lines changed

2 files changed

+52
-35
lines changed

src/main/com/mongodb/util/JSON.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -735,38 +735,3 @@ else if(current == ']') {
735735
}
736736

737737
}
738-
739-
/**
740-
* Exception throw when invalid JSON is passed to JSONParser.
741-
*
742-
* This exception creates a message that points to the first
743-
* offending character in the JSON string:
744-
* <pre>
745-
* { "x" : 3, "y" : 4, some invalid json.... }
746-
* ^
747-
* </pre>
748-
*/
749-
class JSONParseException extends RuntimeException {
750-
751-
private static final long serialVersionUID = -4415279469780082174L;
752-
753-
String s;
754-
int pos;
755-
756-
public String getMessage() {
757-
StringBuilder sb = new StringBuilder();
758-
sb.append("\n");
759-
sb.append(s);
760-
sb.append("\n");
761-
for(int i=0;i<pos;i++) {
762-
sb.append(" ");
763-
}
764-
sb.append("^");
765-
return sb.toString();
766-
}
767-
768-
public JSONParseException(String s, int pos) {
769-
this.s = s;
770-
this.pos = pos;
771-
}
772-
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright (C) 2008 10gen Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.mongodb.util;
18+
19+
/**
20+
* Exception throw when invalid JSON is passed to JSONParser.
21+
*
22+
* This exception creates a message that points to the first
23+
* offending character in the JSON string:
24+
* <pre>
25+
* { "x" : 3, "y" : 4, some invalid json.... }
26+
* ^
27+
* </pre>
28+
*/
29+
public class JSONParseException extends RuntimeException {
30+
31+
private static final long serialVersionUID = -4415279469780082174L;
32+
33+
String s;
34+
int pos;
35+
36+
public String getMessage() {
37+
StringBuilder sb = new StringBuilder();
38+
sb.append("\n");
39+
sb.append(s);
40+
sb.append("\n");
41+
for(int i=0;i<pos;i++) {
42+
sb.append(" ");
43+
}
44+
sb.append("^");
45+
return sb.toString();
46+
}
47+
48+
public JSONParseException(String s, int pos) {
49+
this.s = s;
50+
this.pos = pos;
51+
}
52+
}

0 commit comments

Comments
 (0)