Changeset 23191 in osm for applications/editors/josm/plugins/livegps/src/org/json/JSONTokener.java
- Timestamp:
- 2010-09-15T18:56:19+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/org/json/JSONTokener.java
r21622 r23191 39 39 public class JSONTokener { 40 40 41 private int 42 43 private int 44 private int 45 private char 46 private Reader 41 private int character; 42 private boolean eof; 43 private int index; 44 private int line; 45 private char previous; 46 private Reader reader; 47 47 private boolean usePrevious; 48 48 … … 54 54 */ 55 55 public JSONTokener(Reader reader) { 56 this.reader = reader.markSupported() ? 57 56 this.reader = reader.markSupported() ? 57 reader : new BufferedReader(reader); 58 58 this.eof = false; 59 59 this.usePrevious = false; … … 109 109 return -1; 110 110 } 111 111 112 112 public boolean end() { 113 113 return eof && !usePrevious; 114 114 } 115 115 … … 124 124 if (end()) { 125 125 return false; 126 } 126 } 127 127 back(); 128 128 return true; … … 138 138 int c; 139 139 if (this.usePrevious) { 140 140 this.usePrevious = false; 141 141 c = this.previous; 142 142 } else { 143 144 145 146 147 148 149 150 151 152 153 } 154 155 156 157 158 159 160 161 162 163 164 143 try { 144 c = this.reader.read(); 145 } catch (IOException exception) { 146 throw new JSONException(exception); 147 } 148 149 if (c <= 0) { // End of stream 150 this.eof = true; 151 c = 0; 152 } 153 } 154 this.index += 1; 155 if (this.previous == '\r') { 156 this.line += 1; 157 this.character = c == '\n' ? 0 : 1; 158 } else if (c == '\n') { 159 this.line += 1; 160 this.character = 0; 161 } else { 162 this.character += 1; 163 } 164 this.previous = (char) c; 165 165 return this.previous; 166 166 } … … 204 204 buffer[pos] = next(); 205 205 if (end()) { 206 throw syntaxError("Substring bounds error"); 206 throw syntaxError("Substring bounds error"); 207 207 } 208 208 pos += 1; … … 273 273 case '\\': 274 274 case '/': 275 276 275 sb.append(c); 276 break; 277 277 default: 278 278 throw syntaxError("Illegal escape."); … … 412 412 return c; 413 413 } 414 414 415 415 416 416 /**
Note:
See TracChangeset
for help on using the changeset viewer.