1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.xdomxml10.internal.parser.parameter; |
21 |
|
|
22 |
|
import java.util.LinkedHashMap; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import org.xml.sax.Attributes; |
26 |
|
import org.xml.sax.SAXException; |
27 |
|
import org.xml.sax.helpers.DefaultHandler; |
28 |
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 7 |
Complexity Density: 0.58 |
|
29 |
|
public class CustomParametersParser extends DefaultHandler implements ValueParser<Map<String, String>> |
30 |
|
{ |
31 |
|
private Map<String, String> parameters = new LinkedHashMap<String, String>(); |
32 |
|
|
33 |
|
private StringBuffer value = new StringBuffer(); |
34 |
|
|
35 |
|
private int level = 0; |
36 |
|
|
37 |
|
private String currentEntry; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
2 |
@Override... |
40 |
|
public Map<String, String> getValue() |
41 |
|
{ |
42 |
2 |
return this.parameters; |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
2 |
@Override... |
48 |
|
public void characters(char[] ch, int start, int length) throws SAXException |
49 |
|
{ |
50 |
2 |
this.value.append(ch, start, length); |
51 |
|
} |
52 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
53 |
4 |
@Override... |
54 |
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException |
55 |
|
{ |
56 |
4 |
if (this.level > 0) { |
57 |
2 |
this.currentEntry = qName; |
58 |
2 |
String name = attributes.getValue("name"); |
59 |
2 |
if (name != null) { |
60 |
0 |
this.currentEntry = name; |
61 |
|
} |
62 |
|
} |
63 |
|
|
64 |
4 |
++this.level; |
65 |
|
} |
66 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
67 |
2 |
@Override... |
68 |
|
public void endElement(String uri, String localName, String qName) throws SAXException |
69 |
|
{ |
70 |
2 |
--this.level; |
71 |
|
|
72 |
2 |
if (this.level > 0) { |
73 |
2 |
this.parameters.put(this.currentEntry, this.value.toString()); |
74 |
2 |
this.value.setLength(0); |
75 |
|
} |
76 |
|
} |
77 |
|
} |