1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.api; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.Comparator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
|
29 |
|
import com.xpn.xwiki.XWikiContext; |
30 |
|
import com.xpn.xwiki.XWikiException; |
31 |
|
import com.xpn.xwiki.objects.BaseObject; |
32 |
|
import com.xpn.xwiki.objects.BaseProperty; |
33 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
34 |
|
|
|
|
| 43.9% |
Uncovered Elements: 60 (107) |
Complexity: 25 |
Complexity Density: 0.34 |
|
35 |
|
public class Class extends Collection |
36 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
11926 |
public Class(BaseClass obj, XWikiContext context)... |
38 |
|
{ |
39 |
11926 |
super(obj, context); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
499 |
protected BaseClass getBaseClass()... |
43 |
|
{ |
44 |
499 |
return (BaseClass) getCollection(); |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
286 |
@Override... |
48 |
|
public DocumentReference getReference() |
49 |
|
{ |
50 |
286 |
return getBaseClass().getReference(); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@see |
57 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
58 |
314 |
@Override... |
59 |
|
public java.lang.Object[] getPropertyNames() |
60 |
|
{ |
61 |
314 |
Element[] properties = getProperties(); |
62 |
314 |
if (properties == null) { |
63 |
0 |
return super.getPropertyNames(); |
64 |
|
} |
65 |
314 |
String[] props = new String[properties.length]; |
66 |
4796 |
for (int i = 0; i < properties.length; i++) { |
67 |
4482 |
String propname = properties[i].getName(); |
68 |
4482 |
props[i] = propname; |
69 |
|
} |
70 |
314 |
return props; |
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
@return |
77 |
|
@see |
78 |
|
@see |
79 |
|
@since |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
81 |
0 |
public List<String> getEnabledPropertyNames()... |
82 |
|
{ |
83 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> properties = this.getBaseClass().getEnabledProperties(); |
84 |
0 |
List<String> result = new ArrayList<String>(properties.size()); |
85 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : properties) { |
86 |
0 |
if (property != null) { |
87 |
0 |
result.add(property.getName()); |
88 |
|
} |
89 |
|
} |
90 |
0 |
return result; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@return |
97 |
|
@see |
98 |
|
@see |
99 |
|
@since |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
101 |
0 |
public List<String> getDisabledPropertyNames()... |
102 |
|
{ |
103 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> properties = this.getBaseClass().getDisabledProperties(); |
104 |
0 |
List<String> result = new ArrayList<String>(properties.size()); |
105 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : properties) { |
106 |
0 |
if (property != null) { |
107 |
0 |
result.add(property.getName()); |
108 |
|
} |
109 |
|
} |
110 |
0 |
return result; |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@param |
119 |
|
@return |
120 |
|
@see |
121 |
|
@see |
122 |
|
@since |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
124 |
0 |
public List<String> getDisabledObjectPropertyNames(Object object)... |
125 |
|
{ |
126 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> properties = |
127 |
|
this.getBaseClass().getDisabledObjectProperties(object.getBaseObject()); |
128 |
0 |
List<String> result = new ArrayList<String>(properties.size()); |
129 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : properties) { |
130 |
0 |
if (property != null) { |
131 |
0 |
result.add(property.getName()); |
132 |
|
} |
133 |
|
} |
134 |
0 |
return result; |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
@param |
143 |
|
@return |
144 |
|
@see |
145 |
|
@since |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
147 |
0 |
public List<String> getDeprecatedObjectPropertyNames(Object object)... |
148 |
|
{ |
149 |
0 |
List<BaseProperty> properties = this.getBaseClass().getDeprecatedObjectProperties(object.getBaseObject()); |
150 |
0 |
List<String> result = new ArrayList<String>(properties.size()); |
151 |
0 |
for (BaseProperty property : properties) { |
152 |
0 |
if (property != null) { |
153 |
0 |
result.add(property.getName()); |
154 |
|
} |
155 |
|
} |
156 |
0 |
return result; |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
@return |
161 |
|
|
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
162 |
732 |
@Override... |
163 |
|
public Element[] getProperties() |
164 |
|
{ |
165 |
732 |
@SuppressWarnings("unchecked") |
166 |
|
java.util.Collection<com.xpn.xwiki.objects.classes.PropertyClass> coll = getCollection().getFieldList(); |
167 |
732 |
if (coll == null) { |
168 |
0 |
return null; |
169 |
|
} |
170 |
732 |
PropertyClass[] properties = new PropertyClass[coll.size()]; |
171 |
732 |
int i = 0; |
172 |
732 |
for (com.xpn.xwiki.objects.classes.PropertyClass prop : coll) { |
173 |
13816 |
properties[i++] = new PropertyClass(prop, getXWikiContext()); |
174 |
|
} |
175 |
732 |
Arrays.sort(properties, new PropertyComparator()); |
176 |
732 |
return properties; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
@return |
183 |
|
@see |
184 |
|
@see |
185 |
|
@since |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
187 |
0 |
public List<PropertyClass> getEnabledProperties()... |
188 |
|
{ |
189 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> enabledProperties = |
190 |
|
getBaseClass().getEnabledProperties(); |
191 |
|
|
192 |
0 |
List<PropertyClass> result = new ArrayList<PropertyClass>(enabledProperties.size()); |
193 |
|
|
194 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : enabledProperties) { |
195 |
0 |
result.add(new PropertyClass(property, getXWikiContext())); |
196 |
|
} |
197 |
|
|
198 |
0 |
return result; |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
@return |
205 |
|
@see |
206 |
|
@see |
207 |
|
@since |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
209 |
0 |
public List<PropertyClass> getDisabledProperties()... |
210 |
|
{ |
211 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> disabledProperties = |
212 |
|
getBaseClass().getDisabledProperties(); |
213 |
|
|
214 |
0 |
List<PropertyClass> result = new ArrayList<PropertyClass>(disabledProperties.size()); |
215 |
|
|
216 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : disabledProperties) { |
217 |
0 |
result.add(new PropertyClass(property, getXWikiContext())); |
218 |
|
} |
219 |
|
|
220 |
0 |
return result; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@param |
229 |
|
@return |
230 |
|
@see |
231 |
|
@see |
232 |
|
@since |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
234 |
0 |
public List<PropertyClass> getDisabledObjectProperties(Object object)... |
235 |
|
{ |
236 |
0 |
List<com.xpn.xwiki.objects.classes.PropertyClass> disabledObjectProperties = |
237 |
|
getBaseClass().getDisabledObjectProperties(object.getBaseObject()); |
238 |
|
|
239 |
0 |
List<PropertyClass> result = new ArrayList<PropertyClass>(disabledObjectProperties.size()); |
240 |
0 |
for (com.xpn.xwiki.objects.classes.PropertyClass property : disabledObjectProperties) { |
241 |
0 |
result.add(new PropertyClass(property, getXWikiContext())); |
242 |
|
} |
243 |
|
|
244 |
0 |
return result; |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
@param |
253 |
|
@return |
254 |
|
@see |
255 |
|
@since |
256 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
257 |
91 |
public List<Property> getDeprecatedObjectProperties(Object object)... |
258 |
|
{ |
259 |
91 |
List<BaseProperty> deprecatedObjectProperties = |
260 |
|
getBaseClass().getDeprecatedObjectProperties(object.getBaseObject()); |
261 |
|
|
262 |
91 |
List<Property> result = new ArrayList<Property>(deprecatedObjectProperties.size()); |
263 |
91 |
for (BaseProperty property : deprecatedObjectProperties) { |
264 |
12 |
result.add(new Property(property, getXWikiContext())); |
265 |
|
} |
266 |
|
|
267 |
91 |
return result; |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
@param |
272 |
|
@return |
273 |
|
@see |
274 |
|
@see |
275 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
276 |
3888 |
public Element get(String name)... |
277 |
|
{ |
278 |
3888 |
com.xpn.xwiki.objects.classes.PropertyClass property = |
279 |
|
(com.xpn.xwiki.objects.classes.PropertyClass) getCollection().safeget(name); |
280 |
3888 |
if (property != null) { |
281 |
3876 |
return new PropertyClass(property, getXWikiContext()); |
282 |
|
} |
283 |
12 |
return null; |
284 |
|
} |
285 |
|
|
286 |
|
|
287 |
|
@return |
288 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
289 |
4 |
public BaseClass getXWikiClass()... |
290 |
|
{ |
291 |
4 |
if (hasProgrammingRights()) { |
292 |
4 |
return (BaseClass) getCollection(); |
293 |
|
} else { |
294 |
0 |
return null; |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
|
|
299 |
|
@return |
300 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
301 |
122 |
public Object newObject() throws XWikiException... |
302 |
|
{ |
303 |
122 |
BaseObject obj = (BaseObject) getBaseClass().newObject(getXWikiContext()); |
304 |
122 |
return obj.newObjectApi(obj, getXWikiContext()); |
305 |
|
} |
306 |
|
} |
307 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
308 |
|
class PropertyComparator implements Comparator<PropertyClass> |
309 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
310 |
49385 |
@Override... |
311 |
|
public int compare(PropertyClass o1, PropertyClass o2) |
312 |
|
{ |
313 |
49385 |
return o1.getNumber() - o2.getNumber(); |
314 |
|
} |
315 |
|
} |