1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.objects.meta; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.apache.commons.lang3.StringUtils; |
25 |
|
import org.slf4j.Logger; |
26 |
|
import org.slf4j.LoggerFactory; |
27 |
|
import org.xwiki.component.manager.ComponentLookupException; |
28 |
|
|
29 |
|
import com.xpn.xwiki.XWikiContext; |
30 |
|
import com.xpn.xwiki.internal.objects.classes.PropertyClassProvider; |
31 |
|
import com.xpn.xwiki.objects.BaseCollection; |
32 |
|
import com.xpn.xwiki.objects.PropertyInterface; |
33 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
34 |
|
import com.xpn.xwiki.objects.classes.PropertyClass; |
35 |
|
import com.xpn.xwiki.web.Utils; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@link |
41 |
|
|
42 |
|
@version |
43 |
|
|
|
|
| 71.4% |
Uncovered Elements: 10 (35) |
Complexity: 12 |
Complexity Density: 0.57 |
|
44 |
|
public class MetaClass extends BaseClass |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
private static final String PROPERTY_NAME_PREFIX = "meta"; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(MetaClass.class); |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
private static MetaClass metaClass; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
64 |
3 |
public MetaClass()... |
65 |
|
{ |
66 |
3 |
try { |
67 |
3 |
List<PropertyClassProvider> providers = |
68 |
|
Utils.getContextComponentManager().getInstanceList(PropertyClassProvider.class); |
69 |
3 |
for (PropertyClassProvider provider : providers) { |
70 |
48 |
PropertyInterface property = provider.getDefinition(); |
71 |
48 |
safeput(property.getName(), property); |
72 |
|
} |
73 |
|
} catch (ComponentLookupException e) { |
74 |
0 |
LOGGER.error("Failed to initialize the meta class.", e); |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
78 |
48 |
@Override... |
79 |
|
public void safeput(String name, PropertyInterface property) |
80 |
|
{ |
81 |
48 |
addField(PROPERTY_NAME_PREFIX + name, property); |
82 |
48 |
if (property instanceof PropertyClass) { |
83 |
0 |
((PropertyClass) property).setObject(this); |
84 |
0 |
((PropertyClass) property).setName(name); |
85 |
|
} |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
606 |
@Override... |
89 |
|
public PropertyInterface safeget(String name) |
90 |
|
{ |
91 |
606 |
return super.safeget(PROPERTY_NAME_PREFIX + name); |
92 |
|
} |
93 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
94 |
606 |
@Override... |
95 |
|
public PropertyInterface get(String name) |
96 |
|
{ |
97 |
606 |
PropertyInterface property = safeget(name); |
98 |
606 |
if (property == null) { |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
0 |
property = safeget(StringUtils.removeEnd(StringUtils.substringAfterLast(name, "."), "Class")); |
103 |
|
} |
104 |
606 |
return property; |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0 |
@Override... |
108 |
|
public void put(String name, PropertyInterface property) |
109 |
|
{ |
110 |
0 |
safeput(name, property); |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
@return |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
116 |
424 |
public static MetaClass getMetaClass()... |
117 |
|
{ |
118 |
424 |
if (metaClass == null) { |
119 |
3 |
metaClass = new MetaClass(); |
120 |
|
} |
121 |
424 |
return metaClass; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
@param |
128 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
49 |
public static void setMetaClass(MetaClass metaClass)... |
130 |
|
{ |
131 |
49 |
MetaClass.metaClass = metaClass; |
132 |
|
} |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0 |
@Override... |
135 |
|
public BaseCollection newObject(XWikiContext context) |
136 |
|
{ |
137 |
0 |
return new BaseClass(); |
138 |
|
} |
139 |
|
} |