1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.xml; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.LinkedHashMap; |
24 |
|
import java.util.List; |
25 |
|
import java.util.Map; |
26 |
|
|
27 |
|
import org.xwiki.rendering.wikimodel.WikiFormat; |
28 |
|
import org.xwiki.rendering.wikimodel.WikiParameter; |
29 |
|
import org.xwiki.rendering.wikimodel.WikiParameters; |
30 |
|
import org.xwiki.rendering.wikimodel.WikiReference; |
31 |
|
import org.xwiki.rendering.wikimodel.WikiStyle; |
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 69.1% |
Uncovered Elements: 25 (81) |
Complexity: 23 |
Complexity Density: 0.48 |
|
37 |
|
public class AbstractTagNotifier implements ISaxConst |
38 |
|
{ |
39 |
|
protected static final Map<String, String> EMPTY_MAP = Collections |
40 |
|
.emptyMap(); |
41 |
|
|
42 |
|
protected ITagListener fListener; |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
42
|
public AbstractTagNotifier(ITagListener listener)... |
45 |
|
{ |
46 |
42
|
fListener = listener; |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
@param |
52 |
|
@return |
53 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
54 |
42
|
private Map<String, String> addParams(... |
55 |
|
Map<String, String> map, |
56 |
|
String... params) |
57 |
|
{ |
58 |
156
|
for (int i = 0; i < params.length; i++) { |
59 |
114
|
String key = params[i]; |
60 |
114
|
i++; |
61 |
114
|
String value = i < params.length ? params[i] : null; |
62 |
114
|
map.put(key, value); |
63 |
|
} |
64 |
42
|
return map; |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
@return |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
71 |
28
|
private Map<String, String> getParamsMap(Iterable<WikiParameter> params)... |
72 |
|
{ |
73 |
28
|
Map<String, String> map = newParamMap(); |
74 |
28
|
for (WikiParameter param : params) { |
75 |
12
|
String key = param.getKey(); |
76 |
12
|
String value = param.getValue(); |
77 |
12
|
map.put(key, value); |
78 |
|
} |
79 |
28
|
return map; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
@return |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
72
|
protected Map<String, String> newParamMap()... |
86 |
|
{ |
87 |
72
|
return new LinkedHashMap<String, String>(); |
88 |
|
} |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
90 |
0
|
protected Map<String, String> tagParams(... |
91 |
|
Map<String, String> tagParams, |
92 |
|
String... params) |
93 |
|
{ |
94 |
0
|
if (tagParams == EMPTY_MAP) { |
95 |
0
|
return tagParams(params); |
96 |
|
} |
97 |
0
|
return addParams(tagParams, params); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
100 |
54
|
protected Map<String, String> tagParams(String... params)... |
101 |
|
{ |
102 |
54
|
if (params.length == 0) { |
103 |
12
|
return EMPTY_MAP; |
104 |
|
} |
105 |
42
|
Map<String, String> map = newParamMap(); |
106 |
42
|
return addParams(map, params); |
107 |
|
} |
108 |
|
|
|
|
| 80% |
Uncovered Elements: 4 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
109 |
22
|
protected Map<String, String> tagParams(WikiFormat format)... |
110 |
|
{ |
111 |
22
|
if (format == null) { |
112 |
0
|
return EMPTY_MAP; |
113 |
|
} |
114 |
22
|
List<WikiStyle> styles = format.getStyles(); |
115 |
22
|
if (styles.isEmpty()) { |
116 |
20
|
return EMPTY_MAP; |
117 |
|
} |
118 |
2
|
Map<String, String> map = newParamMap(); |
119 |
2
|
StringBuffer buf = new StringBuffer(); |
120 |
2
|
for (WikiStyle style : styles) { |
121 |
2
|
String name = style.toString(); |
122 |
2
|
if (buf.length() > 0) { |
123 |
0
|
buf.append("; "); |
124 |
|
} |
125 |
2
|
buf.append(name); |
126 |
|
} |
127 |
2
|
map.put(STYLES, buf.toString()); |
128 |
2
|
return map; |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
131 |
0
|
protected Map<String, String> tagParams(WikiReference ref)... |
132 |
|
{ |
133 |
0
|
if (ref == null) { |
134 |
0
|
return EMPTY_MAP; |
135 |
|
} |
136 |
0
|
return tagParams("label", ref.getLabel(), "href", ref.getLink()); |
137 |
|
} |
138 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
139 |
22
|
protected Map<String, String> userParams(WikiFormat format)... |
140 |
|
{ |
141 |
22
|
if (format == null) { |
142 |
0
|
return EMPTY_MAP; |
143 |
|
} |
144 |
22
|
List<WikiParameter> params = format.getParams(); |
145 |
22
|
return getParamsMap(params); |
146 |
|
} |
147 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
148 |
64
|
protected Map<String, String> userParams(WikiParameters params)... |
149 |
|
{ |
150 |
64
|
if (params == null || params.getSize() == 0) { |
151 |
58
|
return EMPTY_MAP; |
152 |
|
} |
153 |
6
|
return getParamsMap(params); |
154 |
|
} |
155 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
156 |
0
|
protected Map<String, String> userParams(WikiReference ref)... |
157 |
|
{ |
158 |
0
|
if (ref == null) { |
159 |
0
|
return EMPTY_MAP; |
160 |
|
} |
161 |
0
|
return userParams(ref.getParameters()); |
162 |
|
} |
163 |
|
} |