Mercurial > dive4elements > framework
comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/JSON.java @ 394:c40729bfe06d
Removed trailing whitespace.
artifacts/trunk@4764 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 23 Jun 2012 08:20:02 +0000 |
parents | 823752e3d392 |
children |
comparison
equal
deleted
inserted
replaced
393:b7831cefbb62 | 394:c40729bfe06d |
---|---|
24 private static final boolean isDigit(int c) { | 24 private static final boolean isDigit(int c) { |
25 return c >= '0' && c <= '9'; | 25 return c >= '0' && c <= '9'; |
26 } | 26 } |
27 | 27 |
28 public static final boolean isWhitespace(int c) { | 28 public static final boolean isWhitespace(int c) { |
29 return c == ' ' || c == '\n' || c == '\r' | 29 return c == ' ' || c == '\n' || c == '\r' |
30 || c == '\t' || c == '\f'; | 30 || c == '\t' || c == '\f'; |
31 } | 31 } |
32 | 32 |
33 private static final void match(int c, int x) throws IOException { | 33 private static final void match(int c, int x) throws IOException { |
34 if (c != x) { | 34 if (c != x) { |
158 } | 158 } |
159 } | 159 } |
160 out.print(']'); | 160 out.print(']'); |
161 } | 161 } |
162 | 162 |
163 public static Map<String, Object> parse(String in) | 163 public static Map<String, Object> parse(String in) |
164 throws IOException | 164 throws IOException |
165 { | 165 { |
166 return parse(asInputStream(in)); | 166 return parse(asInputStream(in)); |
167 } | 167 } |
168 | 168 |
169 private static InputStream asInputStream(String in) { | 169 private static InputStream asInputStream(String in) { |
176 bytes = in.getBytes(); | 176 bytes = in.getBytes(); |
177 } | 177 } |
178 return new ByteArrayInputStream(bytes); | 178 return new ByteArrayInputStream(bytes); |
179 } | 179 } |
180 | 180 |
181 public static Map<String, Object> parse(InputStream in) | 181 public static Map<String, Object> parse(InputStream in) |
182 throws IOException | 182 throws IOException |
183 { | 183 { |
184 return parseObject(new PushbackInputStream(in, 1)); | 184 return parseObject(new PushbackInputStream(in, 1)); |
185 } | 185 } |
186 | 186 |
187 public static Map<String, Object> parse(PushbackInputStream in) | 187 public static Map<String, Object> parse(PushbackInputStream in) |
188 throws IOException | 188 throws IOException |
189 { | 189 { |
190 return parseObject(in); | 190 return parseObject(in); |
191 } | 191 } |
192 | 192 |
193 private static final String parseString( | 193 private static final String parseString( |
264 return sb.toString(); | 264 return sb.toString(); |
265 } | 265 } |
266 | 266 |
267 private static final Boolean parseTrue(InputStream in) | 267 private static final Boolean parseTrue(InputStream in) |
268 throws IOException | 268 throws IOException |
269 { | 269 { |
270 match('t', eof(in)); | 270 match('t', eof(in)); |
271 match('r', eof(in)); | 271 match('r', eof(in)); |
272 match('u', eof(in)); | 272 match('u', eof(in)); |
273 match('e', eof(in)); | 273 match('e', eof(in)); |
274 return Boolean.TRUE; | 274 return Boolean.TRUE; |
275 } | 275 } |
276 | 276 |
277 private static final Boolean parseFalse(InputStream in) | 277 private static final Boolean parseFalse(InputStream in) |
278 throws IOException | 278 throws IOException |
279 { | 279 { |
280 match('f', eof(in)); | 280 match('f', eof(in)); |
281 match('a', eof(in)); | 281 match('a', eof(in)); |
282 match('l', eof(in)); | 282 match('l', eof(in)); |
283 match('s', eof(in)); | 283 match('s', eof(in)); |
284 match('e', eof(in)); | 284 match('e', eof(in)); |
285 return Boolean.FALSE; | 285 return Boolean.FALSE; |
286 } | 286 } |
287 | 287 |
288 private static final Object parseNull(InputStream in) | 288 private static final Object parseNull(InputStream in) |
289 throws IOException | 289 throws IOException |
290 { | 290 { |
291 match('n', eof(in)); | 291 match('n', eof(in)); |
292 match('u', eof(in)); | 292 match('u', eof(in)); |
293 match('l', eof(in)); | 293 match('l', eof(in)); |
294 match('l', eof(in)); | 294 match('l', eof(in)); |
295 return null; | 295 return null; |
413 value = parseNumber(in); | 413 value = parseNumber(in); |
414 } | 414 } |
415 pairs.put(string, value); | 415 pairs.put(string, value); |
416 } | 416 } |
417 | 417 |
418 private static Map<String, Object> parseObject(PushbackInputStream in) | 418 private static Map<String, Object> parseObject(PushbackInputStream in) |
419 throws IOException | 419 throws IOException |
420 { | 420 { |
421 Map<String, Object> pairs = new LinkedHashMap<String, Object>(); | 421 Map<String, Object> pairs = new LinkedHashMap<String, Object>(); |
422 | 422 |
423 int c = whitespace(in); | 423 int c = whitespace(in); |