1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package org.json.simple; |
6 |
|
|
7 |
|
import java.io.IOException; |
8 |
|
import java.io.StringWriter; |
9 |
|
import java.io.Writer; |
10 |
|
import java.util.ArrayList; |
11 |
|
import java.util.Collection; |
12 |
|
import java.util.Iterator; |
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
@author |
18 |
|
|
|
|
| 12.1% |
Uncovered Elements: 218 (248) |
Complexity: 66 |
Complexity Density: 0.41 |
|
19 |
|
public class JSONArray extends ArrayList |
20 |
|
implements JSONAware, JSONStreamAware |
21 |
|
{ |
22 |
|
private static final long serialVersionUID = 3957988303675231981L; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
41284 |
public JSONArray()... |
28 |
|
{ |
29 |
41284 |
super(); |
30 |
|
} |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@param |
37 |
|
|
38 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
0 |
public JSONArray(Collection c)... |
40 |
|
{ |
41 |
0 |
super(c); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@see |
50 |
|
|
51 |
|
@param |
52 |
|
@param |
53 |
|
|
|
|
| 75% |
Uncovered Elements: 6 (24) |
Complexity: 5 |
Complexity Density: 0.31 |
|
54 |
8246 |
public static void writeJSONString(Collection collection, Writer out)... |
55 |
|
throws IOException |
56 |
|
{ |
57 |
8246 |
if (collection == null) |
58 |
|
{ |
59 |
0 |
out.write("null"); |
60 |
0 |
return; |
61 |
|
} |
62 |
|
|
63 |
8246 |
boolean first = true; |
64 |
8246 |
Iterator iter = collection.iterator(); |
65 |
|
|
66 |
8246 |
out.write('['); |
67 |
16534 |
while (iter.hasNext()) |
68 |
|
{ |
69 |
8288 |
if (first) |
70 |
8246 |
first = false; |
71 |
|
else |
72 |
42 |
out.write(','); |
73 |
|
|
74 |
8288 |
Object value = iter.next(); |
75 |
8288 |
if (value == null) |
76 |
|
{ |
77 |
0 |
out.write("null"); |
78 |
0 |
continue; |
79 |
|
} |
80 |
|
|
81 |
8288 |
JSONValue.writeJSONString(value, out); |
82 |
|
} |
83 |
8246 |
out.write(']'); |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0 |
public void writeJSONString(Writer out) throws IOException... |
87 |
|
{ |
88 |
0 |
writeJSONString(this, out); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@see |
97 |
|
|
98 |
|
@param |
99 |
|
@return |
100 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
101 |
8246 |
public static String toJSONString(Collection collection)... |
102 |
|
{ |
103 |
8246 |
final StringWriter writer = new StringWriter(); |
104 |
|
|
105 |
8246 |
try |
106 |
|
{ |
107 |
8246 |
writeJSONString(collection, writer); |
108 |
8246 |
return writer.toString(); |
109 |
|
} catch (IOException e) |
110 |
|
{ |
111 |
|
|
112 |
0 |
throw new RuntimeException(e); |
113 |
|
} |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
116 |
0 |
public static void writeJSONString(byte[] array, Writer out)... |
117 |
|
throws IOException |
118 |
|
{ |
119 |
0 |
if (array == null) |
120 |
|
{ |
121 |
0 |
out.write("null"); |
122 |
|
} |
123 |
0 |
else if (array.length == 0) |
124 |
|
{ |
125 |
0 |
out.write("[]"); |
126 |
|
} |
127 |
|
else |
128 |
|
{ |
129 |
0 |
out.write("["); |
130 |
0 |
out.write(String.valueOf(array[0])); |
131 |
|
|
132 |
0 |
for (int i = 1; i < array.length; i++) |
133 |
|
{ |
134 |
0 |
out.write(","); |
135 |
0 |
out.write(String.valueOf(array[i])); |
136 |
|
} |
137 |
|
|
138 |
0 |
out.write("]"); |
139 |
|
} |
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
142 |
0 |
public static String toJSONString(byte[] array)... |
143 |
|
{ |
144 |
0 |
final StringWriter writer = new StringWriter(); |
145 |
|
|
146 |
0 |
try |
147 |
|
{ |
148 |
0 |
writeJSONString(array, writer); |
149 |
0 |
return writer.toString(); |
150 |
|
} catch (IOException e) |
151 |
|
{ |
152 |
|
|
153 |
0 |
throw new RuntimeException(e); |
154 |
|
} |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
157 |
0 |
public static void writeJSONString(short[] array, Writer out)... |
158 |
|
throws IOException |
159 |
|
{ |
160 |
0 |
if (array == null) |
161 |
|
{ |
162 |
0 |
out.write("null"); |
163 |
|
} |
164 |
0 |
else if (array.length == 0) |
165 |
|
{ |
166 |
0 |
out.write("[]"); |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
0 |
out.write("["); |
171 |
0 |
out.write(String.valueOf(array[0])); |
172 |
|
|
173 |
0 |
for (int i = 1; i < array.length; i++) |
174 |
|
{ |
175 |
0 |
out.write(","); |
176 |
0 |
out.write(String.valueOf(array[i])); |
177 |
|
} |
178 |
|
|
179 |
0 |
out.write("]"); |
180 |
|
} |
181 |
|
} |
182 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
183 |
0 |
public static String toJSONString(short[] array)... |
184 |
|
{ |
185 |
0 |
final StringWriter writer = new StringWriter(); |
186 |
|
|
187 |
0 |
try |
188 |
|
{ |
189 |
0 |
writeJSONString(array, writer); |
190 |
0 |
return writer.toString(); |
191 |
|
} catch (IOException e) |
192 |
|
{ |
193 |
|
|
194 |
0 |
throw new RuntimeException(e); |
195 |
|
} |
196 |
|
} |
197 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
198 |
0 |
public static void writeJSONString(int[] array, Writer out)... |
199 |
|
throws IOException |
200 |
|
{ |
201 |
0 |
if (array == null) |
202 |
|
{ |
203 |
0 |
out.write("null"); |
204 |
|
} |
205 |
0 |
else if (array.length == 0) |
206 |
|
{ |
207 |
0 |
out.write("[]"); |
208 |
|
} |
209 |
|
else |
210 |
|
{ |
211 |
0 |
out.write("["); |
212 |
0 |
out.write(String.valueOf(array[0])); |
213 |
|
|
214 |
0 |
for (int i = 1; i < array.length; i++) |
215 |
|
{ |
216 |
0 |
out.write(","); |
217 |
0 |
out.write(String.valueOf(array[i])); |
218 |
|
} |
219 |
|
|
220 |
0 |
out.write("]"); |
221 |
|
} |
222 |
|
} |
223 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
224 |
0 |
public static String toJSONString(int[] array)... |
225 |
|
{ |
226 |
0 |
final StringWriter writer = new StringWriter(); |
227 |
|
|
228 |
0 |
try |
229 |
|
{ |
230 |
0 |
writeJSONString(array, writer); |
231 |
0 |
return writer.toString(); |
232 |
|
} catch (IOException e) |
233 |
|
{ |
234 |
|
|
235 |
0 |
throw new RuntimeException(e); |
236 |
|
} |
237 |
|
} |
238 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
239 |
0 |
public static void writeJSONString(long[] array, Writer out)... |
240 |
|
throws IOException |
241 |
|
{ |
242 |
0 |
if (array == null) |
243 |
|
{ |
244 |
0 |
out.write("null"); |
245 |
|
} |
246 |
0 |
else if (array.length == 0) |
247 |
|
{ |
248 |
0 |
out.write("[]"); |
249 |
|
} |
250 |
|
else |
251 |
|
{ |
252 |
0 |
out.write("["); |
253 |
0 |
out.write(String.valueOf(array[0])); |
254 |
|
|
255 |
0 |
for (int i = 1; i < array.length; i++) |
256 |
|
{ |
257 |
0 |
out.write(","); |
258 |
0 |
out.write(String.valueOf(array[i])); |
259 |
|
} |
260 |
|
|
261 |
0 |
out.write("]"); |
262 |
|
} |
263 |
|
} |
264 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
265 |
0 |
public static String toJSONString(long[] array)... |
266 |
|
{ |
267 |
0 |
final StringWriter writer = new StringWriter(); |
268 |
|
|
269 |
0 |
try |
270 |
|
{ |
271 |
0 |
writeJSONString(array, writer); |
272 |
0 |
return writer.toString(); |
273 |
|
} catch (IOException e) |
274 |
|
{ |
275 |
|
|
276 |
0 |
throw new RuntimeException(e); |
277 |
|
} |
278 |
|
} |
279 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
280 |
0 |
public static void writeJSONString(float[] array, Writer out)... |
281 |
|
throws IOException |
282 |
|
{ |
283 |
0 |
if (array == null) |
284 |
|
{ |
285 |
0 |
out.write("null"); |
286 |
|
} |
287 |
0 |
else if (array.length == 0) |
288 |
|
{ |
289 |
0 |
out.write("[]"); |
290 |
|
} |
291 |
|
else |
292 |
|
{ |
293 |
0 |
out.write("["); |
294 |
0 |
out.write(String.valueOf(array[0])); |
295 |
|
|
296 |
0 |
for (int i = 1; i < array.length; i++) |
297 |
|
{ |
298 |
0 |
out.write(","); |
299 |
0 |
out.write(String.valueOf(array[i])); |
300 |
|
} |
301 |
|
|
302 |
0 |
out.write("]"); |
303 |
|
} |
304 |
|
} |
305 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
306 |
0 |
public static String toJSONString(float[] array)... |
307 |
|
{ |
308 |
0 |
final StringWriter writer = new StringWriter(); |
309 |
|
|
310 |
0 |
try |
311 |
|
{ |
312 |
0 |
writeJSONString(array, writer); |
313 |
0 |
return writer.toString(); |
314 |
|
} catch (IOException e) |
315 |
|
{ |
316 |
|
|
317 |
0 |
throw new RuntimeException(e); |
318 |
|
} |
319 |
|
} |
320 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
321 |
0 |
public static void writeJSONString(double[] array, Writer out)... |
322 |
|
throws IOException |
323 |
|
{ |
324 |
0 |
if (array == null) |
325 |
|
{ |
326 |
0 |
out.write("null"); |
327 |
|
} |
328 |
0 |
else if (array.length == 0) |
329 |
|
{ |
330 |
0 |
out.write("[]"); |
331 |
|
} |
332 |
|
else |
333 |
|
{ |
334 |
0 |
out.write("["); |
335 |
0 |
out.write(String.valueOf(array[0])); |
336 |
|
|
337 |
0 |
for (int i = 1; i < array.length; i++) |
338 |
|
{ |
339 |
0 |
out.write(","); |
340 |
0 |
out.write(String.valueOf(array[i])); |
341 |
|
} |
342 |
|
|
343 |
0 |
out.write("]"); |
344 |
|
} |
345 |
|
} |
346 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
347 |
0 |
public static String toJSONString(double[] array)... |
348 |
|
{ |
349 |
0 |
final StringWriter writer = new StringWriter(); |
350 |
|
|
351 |
0 |
try |
352 |
|
{ |
353 |
0 |
writeJSONString(array, writer); |
354 |
0 |
return writer.toString(); |
355 |
|
} catch (IOException e) |
356 |
|
{ |
357 |
|
|
358 |
0 |
throw new RuntimeException(e); |
359 |
|
} |
360 |
|
} |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
362 |
0 |
public static void writeJSONString(boolean[] array, Writer out)... |
363 |
|
throws IOException |
364 |
|
{ |
365 |
0 |
if (array == null) |
366 |
|
{ |
367 |
0 |
out.write("null"); |
368 |
|
} |
369 |
0 |
else if (array.length == 0) |
370 |
|
{ |
371 |
0 |
out.write("[]"); |
372 |
|
} |
373 |
|
else |
374 |
|
{ |
375 |
0 |
out.write("["); |
376 |
0 |
out.write(String.valueOf(array[0])); |
377 |
|
|
378 |
0 |
for (int i = 1; i < array.length; i++) |
379 |
|
{ |
380 |
0 |
out.write(","); |
381 |
0 |
out.write(String.valueOf(array[i])); |
382 |
|
} |
383 |
|
|
384 |
0 |
out.write("]"); |
385 |
|
} |
386 |
|
} |
387 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
388 |
0 |
public static String toJSONString(boolean[] array)... |
389 |
|
{ |
390 |
0 |
final StringWriter writer = new StringWriter(); |
391 |
|
|
392 |
0 |
try |
393 |
|
{ |
394 |
0 |
writeJSONString(array, writer); |
395 |
0 |
return writer.toString(); |
396 |
|
} catch (IOException e) |
397 |
|
{ |
398 |
|
|
399 |
0 |
throw new RuntimeException(e); |
400 |
|
} |
401 |
|
} |
402 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
403 |
0 |
public static void writeJSONString(char[] array, Writer out)... |
404 |
|
throws IOException |
405 |
|
{ |
406 |
0 |
if (array == null) |
407 |
|
{ |
408 |
0 |
out.write("null"); |
409 |
|
} |
410 |
0 |
else if (array.length == 0) |
411 |
|
{ |
412 |
0 |
out.write("[]"); |
413 |
|
} |
414 |
|
else |
415 |
|
{ |
416 |
0 |
out.write("[\""); |
417 |
0 |
out.write(String.valueOf(array[0])); |
418 |
|
|
419 |
0 |
for (int i = 1; i < array.length; i++) |
420 |
|
{ |
421 |
0 |
out.write("\",\""); |
422 |
0 |
out.write(String.valueOf(array[i])); |
423 |
|
} |
424 |
|
|
425 |
0 |
out.write("\"]"); |
426 |
|
} |
427 |
|
} |
428 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
429 |
0 |
public static String toJSONString(char[] array)... |
430 |
|
{ |
431 |
0 |
final StringWriter writer = new StringWriter(); |
432 |
|
|
433 |
0 |
try |
434 |
|
{ |
435 |
0 |
writeJSONString(array, writer); |
436 |
0 |
return writer.toString(); |
437 |
|
} catch (IOException e) |
438 |
|
{ |
439 |
|
|
440 |
0 |
throw new RuntimeException(e); |
441 |
|
} |
442 |
|
} |
443 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
444 |
0 |
public static void writeJSONString(Object[] array, Writer out)... |
445 |
|
throws IOException |
446 |
|
{ |
447 |
0 |
if (array == null) |
448 |
|
{ |
449 |
0 |
out.write("null"); |
450 |
|
} |
451 |
0 |
else if (array.length == 0) |
452 |
|
{ |
453 |
0 |
out.write("[]"); |
454 |
|
} |
455 |
|
else |
456 |
|
{ |
457 |
0 |
out.write("["); |
458 |
0 |
JSONValue.writeJSONString(array[0], out); |
459 |
|
|
460 |
0 |
for (int i = 1; i < array.length; i++) |
461 |
|
{ |
462 |
0 |
out.write(","); |
463 |
0 |
JSONValue.writeJSONString(array[i], out); |
464 |
|
} |
465 |
|
|
466 |
0 |
out.write("]"); |
467 |
|
} |
468 |
|
} |
469 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
470 |
0 |
public static String toJSONString(Object[] array)... |
471 |
|
{ |
472 |
0 |
final StringWriter writer = new StringWriter(); |
473 |
|
|
474 |
0 |
try |
475 |
|
{ |
476 |
0 |
writeJSONString(array, writer); |
477 |
0 |
return writer.toString(); |
478 |
|
} catch (IOException e) |
479 |
|
{ |
480 |
|
|
481 |
0 |
throw new RuntimeException(e); |
482 |
|
} |
483 |
|
} |
484 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
485 |
8246 |
public String toJSONString()... |
486 |
|
{ |
487 |
8246 |
return toJSONString(this); |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
@link |
493 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
494 |
8246 |
public String toString()... |
495 |
|
{ |
496 |
8246 |
return toJSONString(); |
497 |
|
} |
498 |
|
} |