1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
package org.xml.sax.helpers; |
8 |
|
|
9 |
|
import org.xml.sax.Attributes; |
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
@link |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@since |
43 |
|
@author |
44 |
|
@version |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 213 (213) |
Complexity: 76 |
Complexity Density: 0.64 |
|
46 |
|
public class AttributesImpl implements Attributes |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
58 |
0 |
public AttributesImpl ()... |
59 |
|
{ |
60 |
0 |
length = 0; |
61 |
0 |
data = null; |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
@link |
70 |
|
|
71 |
|
@param |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0 |
public AttributesImpl (Attributes atts)... |
74 |
|
{ |
75 |
0 |
setAttributes(atts); |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@return |
89 |
|
@see |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
@Override... |
92 |
|
public int getLength () |
93 |
|
{ |
94 |
0 |
return length; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@param |
102 |
|
@return |
103 |
|
|
104 |
|
@see |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
106 |
0 |
@Override... |
107 |
|
public String getURI (int index) |
108 |
|
{ |
109 |
0 |
if (index >= 0 && index < length) { |
110 |
0 |
return data[index*5]; |
111 |
|
} else { |
112 |
0 |
return null; |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
@param |
121 |
|
@return |
122 |
|
|
123 |
|
@see |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
125 |
0 |
@Override... |
126 |
|
public String getLocalName (int index) |
127 |
|
{ |
128 |
0 |
if (index >= 0 && index < length) { |
129 |
0 |
return data[index*5+1]; |
130 |
|
} else { |
131 |
0 |
return null; |
132 |
|
} |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
@return |
141 |
|
|
142 |
|
@see |
143 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
144 |
0 |
@Override... |
145 |
|
public String getQName (int index) |
146 |
|
{ |
147 |
0 |
if (index >= 0 && index < length) { |
148 |
0 |
return data[index*5+2]; |
149 |
|
} else { |
150 |
0 |
return null; |
151 |
|
} |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@param |
159 |
|
@return |
160 |
|
|
161 |
|
@see |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
163 |
0 |
@Override... |
164 |
|
public String getType (int index) |
165 |
|
{ |
166 |
0 |
if (index >= 0 && index < length) { |
167 |
0 |
return data[index*5+3]; |
168 |
|
} else { |
169 |
0 |
return null; |
170 |
|
} |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
@param |
178 |
|
@return |
179 |
|
@see |
180 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
181 |
0 |
@Override... |
182 |
|
public String getValue (int index) |
183 |
|
{ |
184 |
0 |
if (index >= 0 && index < length) { |
185 |
0 |
return data[index*5+4]; |
186 |
|
} else { |
187 |
0 |
return null; |
188 |
|
} |
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
@param |
200 |
|
|
201 |
|
@param |
202 |
|
@return |
203 |
|
@see |
204 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
205 |
0 |
@Override... |
206 |
|
public int getIndex (String uri, String localName) |
207 |
|
{ |
208 |
0 |
int max = length * 5; |
209 |
0 |
for (int i = 0; i < max; i += 5) { |
210 |
0 |
if (data[i].equals(uri) && data[i+1].equals(localName)) { |
211 |
0 |
return i / 5; |
212 |
|
} |
213 |
|
} |
214 |
0 |
return -1; |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
@param |
222 |
|
@return |
223 |
|
@see |
224 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
225 |
0 |
@Override... |
226 |
|
public int getIndex (String qName) |
227 |
|
{ |
228 |
0 |
int max = length * 5; |
229 |
0 |
for (int i = 0; i < max; i += 5) { |
230 |
0 |
if (data[i+2].equals(qName)) { |
231 |
0 |
return i / 5; |
232 |
|
} |
233 |
|
} |
234 |
0 |
return -1; |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@param |
242 |
|
|
243 |
|
@param |
244 |
|
@return |
245 |
|
|
246 |
|
@see |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
248 |
0 |
@Override... |
249 |
|
public String getType (String uri, String localName) |
250 |
|
{ |
251 |
0 |
int max = length * 5; |
252 |
0 |
for (int i = 0; i < max; i += 5) { |
253 |
0 |
if (data[i].equals(uri) && data[i+1].equals(localName)) { |
254 |
0 |
return data[i+3]; |
255 |
|
} |
256 |
|
} |
257 |
0 |
return null; |
258 |
|
} |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
@param |
265 |
|
@return |
266 |
|
|
267 |
|
@see |
268 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
269 |
0 |
@Override... |
270 |
|
public String getType (String qName) |
271 |
|
{ |
272 |
0 |
int max = length * 5; |
273 |
0 |
for (int i = 0; i < max; i += 5) { |
274 |
0 |
if (data[i+2].equals(qName)) { |
275 |
0 |
return data[i+3]; |
276 |
|
} |
277 |
|
} |
278 |
0 |
return null; |
279 |
|
} |
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
@param |
286 |
|
|
287 |
|
@param |
288 |
|
@return |
289 |
|
|
290 |
|
@see |
291 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
292 |
0 |
@Override... |
293 |
|
public String getValue (String uri, String localName) |
294 |
|
{ |
295 |
0 |
int max = length * 5; |
296 |
0 |
for (int i = 0; i < max; i += 5) { |
297 |
0 |
if (data[i].equals(uri) && data[i+1].equals(localName)) { |
298 |
0 |
return data[i+4]; |
299 |
|
} |
300 |
|
} |
301 |
0 |
return null; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
@param |
309 |
|
@return |
310 |
|
|
311 |
|
@see |
312 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
313 |
0 |
@Override... |
314 |
|
public String getValue (String qName) |
315 |
|
{ |
316 |
0 |
int max = length * 5; |
317 |
0 |
for (int i = 0; i < max; i += 5) { |
318 |
0 |
if (data[i+2].equals(qName)) { |
319 |
0 |
return data[i+4]; |
320 |
|
} |
321 |
|
} |
322 |
0 |
return null; |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
339 |
0 |
public void clear ()... |
340 |
|
{ |
341 |
0 |
if (data != null) { |
342 |
0 |
for (int i = 0; i < (length * 5); i++) |
343 |
0 |
data [i] = null; |
344 |
|
} |
345 |
0 |
length = 0; |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
@param |
356 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
357 |
0 |
public void setAttributes (Attributes atts)... |
358 |
|
{ |
359 |
0 |
clear(); |
360 |
0 |
length = atts.getLength(); |
361 |
0 |
if (length > 0) { |
362 |
0 |
data = new String[length*5]; |
363 |
0 |
for (int i = 0; i < length; i++) { |
364 |
0 |
data[i*5] = atts.getURI(i); |
365 |
0 |
data[i*5+1] = atts.getLocalName(i); |
366 |
0 |
data[i*5+2] = atts.getQName(i); |
367 |
0 |
data[i*5+3] = atts.getType(i); |
368 |
0 |
data[i*5+4] = atts.getValue(i); |
369 |
|
} |
370 |
|
} |
371 |
|
} |
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
@param |
382 |
|
|
383 |
|
|
384 |
|
@param |
385 |
|
|
386 |
|
@param |
387 |
|
|
388 |
|
@param |
389 |
|
@param |
390 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
391 |
0 |
public void addAttribute (String uri, String localName, String qName,... |
392 |
|
String type, String value) |
393 |
|
{ |
394 |
0 |
ensureCapacity(length+1); |
395 |
0 |
data[length*5] = uri; |
396 |
0 |
data[length*5+1] = localName; |
397 |
0 |
data[length*5+2] = qName; |
398 |
0 |
data[length*5+3] = type; |
399 |
0 |
data[length*5+4] = value; |
400 |
0 |
length++; |
401 |
|
} |
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
@param |
412 |
|
@param |
413 |
|
|
414 |
|
|
415 |
|
@param |
416 |
|
|
417 |
|
@param |
418 |
|
|
419 |
|
@param |
420 |
|
@param |
421 |
|
@exception |
422 |
|
|
423 |
|
|
424 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
425 |
0 |
public void setAttribute (int index, String uri, String localName,... |
426 |
|
String qName, String type, String value) |
427 |
|
{ |
428 |
0 |
if (index >= 0 && index < length) { |
429 |
0 |
data[index*5] = uri; |
430 |
0 |
data[index*5+1] = localName; |
431 |
0 |
data[index*5+2] = qName; |
432 |
0 |
data[index*5+3] = type; |
433 |
0 |
data[index*5+4] = value; |
434 |
|
} else { |
435 |
0 |
badIndex(index); |
436 |
|
} |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
@param |
444 |
|
@exception |
445 |
|
|
446 |
|
|
447 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
448 |
0 |
public void removeAttribute (int index)... |
449 |
|
{ |
450 |
0 |
if (index >= 0 && index < length) { |
451 |
0 |
if (index < length - 1) { |
452 |
0 |
System.arraycopy(data, (index+1)*5, data, index*5, |
453 |
|
(length-index-1)*5); |
454 |
|
} |
455 |
0 |
index = (length - 1) * 5; |
456 |
0 |
data [index++] = null; |
457 |
0 |
data [index++] = null; |
458 |
0 |
data [index++] = null; |
459 |
0 |
data [index++] = null; |
460 |
0 |
data [index] = null; |
461 |
0 |
length--; |
462 |
|
} else { |
463 |
0 |
badIndex(index); |
464 |
|
} |
465 |
|
} |
466 |
|
|
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
@param |
472 |
|
@param |
473 |
|
|
474 |
|
@exception |
475 |
|
|
476 |
|
|
477 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
478 |
0 |
public void setURI (int index, String uri)... |
479 |
|
{ |
480 |
0 |
if (index >= 0 && index < length) { |
481 |
0 |
data[index*5] = uri; |
482 |
|
} else { |
483 |
0 |
badIndex(index); |
484 |
|
} |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
@param |
492 |
|
@param |
493 |
|
|
494 |
|
@exception |
495 |
|
|
496 |
|
|
497 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
498 |
0 |
public void setLocalName (int index, String localName)... |
499 |
|
{ |
500 |
0 |
if (index >= 0 && index < length) { |
501 |
0 |
data[index*5+1] = localName; |
502 |
|
} else { |
503 |
0 |
badIndex(index); |
504 |
|
} |
505 |
|
} |
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
@param |
512 |
|
@param |
513 |
|
|
514 |
|
@exception |
515 |
|
|
516 |
|
|
517 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
518 |
0 |
public void setQName (int index, String qName)... |
519 |
|
{ |
520 |
0 |
if (index >= 0 && index < length) { |
521 |
0 |
data[index*5+2] = qName; |
522 |
|
} else { |
523 |
0 |
badIndex(index); |
524 |
|
} |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
@param |
532 |
|
@param |
533 |
|
@exception |
534 |
|
|
535 |
|
|
536 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
537 |
0 |
public void setType (int index, String type)... |
538 |
|
{ |
539 |
0 |
if (index >= 0 && index < length) { |
540 |
0 |
data[index*5+3] = type; |
541 |
|
} else { |
542 |
0 |
badIndex(index); |
543 |
|
} |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
@param |
551 |
|
@param |
552 |
|
@exception |
553 |
|
|
554 |
|
|
555 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
556 |
0 |
public void setValue (int index, String value)... |
557 |
|
{ |
558 |
0 |
if (index >= 0 && index < length) { |
559 |
0 |
data[index*5+4] = value; |
560 |
|
} else { |
561 |
0 |
badIndex(index); |
562 |
|
} |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
@param |
576 |
|
|
577 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0.5 |
|
578 |
0 |
private void ensureCapacity (int n) {... |
579 |
0 |
if (n <= 0) { |
580 |
0 |
return; |
581 |
|
} |
582 |
0 |
int max; |
583 |
0 |
if (data == null || data.length == 0) { |
584 |
0 |
max = 25; |
585 |
|
} |
586 |
0 |
else if (data.length >= n * 5) { |
587 |
0 |
return; |
588 |
|
} |
589 |
|
else { |
590 |
0 |
max = data.length; |
591 |
|
} |
592 |
0 |
while (max < n * 5) { |
593 |
0 |
max *= 2; |
594 |
|
} |
595 |
|
|
596 |
0 |
String newData[] = new String[max]; |
597 |
0 |
if (length > 0) { |
598 |
0 |
System.arraycopy(data, 0, newData, 0, length*5); |
599 |
|
} |
600 |
0 |
data = newData; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
@param |
608 |
|
@exception |
609 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
610 |
0 |
private void badIndex (int index)... |
611 |
|
throws ArrayIndexOutOfBoundsException |
612 |
|
{ |
613 |
0 |
String msg = |
614 |
|
"Attempt to modify attribute at illegal index: " + index; |
615 |
0 |
throw new ArrayIndexOutOfBoundsException(msg); |
616 |
|
} |
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
int length; |
625 |
|
String data []; |
626 |
|
|
627 |
|
} |
628 |
|
|
629 |
|
|
630 |
|
|