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 |
|
|
|
|
| 0.8% |
Uncovered Elements: 246 (248) |
Complexity: 66 |
Complexity Density: 0.41 |
|
19 |
|
public class JSONArray extends ArrayList implements JSONAware, JSONStreamAware { |
20 |
|
private static final long serialVersionUID = 3957988303675231981L; |
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
25 |
88 |
public JSONArray(){... |
26 |
88 |
super(); |
27 |
|
} |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@param |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
35 |
0 |
public JSONArray(Collection c){... |
36 |
0 |
super(c); |
37 |
|
} |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@see |
44 |
|
|
45 |
|
@param |
46 |
|
@param |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 5 |
Complexity Density: 0.31 |
|
48 |
0 |
public static void writeJSONString(Collection collection, Writer out) throws IOException{... |
49 |
0 |
if(collection == null){ |
50 |
0 |
out.write("null"); |
51 |
0 |
return; |
52 |
|
} |
53 |
|
|
54 |
0 |
boolean first = true; |
55 |
0 |
Iterator iter=collection.iterator(); |
56 |
|
|
57 |
0 |
out.write('['); |
58 |
0 |
while(iter.hasNext()){ |
59 |
0 |
if(first) |
60 |
0 |
first = false; |
61 |
|
else |
62 |
0 |
out.write(','); |
63 |
|
|
64 |
0 |
Object value=iter.next(); |
65 |
0 |
if(value == null){ |
66 |
0 |
out.write("null"); |
67 |
0 |
continue; |
68 |
|
} |
69 |
|
|
70 |
0 |
JSONValue.writeJSONString(value, out); |
71 |
|
} |
72 |
0 |
out.write(']'); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0 |
public void writeJSONString(Writer out) throws IOException{... |
76 |
0 |
writeJSONString(this, out); |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@see |
84 |
|
|
85 |
|
@param |
86 |
|
@return |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
88 |
0 |
public static String toJSONString(Collection collection){... |
89 |
0 |
final StringWriter writer = new StringWriter(); |
90 |
|
|
91 |
0 |
try { |
92 |
0 |
writeJSONString(collection, writer); |
93 |
0 |
return writer.toString(); |
94 |
|
} catch(IOException e){ |
95 |
|
|
96 |
0 |
throw new RuntimeException(e); |
97 |
|
} |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
100 |
0 |
public static void writeJSONString(byte[] array, Writer out) throws IOException{... |
101 |
0 |
if(array == null){ |
102 |
0 |
out.write("null"); |
103 |
0 |
} else if(array.length == 0) { |
104 |
0 |
out.write("[]"); |
105 |
|
} else { |
106 |
0 |
out.write("["); |
107 |
0 |
out.write(String.valueOf(array[0])); |
108 |
|
|
109 |
0 |
for(int i = 1; i < array.length; i++){ |
110 |
0 |
out.write(","); |
111 |
0 |
out.write(String.valueOf(array[i])); |
112 |
|
} |
113 |
|
|
114 |
0 |
out.write("]"); |
115 |
|
} |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
118 |
0 |
public static String toJSONString(byte[] array){... |
119 |
0 |
final StringWriter writer = new StringWriter(); |
120 |
|
|
121 |
0 |
try { |
122 |
0 |
writeJSONString(array, writer); |
123 |
0 |
return writer.toString(); |
124 |
|
} catch(IOException e){ |
125 |
|
|
126 |
0 |
throw new RuntimeException(e); |
127 |
|
} |
128 |
|
} |
129 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
130 |
0 |
public static void writeJSONString(short[] array, Writer out) throws IOException{... |
131 |
0 |
if(array == null){ |
132 |
0 |
out.write("null"); |
133 |
0 |
} else if(array.length == 0) { |
134 |
0 |
out.write("[]"); |
135 |
|
} else { |
136 |
0 |
out.write("["); |
137 |
0 |
out.write(String.valueOf(array[0])); |
138 |
|
|
139 |
0 |
for(int i = 1; i < array.length; i++){ |
140 |
0 |
out.write(","); |
141 |
0 |
out.write(String.valueOf(array[i])); |
142 |
|
} |
143 |
|
|
144 |
0 |
out.write("]"); |
145 |
|
} |
146 |
|
} |
147 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
148 |
0 |
public static String toJSONString(short[] array){... |
149 |
0 |
final StringWriter writer = new StringWriter(); |
150 |
|
|
151 |
0 |
try { |
152 |
0 |
writeJSONString(array, writer); |
153 |
0 |
return writer.toString(); |
154 |
|
} catch(IOException e){ |
155 |
|
|
156 |
0 |
throw new RuntimeException(e); |
157 |
|
} |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
160 |
0 |
public static void writeJSONString(int[] array, Writer out) throws IOException{... |
161 |
0 |
if(array == null){ |
162 |
0 |
out.write("null"); |
163 |
0 |
} else if(array.length == 0) { |
164 |
0 |
out.write("[]"); |
165 |
|
} else { |
166 |
0 |
out.write("["); |
167 |
0 |
out.write(String.valueOf(array[0])); |
168 |
|
|
169 |
0 |
for(int i = 1; i < array.length; i++){ |
170 |
0 |
out.write(","); |
171 |
0 |
out.write(String.valueOf(array[i])); |
172 |
|
} |
173 |
|
|
174 |
0 |
out.write("]"); |
175 |
|
} |
176 |
|
} |
177 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
178 |
0 |
public static String toJSONString(int[] array){... |
179 |
0 |
final StringWriter writer = new StringWriter(); |
180 |
|
|
181 |
0 |
try { |
182 |
0 |
writeJSONString(array, writer); |
183 |
0 |
return writer.toString(); |
184 |
|
} catch(IOException e){ |
185 |
|
|
186 |
0 |
throw new RuntimeException(e); |
187 |
|
} |
188 |
|
} |
189 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
190 |
0 |
public static void writeJSONString(long[] array, Writer out) throws IOException{... |
191 |
0 |
if(array == null){ |
192 |
0 |
out.write("null"); |
193 |
0 |
} else if(array.length == 0) { |
194 |
0 |
out.write("[]"); |
195 |
|
} else { |
196 |
0 |
out.write("["); |
197 |
0 |
out.write(String.valueOf(array[0])); |
198 |
|
|
199 |
0 |
for(int i = 1; i < array.length; i++){ |
200 |
0 |
out.write(","); |
201 |
0 |
out.write(String.valueOf(array[i])); |
202 |
|
} |
203 |
|
|
204 |
0 |
out.write("]"); |
205 |
|
} |
206 |
|
} |
207 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
208 |
0 |
public static String toJSONString(long[] array){... |
209 |
0 |
final StringWriter writer = new StringWriter(); |
210 |
|
|
211 |
0 |
try { |
212 |
0 |
writeJSONString(array, writer); |
213 |
0 |
return writer.toString(); |
214 |
|
} catch(IOException e){ |
215 |
|
|
216 |
0 |
throw new RuntimeException(e); |
217 |
|
} |
218 |
|
} |
219 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
220 |
0 |
public static void writeJSONString(float[] array, Writer out) throws IOException{... |
221 |
0 |
if(array == null){ |
222 |
0 |
out.write("null"); |
223 |
0 |
} else if(array.length == 0) { |
224 |
0 |
out.write("[]"); |
225 |
|
} else { |
226 |
0 |
out.write("["); |
227 |
0 |
out.write(String.valueOf(array[0])); |
228 |
|
|
229 |
0 |
for(int i = 1; i < array.length; i++){ |
230 |
0 |
out.write(","); |
231 |
0 |
out.write(String.valueOf(array[i])); |
232 |
|
} |
233 |
|
|
234 |
0 |
out.write("]"); |
235 |
|
} |
236 |
|
} |
237 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
238 |
0 |
public static String toJSONString(float[] array){... |
239 |
0 |
final StringWriter writer = new StringWriter(); |
240 |
|
|
241 |
0 |
try { |
242 |
0 |
writeJSONString(array, writer); |
243 |
0 |
return writer.toString(); |
244 |
|
} catch(IOException e){ |
245 |
|
|
246 |
0 |
throw new RuntimeException(e); |
247 |
|
} |
248 |
|
} |
249 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
250 |
0 |
public static void writeJSONString(double[] array, Writer out) throws IOException{... |
251 |
0 |
if(array == null){ |
252 |
0 |
out.write("null"); |
253 |
0 |
} else if(array.length == 0) { |
254 |
0 |
out.write("[]"); |
255 |
|
} else { |
256 |
0 |
out.write("["); |
257 |
0 |
out.write(String.valueOf(array[0])); |
258 |
|
|
259 |
0 |
for(int i = 1; i < array.length; i++){ |
260 |
0 |
out.write(","); |
261 |
0 |
out.write(String.valueOf(array[i])); |
262 |
|
} |
263 |
|
|
264 |
0 |
out.write("]"); |
265 |
|
} |
266 |
|
} |
267 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
268 |
0 |
public static String toJSONString(double[] array){... |
269 |
0 |
final StringWriter writer = new StringWriter(); |
270 |
|
|
271 |
0 |
try { |
272 |
0 |
writeJSONString(array, writer); |
273 |
0 |
return writer.toString(); |
274 |
|
} catch(IOException e){ |
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(boolean[] array, Writer out) throws IOException{... |
281 |
0 |
if(array == null){ |
282 |
0 |
out.write("null"); |
283 |
0 |
} else if(array.length == 0) { |
284 |
0 |
out.write("[]"); |
285 |
|
} else { |
286 |
0 |
out.write("["); |
287 |
0 |
out.write(String.valueOf(array[0])); |
288 |
|
|
289 |
0 |
for(int i = 1; i < array.length; i++){ |
290 |
0 |
out.write(","); |
291 |
0 |
out.write(String.valueOf(array[i])); |
292 |
|
} |
293 |
|
|
294 |
0 |
out.write("]"); |
295 |
|
} |
296 |
|
} |
297 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
298 |
0 |
public static String toJSONString(boolean[] array){... |
299 |
0 |
final StringWriter writer = new StringWriter(); |
300 |
|
|
301 |
0 |
try { |
302 |
0 |
writeJSONString(array, writer); |
303 |
0 |
return writer.toString(); |
304 |
|
} catch(IOException e){ |
305 |
|
|
306 |
0 |
throw new RuntimeException(e); |
307 |
|
} |
308 |
|
} |
309 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
310 |
0 |
public static void writeJSONString(char[] array, Writer out) throws IOException{... |
311 |
0 |
if(array == null){ |
312 |
0 |
out.write("null"); |
313 |
0 |
} else if(array.length == 0) { |
314 |
0 |
out.write("[]"); |
315 |
|
} else { |
316 |
0 |
out.write("[\""); |
317 |
0 |
out.write(String.valueOf(array[0])); |
318 |
|
|
319 |
0 |
for(int i = 1; i < array.length; i++){ |
320 |
0 |
out.write("\",\""); |
321 |
0 |
out.write(String.valueOf(array[i])); |
322 |
|
} |
323 |
|
|
324 |
0 |
out.write("\"]"); |
325 |
|
} |
326 |
|
} |
327 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
328 |
0 |
public static String toJSONString(char[] array){... |
329 |
0 |
final StringWriter writer = new StringWriter(); |
330 |
|
|
331 |
0 |
try { |
332 |
0 |
writeJSONString(array, writer); |
333 |
0 |
return writer.toString(); |
334 |
|
} catch(IOException e){ |
335 |
|
|
336 |
0 |
throw new RuntimeException(e); |
337 |
|
} |
338 |
|
} |
339 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
340 |
0 |
public static void writeJSONString(Object[] array, Writer out) throws IOException{... |
341 |
0 |
if(array == null){ |
342 |
0 |
out.write("null"); |
343 |
0 |
} else if(array.length == 0) { |
344 |
0 |
out.write("[]"); |
345 |
|
} else { |
346 |
0 |
out.write("["); |
347 |
0 |
JSONValue.writeJSONString(array[0], out); |
348 |
|
|
349 |
0 |
for(int i = 1; i < array.length; i++){ |
350 |
0 |
out.write(","); |
351 |
0 |
JSONValue.writeJSONString(array[i], out); |
352 |
|
} |
353 |
|
|
354 |
0 |
out.write("]"); |
355 |
|
} |
356 |
|
} |
357 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
358 |
0 |
public static String toJSONString(Object[] array){... |
359 |
0 |
final StringWriter writer = new StringWriter(); |
360 |
|
|
361 |
0 |
try { |
362 |
0 |
writeJSONString(array, writer); |
363 |
0 |
return writer.toString(); |
364 |
|
} catch(IOException e){ |
365 |
|
|
366 |
0 |
throw new RuntimeException(e); |
367 |
|
} |
368 |
|
} |
369 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
370 |
0 |
public String toJSONString(){... |
371 |
0 |
return toJSONString(this); |
372 |
|
} |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
@link |
377 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
378 |
0 |
public String toString() {... |
379 |
0 |
return toJSONString(); |
380 |
|
} |
381 |
|
} |