1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.contract.model.impl; |
17 |
|
|
18 |
|
import com.thoughtworks.qdox.JavaDocBuilder; |
19 |
|
import com.thoughtworks.qdox.model.Annotation; |
20 |
|
import com.thoughtworks.qdox.model.DefaultDocletTagFactory; |
21 |
|
import com.thoughtworks.qdox.model.DocletTag; |
22 |
|
import com.thoughtworks.qdox.model.JavaClass; |
23 |
|
import com.thoughtworks.qdox.model.JavaField; |
24 |
|
import com.thoughtworks.qdox.model.JavaMethod; |
25 |
|
import com.thoughtworks.qdox.model.JavaParameter; |
26 |
|
import com.thoughtworks.qdox.model.Type; |
27 |
|
import com.thoughtworks.qdox.model.annotation.AnnotationValue; |
28 |
|
import java.io.File; |
29 |
|
import java.util.ArrayList; |
30 |
|
import java.util.Arrays; |
31 |
|
import java.util.Collection; |
32 |
|
import java.util.Collections; |
33 |
|
import java.util.Date; |
34 |
|
import java.util.LinkedHashMap; |
35 |
|
import java.util.LinkedHashSet; |
36 |
|
import java.util.List; |
37 |
|
import java.util.Map; |
38 |
|
import java.util.Set; |
39 |
|
|
40 |
|
import org.kuali.student.contract.model.MessageStructure; |
41 |
|
import org.kuali.student.contract.model.Service; |
42 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
43 |
|
import org.kuali.student.contract.model.ServiceMethod; |
44 |
|
import org.kuali.student.contract.model.ServiceMethodError; |
45 |
|
import org.kuali.student.contract.model.ServiceMethodParameter; |
46 |
|
import org.kuali.student.contract.model.ServiceMethodReturnValue; |
47 |
|
import org.kuali.student.contract.model.XmlType; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@author |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 1,291 (1,291) |
Complexity: 318 |
Complexity Density: 0.43 |
|
53 |
|
public class ServiceContractModelQDoxLoader implements |
54 |
|
ServiceContractModel { |
55 |
|
|
56 |
|
private static final String LOCALE_KEY_LIST = "LocaleKeyList"; |
57 |
|
private static final String MESSAGE_GROUP_KEY_LIST = "MessageGroupKeyList"; |
58 |
|
private static final JavaClass STRING_JAVA_CLASS = new JavaClass( |
59 |
|
"java.lang.String"); |
60 |
|
private List<String> sourceDirectories = null; |
61 |
|
private List<Service> services = null; |
62 |
|
private List<ServiceMethod> serviceMethods = null; |
63 |
|
private Map<String, XmlType> xmlTypeMap = null; |
64 |
|
private List<MessageStructure> messageStructures; |
65 |
|
private boolean validateKualiStudent = true; |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
0
|
public ServiceContractModelQDoxLoader(List<String> sourceDirectories) {... |
68 |
0
|
this.sourceDirectories = sourceDirectories; |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
0
|
public ServiceContractModelQDoxLoader(List<String> sourceDirectories, boolean validateKualiStudent) {... |
72 |
0
|
this.sourceDirectories = sourceDirectories; |
73 |
0
|
this.setValidateKualiStudent(validateKualiStudent); |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0
|
public boolean isValidateKualiStudent() {... |
77 |
0
|
return validateKualiStudent; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0
|
public void setValidateKualiStudent(boolean validateKualiStudent) {... |
81 |
0
|
this.validateKualiStudent = validateKualiStudent; |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
84 |
0
|
@Override... |
85 |
|
public List<ServiceMethod> getServiceMethods() { |
86 |
0
|
if (this.serviceMethods == null) { |
87 |
0
|
this.parse(); |
88 |
|
} |
89 |
0
|
return this.serviceMethods; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
92 |
0
|
@Override... |
93 |
|
public List<String> getSourceNames() { |
94 |
0
|
List<String> list = new ArrayList(this.sourceDirectories.size()); |
95 |
0
|
for (String javaFile : this.sourceDirectories) { |
96 |
0
|
list.add(javaFile); |
97 |
|
} |
98 |
0
|
return list; |
99 |
|
} |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
101 |
0
|
@Override... |
102 |
|
public List<Service> getServices() { |
103 |
0
|
if (services == null) { |
104 |
0
|
this.parse(); |
105 |
|
} |
106 |
0
|
return services; |
107 |
|
} |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
109 |
0
|
@Override... |
110 |
|
public List<XmlType> getXmlTypes() { |
111 |
0
|
if (xmlTypeMap == null) { |
112 |
0
|
this.parse(); |
113 |
|
} |
114 |
0
|
return new ArrayList(xmlTypeMap.values()); |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
117 |
0
|
@Override... |
118 |
|
public List<MessageStructure> getMessageStructures() { |
119 |
0
|
if (messageStructures == null) { |
120 |
0
|
this.parse(); |
121 |
|
} |
122 |
0
|
return this.messageStructures; |
123 |
|
} |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
125 |
0
|
private String dump(DocletTag tag) {... |
126 |
0
|
if (tag == null) { |
127 |
0
|
return null; |
128 |
|
} |
129 |
0
|
StringBuilder bldr = new StringBuilder(); |
130 |
0
|
bldr.append(tag.getName()); |
131 |
0
|
bldr.append("="); |
132 |
0
|
if (tag.getNamedParameterMap() == null |
133 |
|
|| tag.getNamedParameterMap().isEmpty()) { |
134 |
0
|
bldr.append(tag.getValue()); |
135 |
|
} else { |
136 |
0
|
for (Object key : tag.getNamedParameterMap().keySet()) { |
137 |
0
|
Object value = tag.getNamedParameterMap().get(key); |
138 |
0
|
bldr.append("("); |
139 |
0
|
bldr.append(key); |
140 |
0
|
bldr.append("="); |
141 |
0
|
bldr.append(value); |
142 |
0
|
bldr.append(")"); |
143 |
|
} |
144 |
|
} |
145 |
0
|
return bldr.toString(); |
146 |
|
} |
147 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
148 |
0
|
private void checkIfExists(String sourceDirectory) {... |
149 |
0
|
File file = new File(sourceDirectory); |
150 |
0
|
if (!file.isDirectory()) { |
151 |
0
|
throw new IllegalArgumentException(sourceDirectory + " is not a directory on disk"); |
152 |
|
} |
153 |
|
} |
154 |
|
|
|
|
| 0% |
Uncovered Elements: 61 (61) |
Complexity: 4 |
Complexity Density: 0.07 |
|
155 |
0
|
private void parse() {... |
156 |
|
|
157 |
0
|
services = new ArrayList(); |
158 |
0
|
serviceMethods = new ArrayList(); |
159 |
0
|
xmlTypeMap = new LinkedHashMap(); |
160 |
0
|
messageStructures = new ArrayList(); |
161 |
0
|
DefaultDocletTagFactory dtf = new DefaultDocletTagFactory(); |
162 |
0
|
JavaDocBuilder builder = new JavaDocBuilder(dtf); |
163 |
0
|
for (String sourceDirectory : sourceDirectories) { |
164 |
0
|
checkIfExists(sourceDirectory); |
165 |
0
|
builder.addSourceTree(new File(sourceDirectory)); |
166 |
|
} |
167 |
0
|
List<JavaClass> sortedClasses = Arrays.asList(builder.getClasses()); |
168 |
0
|
Collections.sort(sortedClasses); |
169 |
0
|
for (JavaClass javaClass : sortedClasses) { |
170 |
0
|
if (!this.isServiceToProcess(javaClass)) { |
171 |
0
|
continue; |
172 |
|
} |
173 |
|
|
174 |
0
|
Service service = new Service(); |
175 |
0
|
services.add(service); |
176 |
0
|
service.setKey(javaClass.getName().substring(0, javaClass.getName().length() |
177 |
|
- "Service".length())); |
178 |
0
|
service.setName(javaClass.getName()); |
179 |
0
|
service.setComments(this.calcComment(javaClass)); |
180 |
0
|
service.setUrl(this.calcServiceUrl(javaClass)); |
181 |
0
|
service.setVersion(this.calcVersion(javaClass)); |
182 |
0
|
service.setStatus("???"); |
183 |
0
|
service.setIncludedServices(calcIncludedServices(javaClass)); |
184 |
0
|
service.setImplProject(javaClass.getPackageName()); |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
0
|
for (JavaMethod javaMethod : javaClass.getMethods()) { |
193 |
|
|
194 |
0
|
ServiceMethod serviceMethod = new ServiceMethod(); |
195 |
0
|
serviceMethods.add(serviceMethod); |
196 |
0
|
serviceMethod.setService(service.getKey()); |
197 |
0
|
serviceMethod.setName(javaMethod.getName()); |
198 |
0
|
serviceMethod.setDescription(calcMissing(javaMethod.getComment())); |
199 |
0
|
serviceMethod.setParameters(new ArrayList()); |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
0
|
for (JavaParameter parameter : javaMethod.getParameters()) { |
209 |
0
|
ServiceMethodParameter param = new ServiceMethodParameter(); |
210 |
0
|
serviceMethod.getParameters().add(param); |
211 |
0
|
param.setName(parameter.getName()); |
212 |
0
|
param.setType(calcType(parameter.getType())); |
213 |
0
|
param.setDescription(calcMissing( |
214 |
|
calcParameterDescription(javaMethod, |
215 |
|
param.getName()))); |
216 |
0
|
addXmlTypeAndMessageStructure(calcRealJavaClass(parameter.getType()), |
217 |
|
serviceMethod.getService()); |
218 |
|
} |
219 |
|
|
220 |
0
|
serviceMethod.setErrors(new ArrayList()); |
221 |
0
|
for (Type exception : javaMethod.getExceptions()) { |
222 |
0
|
ServiceMethodError error = new ServiceMethodError(); |
223 |
0
|
error.setType(this.calcType(exception.getJavaClass())); |
224 |
0
|
error.setDescription(calcMissing( |
225 |
|
calcExceptionDescription(javaMethod, |
226 |
|
error.getType()))); |
227 |
0
|
error.setPackageName(exception.getJavaClass().getPackageName()); |
228 |
0
|
error.setClassName(exception.getJavaClass().getName()); |
229 |
0
|
serviceMethod.getErrors().add(error); |
230 |
|
} |
231 |
|
|
232 |
0
|
ServiceMethodReturnValue rv = new ServiceMethodReturnValue(); |
233 |
0
|
serviceMethod.setReturnValue(rv); |
234 |
0
|
Type returnType = null; |
235 |
0
|
try { |
236 |
0
|
returnType = javaMethod.getReturnType(); |
237 |
|
} catch (NullPointerException ex) { |
238 |
0
|
System.out.println("Nullpinter getting return type: " + javaMethod.getCallSignature()); |
239 |
0
|
returnType = null; |
240 |
|
} |
241 |
|
|
242 |
0
|
rv.setType(calcType(returnType)); |
243 |
0
|
rv.setDescription(calcMissing(this.calcReturnDescription(javaMethod))); |
244 |
0
|
if (returnType != null) { |
245 |
0
|
addXmlTypeAndMessageStructure(calcRealJavaClass(returnType), |
246 |
|
serviceMethod.getService()); |
247 |
|
} |
248 |
|
} |
249 |
|
} |
250 |
|
} |
251 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.5 |
|
252 |
0
|
private boolean isServiceToProcess(JavaClass javaClass) {... |
253 |
|
|
254 |
0
|
if (!javaClass.getName().endsWith("Service")) { |
255 |
0
|
return false; |
256 |
|
} |
257 |
0
|
if (javaClass.getPackageName().contains(".old.")) { |
258 |
|
|
259 |
0
|
return false; |
260 |
|
} |
261 |
0
|
if (javaClass.getPackageName().endsWith(".old")) { |
262 |
0
|
return false; |
263 |
|
} |
264 |
0
|
for (Annotation annotation : javaClass.getAnnotations()) { |
265 |
|
|
266 |
0
|
if (annotation.getType().getJavaClass().getName().equals("WebService")) { |
267 |
|
|
268 |
|
|
269 |
0
|
return true; |
270 |
|
} |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
0
|
if (javaClass.getName().endsWith("BoService")) { |
276 |
0
|
return true; |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
0
|
return false; |
281 |
|
} |
282 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
283 |
0
|
private List<String> calcIncludedServices(JavaClass javaClass) {... |
284 |
0
|
List<String> includedServices = new ArrayList<String>(); |
285 |
0
|
for (JavaClass interfaceClass : javaClass.getImplementedInterfaces()) { |
286 |
|
|
287 |
|
|
288 |
0
|
includedServices.add(interfaceClass.getName()); |
289 |
|
} |
290 |
0
|
return includedServices; |
291 |
|
} |
292 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
293 |
0
|
private String calcParameterDescription(JavaMethod method,... |
294 |
|
String parameterName) { |
295 |
0
|
for (DocletTag tag : method.getTags()) { |
296 |
0
|
if (tag.getName().equals("param")) { |
297 |
0
|
if (tag.getValue().startsWith(parameterName + " ")) { |
298 |
0
|
return tag.getValue().substring(parameterName.length() + 1); |
299 |
|
} |
300 |
|
} |
301 |
|
} |
302 |
0
|
return null; |
303 |
|
} |
304 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
305 |
0
|
private String calcExceptionDescription(JavaMethod serviceMethod,... |
306 |
|
String exceptionType) { |
307 |
0
|
for (DocletTag tag : serviceMethod.getTags()) { |
308 |
0
|
if (tag.getName().equals("throws")) { |
309 |
0
|
if (tag.getValue().startsWith(exceptionType + " ")) { |
310 |
0
|
return tag.getValue().substring(exceptionType.length() + 1); |
311 |
|
} |
312 |
|
} |
313 |
|
} |
314 |
0
|
return null; |
315 |
|
} |
316 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
317 |
0
|
private String calcReturnDescription(JavaMethod serviceMethod) {... |
318 |
0
|
for (DocletTag tag : serviceMethod.getTags()) { |
319 |
0
|
if (tag.getName().equals("return")) { |
320 |
0
|
return tag.getValue(); |
321 |
|
} |
322 |
|
} |
323 |
0
|
return null; |
324 |
|
} |
325 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
326 |
0
|
private String calcServiceUrl(JavaClass serviceClass) {... |
327 |
0
|
for (DocletTag tag : serviceClass.getTags()) { |
328 |
0
|
if (tag.getName().equals("See")) { |
329 |
0
|
return tag.getValue(); |
330 |
|
} |
331 |
|
} |
332 |
0
|
return null; |
333 |
|
} |
334 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 3 |
Complexity Density: 0.21 |
|
335 |
0
|
private void addXmlTypeAndMessageStructure(JavaClass messageStructureJavaClass,... |
336 |
|
String serviceKey) { |
337 |
0
|
String name = calcType(messageStructureJavaClass); |
338 |
0
|
XmlType xmlType = xmlTypeMap.get(name); |
339 |
0
|
if (xmlType == null) { |
340 |
0
|
xmlType = new XmlType(); |
341 |
0
|
xmlTypeMap.put(name, xmlType); |
342 |
0
|
xmlType.setName(name); |
343 |
0
|
xmlType.setDesc(this.calcMessageStructureDesc(messageStructureJavaClass)); |
344 |
0
|
xmlType.setService(serviceKey); |
345 |
0
|
xmlType.setVersion("IGNORE -- SAME AS SERVICE"); |
346 |
0
|
xmlType.setPrimitive(calcPrimitive(messageStructureJavaClass)); |
347 |
0
|
xmlType.setJavaPackage(calcJavaPackage(messageStructureJavaClass)); |
348 |
0
|
if (xmlType.getPrimitive().equals(XmlType.COMPLEX)) { |
349 |
0
|
addMessageStructure(messageStructureJavaClass, serviceKey); |
350 |
|
} |
351 |
|
} else { |
352 |
0
|
addServiceToList(xmlType, serviceKey); |
353 |
|
} |
354 |
|
} |
355 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
356 |
0
|
private String calcJavaPackage(JavaClass javaClass) {... |
357 |
0
|
String packageName = javaClass.getPackageName(); |
358 |
0
|
return packageName; |
359 |
|
} |
360 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
361 |
0
|
private String calcMessageStructureDesc(JavaClass javaClass) {... |
362 |
|
{ |
363 |
0
|
String desc = javaClass.getComment(); |
364 |
0
|
if (desc != null) { |
365 |
0
|
if (!desc.isEmpty()) { |
366 |
0
|
return desc; |
367 |
|
} |
368 |
|
} |
369 |
0
|
JavaClass infcClass = this.getMatchingInfc(javaClass); |
370 |
0
|
if (infcClass == null) { |
371 |
0
|
return null; |
372 |
|
} |
373 |
0
|
return infcClass.getComment(); |
374 |
|
} |
375 |
|
} |
376 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
377 |
0
|
private JavaClass getMatchingInfc(JavaClass javaClass) {... |
378 |
|
|
379 |
0
|
String nameInfc = javaClass.getName(); |
380 |
0
|
if (nameInfc.endsWith("Info")) { |
381 |
0
|
nameInfc = nameInfc.substring(0, nameInfc.length() - "Info".length()) |
382 |
|
+ "Infc"; |
383 |
|
} |
384 |
0
|
String nameWithOutInfo = javaClass.getName(); |
385 |
|
|
386 |
0
|
if (nameWithOutInfo.endsWith("Info")) { |
387 |
0
|
nameWithOutInfo = nameWithOutInfo.substring(0, nameWithOutInfo.length() |
388 |
|
- "Info".length()); |
389 |
|
} |
390 |
0
|
for (JavaClass infc : javaClass.getImplementedInterfaces()) { |
391 |
0
|
if (infc.getName().equals(nameInfc)) { |
392 |
|
|
393 |
0
|
return infc; |
394 |
|
} |
395 |
0
|
if (infc.getName().equals(nameWithOutInfo)) { |
396 |
0
|
return infc; |
397 |
|
} |
398 |
|
} |
399 |
0
|
return null; |
400 |
|
} |
401 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
402 |
0
|
private String calcPrimitive(JavaClass javaClass) {... |
403 |
0
|
if (this.isComplex(javaClass)) { |
404 |
0
|
return XmlType.COMPLEX; |
405 |
|
} |
406 |
0
|
return "Primitive"; |
407 |
|
} |
408 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
409 |
0
|
private String initLower(String str) {... |
410 |
0
|
if (str == null) { |
411 |
0
|
return null; |
412 |
|
} |
413 |
0
|
if (str.length() == 0) { |
414 |
0
|
return str; |
415 |
|
} |
416 |
0
|
if (str.length() == 1) { |
417 |
0
|
return str.toLowerCase(); |
418 |
|
} |
419 |
0
|
return str.substring(0, 1).toLowerCase() + str.substring(1); |
420 |
|
} |
421 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
422 |
0
|
private String initUpper(String str) {... |
423 |
0
|
if (str == null) { |
424 |
0
|
return null; |
425 |
|
} |
426 |
0
|
if (str.length() == 0) { |
427 |
0
|
return str; |
428 |
|
} |
429 |
0
|
if (str.length() == 1) { |
430 |
0
|
return str.toUpperCase(); |
431 |
|
} |
432 |
0
|
return str.substring(0, 1).toUpperCase() + str.substring(1); |
433 |
|
} |
434 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
435 |
0
|
private Set<String> getShortNames(JavaClass messageStructureJavaClass) {... |
436 |
0
|
Set<String> fields = getFieldsUsingPropOrder(messageStructureJavaClass); |
437 |
0
|
if (fields != null) { |
438 |
0
|
return fields; |
439 |
|
} |
440 |
0
|
fields = new LinkedHashSet(); |
441 |
0
|
for (JavaMethod method : messageStructureJavaClass.getMethods(true)) { |
442 |
0
|
if (isSetterMethodToProcess(method, messageStructureJavaClass.getName())) { |
443 |
0
|
String shortName = this.calcShortNameFromSetter(method); |
444 |
0
|
fields.add(shortName); |
445 |
0
|
continue; |
446 |
|
} |
447 |
0
|
if (isGetterMethodToProcess(method, messageStructureJavaClass.getName())) { |
448 |
0
|
String shortName = this.calcShortNameFromGetter(method); |
449 |
0
|
fields.add(shortName); |
450 |
0
|
continue; |
451 |
|
} |
452 |
|
} |
453 |
0
|
return fields; |
454 |
|
} |
455 |
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 10 |
Complexity Density: 0.34 |
|
456 |
0
|
private Set<String> getFieldsUsingPropOrder(... |
457 |
|
JavaClass messageStructureJavaClass) { |
458 |
0
|
for (Annotation annotation : messageStructureJavaClass.getAnnotations()) { |
459 |
0
|
if (annotation.getType().getJavaClass().getName().equals("XmlType")) { |
460 |
0
|
AnnotationValue propOrderParam = annotation.getProperty("propOrder"); |
461 |
0
|
if (propOrderParam == null) { |
462 |
0
|
continue; |
463 |
|
} |
464 |
0
|
Object propOrderValue = propOrderParam.getParameterValue(); |
465 |
0
|
if (!(propOrderValue instanceof List)) { |
466 |
0
|
continue; |
467 |
|
} |
468 |
0
|
Set<String> fields = new LinkedHashSet(); |
469 |
0
|
for (Object value : (List) propOrderValue) { |
470 |
0
|
if (value instanceof String) { |
471 |
0
|
String shortName = (String) value; |
472 |
0
|
shortName = this.stripQuotes(shortName); |
473 |
0
|
if (shortName.contains(".Elements.")) { |
474 |
0
|
String newShortName = getShortNameFromElements(shortName, messageStructureJavaClass); |
475 |
0
|
if (newShortName == null) { |
476 |
0
|
continue; |
477 |
|
} |
478 |
0
|
shortName = newShortName; |
479 |
0
|
} else if (shortName.startsWith("CoreConstants.CommonElements.")) { |
480 |
0
|
String newShortName = getCoreConstants(shortName); |
481 |
0
|
if (newShortName == null) { |
482 |
0
|
continue; |
483 |
|
} |
484 |
0
|
shortName = newShortName; |
485 |
|
} |
486 |
0
|
if (shortName.equals("_futureElements")) { |
487 |
0
|
continue; |
488 |
|
} |
489 |
0
|
shortName = this.initUpper(shortName); |
490 |
0
|
fields.add(shortName); |
491 |
|
} |
492 |
|
} |
493 |
0
|
return fields; |
494 |
|
} |
495 |
|
} |
496 |
0
|
return null; |
497 |
|
} |
498 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
499 |
0
|
private String getShortNameFromElements(String shortName, JavaClass messageStructureJavaClass) {... |
500 |
0
|
JavaClass elementsJavaClass = messageStructureJavaClass.getNestedClassByName("Elements"); |
501 |
0
|
if (elementsJavaClass == null) { |
502 |
0
|
return null; |
503 |
|
} |
504 |
0
|
String fieldName = shortName.substring(shortName.indexOf(".Elements.") + ".Elements.".length()); |
505 |
0
|
JavaField field = elementsJavaClass.getFieldByName(fieldName); |
506 |
0
|
String initExpr = field.getInitializationExpression(); |
507 |
0
|
return stripQuotes(initExpr); |
508 |
|
} |
509 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 8 |
Complexity Density: 0.53 |
|
510 |
0
|
private String getCoreConstants(String shortName) {... |
511 |
0
|
if (shortName.endsWith("VERSION_NUMBER")) { |
512 |
0
|
return "versionNumber"; |
513 |
|
} |
514 |
0
|
if (shortName.endsWith("OBJECT_ID")) { |
515 |
0
|
return "objectId"; |
516 |
|
} |
517 |
0
|
if (shortName.endsWith("ACTIVE")) { |
518 |
0
|
return "active"; |
519 |
|
} |
520 |
0
|
if (shortName.endsWith("ACTIVE_FROM_DATE")) { |
521 |
0
|
return "activeFromDate"; |
522 |
|
} |
523 |
0
|
if (shortName.endsWith("ACTIVE_TO_DATE")) { |
524 |
0
|
return "activeToDate"; |
525 |
|
} |
526 |
0
|
if (shortName.endsWith("ATTRIBUTES")) { |
527 |
0
|
return "attributes"; |
528 |
|
} |
529 |
0
|
if (shortName.endsWith("FUTURE_ELEMENTS")) { |
530 |
0
|
return "_futureElements"; |
531 |
|
} |
532 |
0
|
throw new RuntimeException("Unknown shortName " + shortName); |
533 |
|
} |
534 |
|
|
|
|
| 0% |
Uncovered Elements: 80 (80) |
Complexity: 15 |
Complexity Density: 0.29 |
|
535 |
0
|
private void addMessageStructure(JavaClass messageStructureJavaClass,... |
536 |
|
String serviceKey) { |
537 |
0
|
Set<JavaClass> subObjectsToAdd = new LinkedHashSet(); |
538 |
0
|
for (String shortName : this.getShortNames(messageStructureJavaClass)) { |
539 |
0
|
JavaMethod setterMethod = findSetterMethod(messageStructureJavaClass, |
540 |
|
shortName); |
541 |
0
|
JavaMethod getterMethod = findGetterMethod(messageStructureJavaClass, |
542 |
|
shortName); |
543 |
0
|
if (getterMethod == null) { |
544 |
0
|
if (this.validateKualiStudent) { |
545 |
0
|
throw new IllegalArgumentException("shortName has no corresponding getter method: " |
546 |
|
+ messageStructureJavaClass.getFullyQualifiedName() |
547 |
|
+ "." + shortName); |
548 |
|
} |
549 |
|
} |
550 |
0
|
JavaField beanField = this.findField(messageStructureJavaClass, |
551 |
|
shortName, setterMethod); |
552 |
0
|
if (beanField == null) { |
553 |
0
|
String accessorType = getAccessorType(getterMethod); |
554 |
0
|
if ("XmlAccessType.FIELD".equals(accessorType)) { |
555 |
0
|
throw new IllegalArgumentException("Setter method has no corresponding bean field: " |
556 |
|
+ messageStructureJavaClass.getName() |
557 |
|
+ "." + getterMethod.getName()); |
558 |
|
} |
559 |
|
} |
560 |
|
|
561 |
|
|
562 |
0
|
if (beanField != null) { |
563 |
0
|
for (Annotation annotation : beanField.getAnnotations()) { |
564 |
0
|
if (annotation.getType().getJavaClass().getName().equals("XmlAttribute")) { |
565 |
0
|
Object nameValue = annotation.getNamedParameter("name"); |
566 |
0
|
if (nameValue != null) { |
567 |
0
|
shortName = stripQuotes(nameValue.toString()); |
568 |
|
} |
569 |
|
} |
570 |
|
} |
571 |
|
} |
572 |
0
|
shortName = initLower(shortName); |
573 |
0
|
MessageStructure ms = new MessageStructure(); |
574 |
0
|
messageStructures.add(ms); |
575 |
0
|
ms.setXmlObject(messageStructureJavaClass.getName()); |
576 |
0
|
ms.setShortName(shortName); |
577 |
0
|
ms.setId(ms.getXmlObject() + "." + ms.getShortName()); |
578 |
0
|
ms.setName(calcMissing(calcName(messageStructureJavaClass, getterMethod, setterMethod, |
579 |
|
beanField, shortName))); |
580 |
0
|
ms.setType(calcType(messageStructureJavaClass, getterMethod, setterMethod, beanField, shortName)); |
581 |
0
|
if (ms.getType().equals("Object")) { |
582 |
0
|
System.out.println("WARNING " + ms.getId() |
583 |
|
+ " has Object as it's type ==> Changing to String"); |
584 |
0
|
ms.setType("String"); |
585 |
0
|
} else if (ms.getType().equals("ObjectList")) { |
586 |
0
|
System.out.println( |
587 |
|
"WARNING " + ms.getId() |
588 |
|
+ " has a list of Objects as it's type ==> Changing to List of String"); |
589 |
0
|
ms.setType("StringList"); |
590 |
|
} |
591 |
0
|
ms.setXmlAttribute(this.calcXmlAttribute(beanField)); |
592 |
0
|
ms.setRequired(calcRequired(getterMethod, setterMethod, beanField)); |
593 |
0
|
ms.setReadOnly(calcReadOnly(getterMethod, setterMethod, beanField)); |
594 |
0
|
ms.setCardinality(this.calcCardinality(messageStructureJavaClass, getterMethod, setterMethod, beanField, shortName)); |
595 |
0
|
ms.setDescription(calcMissing(calcDescription(messageStructureJavaClass, getterMethod, setterMethod, |
596 |
|
beanField))); |
597 |
0
|
ms.setImplNotes(calcImplementationNotes(getterMethod, setterMethod, beanField)); |
598 |
0
|
ms.setStatus("???"); |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
0
|
ms.setOverriden(this.calcOverridden(messageStructureJavaClass, getterMethod)); |
603 |
0
|
JavaClass subObjToAdd = this.calcRealJavaClassOfGetterReturn(getterMethod); |
604 |
0
|
if (subObjToAdd != null) { |
605 |
|
|
606 |
0
|
if (!subObjToAdd.getName().equals("Object")) { |
607 |
0
|
if (!subObjToAdd.getName().equals("LocaleKeyList")) { |
608 |
0
|
if (!subObjToAdd.getName().equals("MessageGroupKeyList")) { |
609 |
0
|
subObjectsToAdd.add(subObjToAdd); |
610 |
|
} |
611 |
|
} |
612 |
|
} |
613 |
|
|
614 |
|
} |
615 |
|
} |
616 |
|
|
617 |
0
|
for (JavaClass subObjectToAdd : subObjectsToAdd) { |
618 |
0
|
XmlType xmlType = xmlTypeMap.get(calcType(subObjectToAdd)); |
619 |
0
|
if (xmlType == null) { |
620 |
0
|
addXmlTypeAndMessageStructure(subObjectToAdd, serviceKey); |
621 |
|
} else { |
622 |
0
|
addServiceToList(xmlType, serviceKey); |
623 |
|
} |
624 |
|
} |
625 |
0
|
return; |
626 |
|
} |
627 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
628 |
0
|
private boolean calcOverridden(JavaClass mainClass, JavaMethod getterMethod) {... |
629 |
0
|
if (getterMethod == null) { |
630 |
0
|
return false; |
631 |
|
} |
632 |
0
|
JavaMethod infcGetter = null; |
633 |
0
|
if (getterMethod.getParentClass().isInterface()) { |
634 |
0
|
infcGetter = getterMethod; |
635 |
|
} |
636 |
0
|
if (infcGetter == null) { |
637 |
0
|
infcGetter = findInterfaceMethod(mainClass, getterMethod); |
638 |
|
} |
639 |
0
|
if (infcGetter == null) { |
640 |
0
|
return false; |
641 |
|
} |
642 |
0
|
Annotation annotation = this.getAnnotation(infcGetter, null, null, "Override"); |
643 |
0
|
if (annotation != null) { |
644 |
0
|
return true; |
645 |
|
} |
646 |
0
|
return false; |
647 |
|
} |
648 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
649 |
0
|
private String calcComment(JavaClass javaClass) {... |
650 |
0
|
return this.calcComment(javaClass.getComment()); |
651 |
|
} |
652 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
653 |
0
|
private String calcComment(String comment) {... |
654 |
0
|
return this.parseCommentVersion(comment)[0]; |
655 |
|
} |
656 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
657 |
0
|
private String calcVersion(JavaClass javaClass) {... |
658 |
0
|
DocletTag tag = javaClass.getTagByName("version", true); |
659 |
0
|
if (tag != null) { |
660 |
0
|
return tag.getValue(); |
661 |
|
} |
662 |
0
|
return this.calcVersion(javaClass.getComment()); |
663 |
|
} |
664 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
665 |
0
|
private String calcVersion(String comment) {... |
666 |
0
|
return this.parseCommentVersion(comment)[1]; |
667 |
|
} |
668 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
669 |
0
|
private String[] parseCommentVersion(String commentVersion) {... |
670 |
0
|
String[] parsed = new String[2]; |
671 |
0
|
if (commentVersion == null) { |
672 |
0
|
return parsed; |
673 |
|
} |
674 |
0
|
commentVersion = commentVersion.trim(); |
675 |
0
|
int i = commentVersion.toLowerCase().indexOf("\nversion:"); |
676 |
0
|
if (i == -1) { |
677 |
0
|
parsed[0] = commentVersion; |
678 |
0
|
return parsed; |
679 |
|
} |
680 |
0
|
parsed[1] = commentVersion.substring(i + "\nversion:".length()).trim(); |
681 |
0
|
parsed[0] = commentVersion.substring(0, i).trim(); |
682 |
|
|
683 |
0
|
return parsed; |
684 |
|
} |
685 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
686 |
0
|
private Annotation getAnnotation(JavaMethod getterMethod,... |
687 |
|
JavaMethod setterMethod, JavaField beanField, String type) { |
688 |
0
|
if (beanField != null) { |
689 |
|
|
690 |
0
|
for (Annotation annotation : beanField.getAnnotations()) { |
691 |
0
|
if (annotation.getType().getJavaClass().getName().equals(type)) { |
692 |
0
|
return annotation; |
693 |
|
} |
694 |
|
} |
695 |
|
} |
696 |
0
|
if (getterMethod != null) { |
697 |
|
|
698 |
0
|
for (Annotation annotation : getterMethod.getAnnotations()) { |
699 |
0
|
if (annotation.getType().getJavaClass().getName().equals(type)) { |
700 |
0
|
return annotation; |
701 |
|
} |
702 |
|
} |
703 |
|
} |
704 |
0
|
if (setterMethod != null) { |
705 |
|
|
706 |
0
|
for (Annotation annotation : setterMethod.getAnnotations()) { |
707 |
0
|
if (annotation.getType().getJavaClass().getName().equals(type)) { |
708 |
0
|
return annotation; |
709 |
|
} |
710 |
|
} |
711 |
|
} |
712 |
0
|
return null; |
713 |
|
} |
714 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 8 |
Complexity Density: 0.5 |
|
715 |
0
|
private String calcRequired(JavaMethod getterMethod,... |
716 |
|
JavaMethod setterMethod, JavaField beanField) { |
717 |
0
|
Annotation annotation = this.getAnnotation(getterMethod, setterMethod, beanField, "XmlElement"); |
718 |
0
|
if (annotation == null) { |
719 |
0
|
annotation = this.getAnnotation(getterMethod, setterMethod, beanField, "XmlAttribute"); |
720 |
|
} |
721 |
0
|
if (annotation != null) { |
722 |
0
|
Object required = annotation.getNamedParameter("required"); |
723 |
0
|
if (required != null) { |
724 |
0
|
if (required.toString().equalsIgnoreCase("true")) { |
725 |
0
|
return "Required"; |
726 |
|
} |
727 |
|
} |
728 |
|
} |
729 |
0
|
if (getterMethod != null) { |
730 |
0
|
DocletTag tag = getterMethod.getTagByName("required", true); |
731 |
0
|
if (tag != null) { |
732 |
0
|
if (tag.getValue() == null) { |
733 |
0
|
return "Required"; |
734 |
|
} |
735 |
0
|
String required = "Required " + tag.getValue(); |
736 |
0
|
return required.trim(); |
737 |
|
} |
738 |
|
} |
739 |
0
|
return null; |
740 |
|
} |
741 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
742 |
0
|
private String calcReadOnly(JavaMethod getterMethod,... |
743 |
|
JavaMethod setterMethod, JavaField beanField) { |
744 |
0
|
if (getterMethod != null) { |
745 |
0
|
DocletTag tag = getterMethod.getTagByName("readOnly", true); |
746 |
0
|
if (tag != null) { |
747 |
0
|
if (tag.getValue() == null) { |
748 |
0
|
return "Read only"; |
749 |
|
} |
750 |
0
|
String readOnly = "Read only " + tag.getValue(); |
751 |
0
|
return readOnly.trim(); |
752 |
|
} |
753 |
|
} |
754 |
0
|
return null; |
755 |
|
} |
756 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
757 |
0
|
private String calcImplementationNotes(JavaMethod getterMethod,... |
758 |
|
JavaMethod setterMethod, JavaField beanField) { |
759 |
0
|
if (getterMethod != null) { |
760 |
0
|
DocletTag tag = getterMethod.getTagByName("impl", true); |
761 |
0
|
if (tag != null) { |
762 |
0
|
return tag.getValue(); |
763 |
|
} |
764 |
|
} |
765 |
0
|
return null; |
766 |
|
} |
767 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
768 |
0
|
private String calcNameFromShortName(String shortName) {... |
769 |
0
|
StringBuilder bldr = new StringBuilder(shortName.length() + 3); |
770 |
0
|
char c = shortName.charAt(0); |
771 |
0
|
bldr.append(Character.toUpperCase(c)); |
772 |
0
|
boolean lastWasUpper = true; |
773 |
0
|
for (int i = 1; i < shortName.length(); i++) { |
774 |
0
|
c = shortName.charAt(i); |
775 |
0
|
if (Character.isUpperCase(c)) { |
776 |
0
|
if (!lastWasUpper) { |
777 |
0
|
bldr.append(" "); |
778 |
|
} |
779 |
|
} else { |
780 |
0
|
lastWasUpper = false; |
781 |
|
} |
782 |
0
|
bldr.append(c); |
783 |
|
} |
784 |
0
|
return bldr.toString(); |
785 |
|
} |
786 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
787 |
0
|
private String calcName(JavaClass mainClass, JavaMethod getterMethod,... |
788 |
|
JavaMethod setterMethod, JavaField beanField, String shortName) { |
789 |
0
|
String name = this.calcNameFromTag(getterMethod, setterMethod, beanField); |
790 |
0
|
if (name != null) { |
791 |
0
|
return name; |
792 |
|
} |
793 |
0
|
name = this.calcNameFromNameEmbeddedInDescription(mainClass, getterMethod, setterMethod, beanField); |
794 |
0
|
if (name != null) { |
795 |
0
|
return name; |
796 |
|
} |
797 |
0
|
return this.calcNameFromShortName(shortName); |
798 |
|
} |
799 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
800 |
0
|
private String calcNameFromTag(JavaMethod getterMethod,... |
801 |
|
JavaMethod setterMethod, JavaField beanField) { |
802 |
0
|
if (getterMethod != null) { |
803 |
0
|
DocletTag tag = getterMethod.getTagByName("name", true); |
804 |
0
|
if (tag != null) { |
805 |
0
|
return tag.getValue(); |
806 |
|
} |
807 |
|
} |
808 |
0
|
return null; |
809 |
|
} |
810 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
811 |
0
|
private String calcNameFromNameEmbeddedInDescription(JavaClass mainClass, JavaMethod getterMethod,... |
812 |
|
JavaMethod setterMethod, JavaField beanField) { |
813 |
0
|
String nameDesc = this.calcMethodComment(mainClass, getterMethod, setterMethod, |
814 |
|
beanField); |
815 |
0
|
String[] parsed = parseNameDesc(nameDesc); |
816 |
0
|
return parsed[0]; |
817 |
|
} |
818 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
819 |
0
|
private String[] parseNameDesc(String nameDesc) {... |
820 |
0
|
String[] parsed = new String[2]; |
821 |
0
|
if (nameDesc == null) { |
822 |
0
|
return parsed; |
823 |
|
} |
824 |
0
|
nameDesc = nameDesc.trim(); |
825 |
0
|
if (!nameDesc.startsWith("Name:")) { |
826 |
0
|
parsed[1] = nameDesc; |
827 |
0
|
return parsed; |
828 |
|
} |
829 |
0
|
nameDesc = nameDesc.substring("Name:".length()).trim(); |
830 |
0
|
int i = nameDesc.indexOf("\n"); |
831 |
0
|
if (i == -1) { |
832 |
0
|
parsed[0] = nameDesc.trim(); |
833 |
0
|
return parsed; |
834 |
|
} |
835 |
0
|
parsed[0] = nameDesc.substring(0, i).trim(); |
836 |
0
|
parsed[1] = nameDesc.substring(i).trim(); |
837 |
0
|
return parsed; |
838 |
|
} |
839 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
840 |
0
|
private String calcDescription(JavaClass mainClass, JavaMethod getterMethod,... |
841 |
|
JavaMethod setterMethod, JavaField beanField) { |
842 |
0
|
String nameDesc = this.calcMethodComment(mainClass, getterMethod, setterMethod, |
843 |
|
beanField); |
844 |
0
|
String[] parsed = parseNameDesc(nameDesc); |
845 |
0
|
return parsed[1]; |
846 |
|
} |
847 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0.45 |
|
848 |
0
|
private String calcMethodComment(JavaClass mainClass, JavaMethod getterMethod,... |
849 |
|
JavaMethod setterMethod, |
850 |
|
JavaField beanField) { |
851 |
0
|
String desc = null; |
852 |
0
|
if (getterMethod != null) { |
853 |
0
|
desc = getterMethod.getComment(); |
854 |
0
|
if (isCommentNotEmpty(desc)) { |
855 |
0
|
return desc; |
856 |
|
} |
857 |
|
} |
858 |
0
|
if (setterMethod != null) { |
859 |
0
|
desc = setterMethod.getComment(); |
860 |
0
|
if (isCommentNotEmpty(desc)) { |
861 |
0
|
return desc; |
862 |
|
} |
863 |
|
} |
864 |
0
|
if (beanField != null) { |
865 |
0
|
desc = beanField.getComment(); |
866 |
0
|
if (isCommentNotEmpty(desc)) { |
867 |
0
|
return desc; |
868 |
|
} |
869 |
|
} |
870 |
0
|
desc = calcMethodCommentRecursively(mainClass, getterMethod); |
871 |
0
|
if (isCommentNotEmpty(desc)) { |
872 |
0
|
return desc; |
873 |
|
} |
874 |
0
|
desc = calcMethodCommentRecursively(mainClass, setterMethod); |
875 |
0
|
if (isCommentNotEmpty(desc)) { |
876 |
0
|
return desc; |
877 |
|
} |
878 |
0
|
return null; |
879 |
|
} |
880 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 7 |
Complexity Density: 0.44 |
|
881 |
0
|
private String calcMethodCommentRecursively(JavaClass mainClass, JavaMethod method) {... |
882 |
0
|
if (method == null) { |
883 |
0
|
return null; |
884 |
|
} |
885 |
0
|
String desc = method.getComment(); |
886 |
0
|
if (isCommentNotEmpty(desc)) { |
887 |
0
|
return desc; |
888 |
|
} |
889 |
0
|
JavaMethod infcMethod = findInterfaceMethod(mainClass, method); |
890 |
0
|
if (infcMethod != null) { |
891 |
0
|
desc = infcMethod.getComment(); |
892 |
0
|
if (isCommentNotEmpty(desc)) { |
893 |
0
|
return desc; |
894 |
|
} |
895 |
|
} |
896 |
0
|
JavaMethod superMethod = findSuperMethod(method); |
897 |
0
|
if (superMethod != null) { |
898 |
0
|
desc = superMethod.getComment(); |
899 |
0
|
if (isCommentNotEmpty(desc)) { |
900 |
0
|
return desc; |
901 |
|
} |
902 |
|
} |
903 |
0
|
return null; |
904 |
|
} |
905 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
906 |
0
|
private JavaMethod findSuperMethod(JavaMethod method) {... |
907 |
|
|
908 |
|
|
909 |
|
|
910 |
0
|
for (JavaMethod superMethod : method.getParentClass().getMethods(true)) { |
911 |
0
|
if (method.equals(superMethod)) { |
912 |
0
|
continue; |
913 |
|
} |
914 |
0
|
if (method.getCallSignature().equals(superMethod.getCallSignature())) { |
915 |
0
|
return superMethod; |
916 |
|
} |
917 |
|
} |
918 |
0
|
return null; |
919 |
|
} |
920 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
921 |
0
|
private JavaMethod findInterfaceMethod(JavaClass mainClass, JavaMethod method) {... |
922 |
0
|
String callSig = method.getCallSignature(); |
923 |
0
|
JavaClass classToSearch = mainClass; |
924 |
|
|
925 |
0
|
while (true) { |
926 |
0
|
for (JavaClass infcClass : classToSearch.getImplementedInterfaces()) { |
927 |
0
|
JavaMethod meth = this.findMethodOnInterfaceRecursively(infcClass, callSig); |
928 |
0
|
if (meth != null) { |
929 |
|
|
930 |
0
|
return meth; |
931 |
|
} |
932 |
|
} |
933 |
0
|
JavaClass superClass = classToSearch.getSuperJavaClass(); |
934 |
0
|
if (superClass == null) { |
935 |
|
|
936 |
|
|
937 |
0
|
return null; |
938 |
|
} |
939 |
0
|
classToSearch = superClass; |
940 |
|
|
941 |
|
} |
942 |
|
} |
943 |
|
|
944 |
|
|
945 |
|
|
946 |
|
|
947 |
|
|
948 |
|
|
949 |
|
|
950 |
|
|
951 |
|
|
952 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
953 |
0
|
private JavaMethod findMethodOnInterfaceRecursively(JavaClass infcClass, String callSig) {... |
954 |
|
|
955 |
|
|
956 |
0
|
for (JavaMethod infcMethod : infcClass.getMethods()) { |
957 |
0
|
if (callSig.equals(infcMethod.getCallSignature())) { |
958 |
|
|
959 |
|
|
960 |
0
|
return infcMethod; |
961 |
|
} |
962 |
|
} |
963 |
0
|
for (JavaClass subInfc : infcClass.getImplementedInterfaces()) { |
964 |
|
|
965 |
0
|
JavaMethod infcMethod = findMethodOnInterfaceRecursively(subInfc, callSig); |
966 |
0
|
if (infcMethod != null) { |
967 |
|
|
968 |
0
|
return infcMethod; |
969 |
|
} |
970 |
|
} |
971 |
|
|
972 |
|
|
973 |
0
|
return null; |
974 |
|
} |
975 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
976 |
0
|
private boolean isCommentNotEmpty(String desc) {... |
977 |
0
|
if (desc == null) { |
978 |
0
|
return false; |
979 |
|
} |
980 |
0
|
if (desc.trim().isEmpty()) { |
981 |
0
|
return false; |
982 |
|
} |
983 |
0
|
if (desc.contains("@inheritDoc")) { |
984 |
0
|
return false; |
985 |
|
} |
986 |
0
|
return true; |
987 |
|
} |
988 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
989 |
0
|
private String getAccessorType(JavaMethod method) {... |
990 |
0
|
String accessorType = getAccessorType(method.getAnnotations()); |
991 |
0
|
if (accessorType != null) { |
992 |
0
|
return accessorType; |
993 |
|
} |
994 |
0
|
accessorType = getAccessorType(method.getParentClass().getAnnotations()); |
995 |
0
|
return accessorType; |
996 |
|
} |
997 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
998 |
0
|
private String getAccessorType(Annotation[] annotations) {... |
999 |
0
|
for (Annotation annotation : annotations) { |
1000 |
0
|
if (annotation.getType().getJavaClass().getName().equals( |
1001 |
|
"XmlAccessorType")) { |
1002 |
|
|
1003 |
|
|
1004 |
0
|
return annotation.getParameterValue().toString(); |
1005 |
|
} |
1006 |
|
} |
1007 |
0
|
return null; |
1008 |
|
} |
1009 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1010 |
0
|
private String stripQuotes(String str) {... |
1011 |
0
|
if (str.startsWith("\"")) { |
1012 |
0
|
str = str.substring(1); |
1013 |
|
} |
1014 |
0
|
if (str.endsWith("\"")) { |
1015 |
0
|
str = str.substring(0, str.length() - 1); |
1016 |
|
} |
1017 |
0
|
return str; |
1018 |
|
} |
1019 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1020 |
0
|
private String calcMissing(String str) {... |
1021 |
0
|
if (str == null) { |
1022 |
0
|
return "???"; |
1023 |
|
} |
1024 |
0
|
if (str.trim().isEmpty()) { |
1025 |
0
|
return "???"; |
1026 |
|
} |
1027 |
0
|
return str; |
1028 |
|
} |
1029 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1030 |
0
|
private void addServiceToList(XmlType xmlType, String serviceKey) {... |
1031 |
0
|
if (!xmlType.getService().contains(serviceKey)) { |
1032 |
0
|
xmlType.setService(xmlType.getService() + ", " + serviceKey); |
1033 |
|
} |
1034 |
|
} |
1035 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
1036 |
0
|
private String calcXmlAttribute(JavaField beanField) {... |
1037 |
0
|
if (beanField == null) { |
1038 |
|
|
1039 |
0
|
return "No"; |
1040 |
|
} |
1041 |
0
|
for (Annotation annotation : beanField.getAnnotations()) { |
1042 |
0
|
if (annotation.getType().getJavaClass().getName().equals("XmlAttribute")) { |
1043 |
0
|
return "Yes"; |
1044 |
|
} |
1045 |
|
} |
1046 |
0
|
return "No"; |
1047 |
|
} |
1048 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
1049 |
0
|
private JavaField findField(JavaClass javaClass, String shortName,... |
1050 |
|
JavaMethod setterMethod) { |
1051 |
0
|
JavaField field = findField(javaClass, shortName); |
1052 |
0
|
if (field != null) { |
1053 |
0
|
return field; |
1054 |
|
} |
1055 |
0
|
if (setterMethod != null) { |
1056 |
0
|
String paramName = setterMethod.getParameters()[0].getName(); |
1057 |
0
|
if (paramName.equalsIgnoreCase(shortName)) { |
1058 |
0
|
return null; |
1059 |
|
} |
1060 |
0
|
return findField(javaClass, paramName); |
1061 |
|
} |
1062 |
0
|
return null; |
1063 |
|
} |
1064 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
1065 |
0
|
private JavaField findField(JavaClass javaClass, String name) {... |
1066 |
0
|
if (name == null) { |
1067 |
0
|
return null; |
1068 |
|
} |
1069 |
0
|
for (JavaField field : javaClass.getFields()) { |
1070 |
0
|
if (field.getName().equalsIgnoreCase(name)) { |
1071 |
0
|
return field; |
1072 |
|
} |
1073 |
|
|
1074 |
0
|
if (field.getName().equals("is" + name)) { |
1075 |
0
|
return field; |
1076 |
|
} |
1077 |
|
} |
1078 |
0
|
JavaClass superClass = javaClass.getSuperJavaClass(); |
1079 |
0
|
if (superClass == null) { |
1080 |
0
|
return null; |
1081 |
|
} |
1082 |
0
|
return findField(superClass, name); |
1083 |
|
} |
1084 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 7 |
Complexity Density: 0.64 |
|
1085 |
0
|
private JavaMethod findGetterMethod(JavaClass msClass, String shortName) {... |
1086 |
0
|
for (JavaMethod method : msClass.getMethods(true)) { |
1087 |
0
|
if (method.getName().equalsIgnoreCase("get" + shortName)) { |
1088 |
0
|
return method; |
1089 |
|
} |
1090 |
0
|
if (method.getName().toLowerCase().startsWith("is")) { |
1091 |
0
|
if (method.getName().equalsIgnoreCase("is" + shortName)) { |
1092 |
0
|
return method; |
1093 |
|
} |
1094 |
|
|
1095 |
0
|
if (method.getName().equalsIgnoreCase(shortName)) { |
1096 |
0
|
return method; |
1097 |
|
} |
1098 |
|
} |
1099 |
|
|
1100 |
0
|
if (method.getName().equalsIgnoreCase("getInState") && shortName.equalsIgnoreCase( |
1101 |
|
"InStateFlag")) { |
1102 |
0
|
return method; |
1103 |
|
} |
1104 |
|
} |
1105 |
0
|
return null; |
1106 |
|
} |
1107 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
1108 |
0
|
private JavaMethod findSetterMethod(JavaClass msClass, String shortName) {... |
1109 |
0
|
for (JavaMethod method : msClass.getMethods(true)) { |
1110 |
0
|
if (method.getName().equals("set" + shortName)) { |
1111 |
0
|
return method; |
1112 |
|
} |
1113 |
|
|
1114 |
0
|
if (method.getName().equals("setIs" + shortName)) { |
1115 |
0
|
return method; |
1116 |
|
} |
1117 |
|
|
1118 |
0
|
if (method.getName().equals("setInStateFlag") && shortName.equals( |
1119 |
|
"InState")) { |
1120 |
0
|
return method; |
1121 |
|
} |
1122 |
|
} |
1123 |
0
|
return null; |
1124 |
|
} |
1125 |
|
private static final String[] SETTER_METHODS_TO_SKIP = { |
1126 |
|
|
1127 |
|
"ValidationResultInfo.setWarning", |
1128 |
|
"ValidationResultInfo.setError", |
1129 |
|
|
1130 |
|
"CredentialProgramInfo.setDiplomaTitle", |
1131 |
|
|
1132 |
|
"CredentialProgramInfo.setType", |
1133 |
|
|
1134 |
|
"CredentialProgramInfo.setHegisCode", |
1135 |
|
"CredentialProgramInfo.setCip2000Code", |
1136 |
|
"CredentialProgramInfo.setCip2010Code", |
1137 |
|
"CredentialProgramInfo.setSelectiveEnrollmentCode", |
1138 |
|
"CoreProgramInfo.setDiplomaTitle", |
1139 |
|
|
1140 |
|
|
1141 |
|
|
1142 |
|
"CoreProgramInfo.setHegisCode", |
1143 |
|
"CoreProgramInfo.setCip2000Code", |
1144 |
|
"CoreProgramInfo.setCip2010Code", |
1145 |
|
"CoreProgramInfo.setSelectiveEnrollmentCode", |
1146 |
|
"WhenConstraint.setValue" |
1147 |
|
}; |
1148 |
|
private static final String[] GETTER_METHODS_TO_SKIP = { |
1149 |
|
|
1150 |
|
"ValidationResultInfo.getWarning", |
1151 |
|
"ValidationResultInfo.getError", |
1152 |
|
|
1153 |
|
"CredentialProgramInfo.getDiplomaTitle", |
1154 |
|
|
1155 |
|
"CredentialProgramInfo.getType", |
1156 |
|
|
1157 |
|
"CredentialProgramInfo.getHegisCode", |
1158 |
|
"CredentialProgramInfo.getCip2000Code", |
1159 |
|
"CredentialProgramInfo.getCip2010Code", |
1160 |
|
"CredentialProgramInfo.getSelectiveEnrollmentCode", |
1161 |
|
"CoreProgramInfo.getDiplomaTitle", |
1162 |
|
|
1163 |
|
|
1164 |
|
|
1165 |
|
"CoreProgramInfo.getHegisCode", |
1166 |
|
"CoreProgramInfo.getCip2000Code", |
1167 |
|
"CoreProgramInfo.getCip2010Code", |
1168 |
|
"CoreProgramInfo.getSelectiveEnrollmentCode", |
1169 |
|
"WhenConstraint.getValue" |
1170 |
|
}; |
1171 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0.45 |
|
1172 |
0
|
private boolean isSetterMethodToProcess(JavaMethod method, String className) {... |
1173 |
0
|
if (!method.getName().startsWith("set")) { |
1174 |
0
|
return false; |
1175 |
|
} |
1176 |
0
|
if (method.getParameters().length != 1) { |
1177 |
0
|
return false; |
1178 |
|
} |
1179 |
0
|
if (method.isPrivate()) { |
1180 |
0
|
return false; |
1181 |
|
} |
1182 |
0
|
if (method.isProtected()) { |
1183 |
0
|
return false; |
1184 |
|
} |
1185 |
0
|
if (method.isStatic()) { |
1186 |
0
|
return false; |
1187 |
|
} |
1188 |
0
|
if (method.getParentClass().getPackageName().startsWith("java")) { |
1189 |
0
|
return false; |
1190 |
|
} |
1191 |
0
|
String fullName = className + "." + method.getName(); |
1192 |
0
|
for (String skip : SETTER_METHODS_TO_SKIP) { |
1193 |
0
|
if (skip.equals(fullName)) { |
1194 |
0
|
return false; |
1195 |
|
} |
1196 |
|
} |
1197 |
|
|
1198 |
|
|
1199 |
|
|
1200 |
|
|
1201 |
0
|
for (Annotation annotation : method.getAnnotations()) { |
1202 |
0
|
if (annotation.getType().getJavaClass().getName().equals("XmlTransient")) { |
1203 |
0
|
return false; |
1204 |
|
} |
1205 |
|
} |
1206 |
0
|
return true; |
1207 |
|
} |
1208 |
|
|
|
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 10 |
Complexity Density: 0.48 |
|
1209 |
0
|
private boolean isGetterMethodToProcess(JavaMethod method, String className) {... |
1210 |
0
|
if (!method.getName().startsWith("get")) { |
1211 |
0
|
if (!method.getName().startsWith("is")) { |
1212 |
0
|
return false; |
1213 |
|
} |
1214 |
|
} |
1215 |
0
|
if (method.getParameters().length != 0) { |
1216 |
0
|
return false; |
1217 |
|
} |
1218 |
0
|
if (method.isPrivate()) { |
1219 |
0
|
return false; |
1220 |
|
} |
1221 |
0
|
if (method.isProtected()) { |
1222 |
0
|
return false; |
1223 |
|
} |
1224 |
0
|
if (method.isStatic()) { |
1225 |
0
|
return false; |
1226 |
|
} |
1227 |
0
|
if (method.getParentClass().getPackageName().startsWith("java")) { |
1228 |
0
|
return false; |
1229 |
|
} |
1230 |
0
|
String fullName = className + "." + method.getName(); |
1231 |
0
|
for (String skip : GETTER_METHODS_TO_SKIP) { |
1232 |
0
|
if (skip.equals(fullName)) { |
1233 |
0
|
return false; |
1234 |
|
} |
1235 |
|
} |
1236 |
|
|
1237 |
|
|
1238 |
|
|
1239 |
|
|
1240 |
0
|
for (Annotation annotation : method.getAnnotations()) { |
1241 |
0
|
if (annotation.getType().getJavaClass().getName().equals("XmlTransient")) { |
1242 |
0
|
return false; |
1243 |
|
} |
1244 |
|
} |
1245 |
0
|
return true; |
1246 |
|
} |
1247 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1248 |
0
|
private String calcShortNameFromSetter(JavaMethod method) {... |
1249 |
0
|
return method.getName().substring(3); |
1250 |
|
} |
1251 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1252 |
0
|
private String calcShortNameFromGetter(JavaMethod method) {... |
1253 |
0
|
if (method.getName().startsWith("get")) { |
1254 |
0
|
return method.getName().substring(3); |
1255 |
|
} |
1256 |
0
|
if (method.getName().startsWith("is")) { |
1257 |
0
|
return method.getName().substring(2); |
1258 |
|
} |
1259 |
0
|
throw new IllegalArgumentException(method.getName() |
1260 |
|
+ " does not start with is or get"); |
1261 |
|
} |
1262 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1263 |
0
|
private String calcCardinality(JavaClass mainClass, JavaMethod getterMethod,... |
1264 |
|
JavaMethod setterMethod, JavaField beanField, String shortName) { |
1265 |
0
|
if (isReturnACollection(mainClass, getterMethod, setterMethod, beanField, shortName)) { |
1266 |
0
|
return "Many"; |
1267 |
|
} |
1268 |
0
|
return "One"; |
1269 |
|
} |
1270 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1271 |
0
|
private boolean isReturnACollection(JavaClass mainClass, JavaMethod getterMethod,... |
1272 |
|
JavaMethod setterMethod, JavaField beanField, String shortName) { |
1273 |
0
|
if (getterMethod != null) { |
1274 |
0
|
return isCollection(getterMethod.getReturnType()); |
1275 |
|
} |
1276 |
0
|
if (beanField != null) { |
1277 |
0
|
return isCollection(beanField.getType()); |
1278 |
|
} |
1279 |
|
|
1280 |
0
|
return false; |
1281 |
|
} |
1282 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1283 |
0
|
private boolean isCollection(Type type) {... |
1284 |
0
|
JavaClass javaClass = type.getJavaClass(); |
1285 |
0
|
return this.isCollection(javaClass); |
1286 |
|
} |
1287 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
1288 |
0
|
private boolean isCollection(JavaClass javaClass) {... |
1289 |
0
|
if (javaClass.getName().equals("LocalKeyList")) { |
1290 |
0
|
return true; |
1291 |
|
} |
1292 |
0
|
if (javaClass.getName().equals("MessageGroupKeyList")) { |
1293 |
0
|
return true; |
1294 |
|
} |
1295 |
0
|
if (javaClass.getName().equals(List.class.getSimpleName())) { |
1296 |
0
|
return true; |
1297 |
|
} |
1298 |
0
|
if (javaClass.getName().equals(ArrayList.class.getSimpleName())) { |
1299 |
0
|
return true; |
1300 |
|
} |
1301 |
0
|
if (javaClass.getName().equals(Collection.class.getSimpleName())) { |
1302 |
0
|
return true; |
1303 |
|
} |
1304 |
0
|
if (javaClass.getName().equals(Set.class.getSimpleName())) { |
1305 |
0
|
return true; |
1306 |
|
} |
1307 |
0
|
return false; |
1308 |
|
} |
1309 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
1310 |
0
|
private String calcType(JavaClass mainClass, JavaMethod getterMethod,... |
1311 |
|
JavaMethod setterMethod, JavaField beanField, String shortName) { |
1312 |
0
|
if (getterMethod != null) { |
1313 |
0
|
return calcTypeOfGetterMethodReturn(getterMethod); |
1314 |
|
} |
1315 |
0
|
if (beanField != null) { |
1316 |
0
|
Type type = beanField.getType(); |
1317 |
0
|
return calcType(type); |
1318 |
|
} |
1319 |
|
|
1320 |
0
|
return null; |
1321 |
|
} |
1322 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1323 |
0
|
private String calcTypeOfGetterMethodReturn(JavaMethod getterMethod) {... |
1324 |
0
|
Type type = getterMethod.getReturnType(); |
1325 |
0
|
return calcType(type); |
1326 |
|
} |
1327 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1328 |
0
|
private String calcTypeOfSetterMethodFirstParam(JavaMethod setterMethod) {... |
1329 |
0
|
JavaParameter param = setterMethod.getParameters()[0]; |
1330 |
0
|
return calcType(param); |
1331 |
|
} |
1332 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1333 |
0
|
private String calcType(JavaParameter parameter) {... |
1334 |
0
|
return calcType(parameter.getType()); |
1335 |
|
} |
1336 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1337 |
0
|
private String calcType(Type type) {... |
1338 |
0
|
if (type == null) { |
1339 |
0
|
return "void"; |
1340 |
|
} |
1341 |
0
|
if (isCollection(type.getJavaClass())) { |
1342 |
0
|
return calcType(calcRealJavaClass(type)) + "List"; |
1343 |
|
} |
1344 |
0
|
return calcType(calcRealJavaClass(type)); |
1345 |
|
} |
1346 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 14 |
Complexity Density: 0.54 |
|
1347 |
0
|
private String calcType(JavaClass javaClass) {... |
1348 |
0
|
if (javaClass.isEnum()) { |
1349 |
|
|
1350 |
0
|
if (javaClass.getName().equals("ErrorLevel")) { |
1351 |
0
|
return "Integer"; |
1352 |
|
} |
1353 |
0
|
if (javaClass.getName().equals("StatementOperatorTypeKey")) { |
1354 |
0
|
return "String"; |
1355 |
|
} |
1356 |
0
|
if (javaClass.getName().equals("WriteAccess")) { |
1357 |
0
|
return "String"; |
1358 |
|
} |
1359 |
0
|
if (javaClass.getName().equals("Widget")) { |
1360 |
0
|
return "String"; |
1361 |
|
} |
1362 |
0
|
if (javaClass.getName().equals("DataType")) { |
1363 |
0
|
return "String"; |
1364 |
|
} |
1365 |
0
|
if (javaClass.getName().equals("SortDirection")) { |
1366 |
0
|
return "String"; |
1367 |
|
} |
1368 |
0
|
if (javaClass.getName().equals("Usage")) { |
1369 |
0
|
return "String"; |
1370 |
|
} |
1371 |
0
|
if (javaClass.getName().equals("StatementOperator")) { |
1372 |
0
|
return "String"; |
1373 |
|
} |
1374 |
|
} |
1375 |
|
|
1376 |
0
|
if (javaClass.getName().equals(LOCALE_KEY_LIST)) { |
1377 |
0
|
return "StringList"; |
1378 |
|
} |
1379 |
0
|
if (javaClass.getName().equals(MESSAGE_GROUP_KEY_LIST)) { |
1380 |
0
|
return "StringList"; |
1381 |
|
} |
1382 |
|
|
1383 |
0
|
if (javaClass.getName().equals("java$util$Map")) { |
1384 |
0
|
return "Map<String, String>"; |
1385 |
|
} |
1386 |
0
|
if (javaClass.getName().equals("Map")) { |
1387 |
|
|
1388 |
0
|
return "Map<String, String>"; |
1389 |
|
} |
1390 |
0
|
return javaClass.getName(); |
1391 |
|
} |
1392 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1393 |
0
|
private JavaClass calcRealJavaClassOfGetterReturn(JavaMethod getterMethod) {... |
1394 |
0
|
if (getterMethod == null) { |
1395 |
0
|
return null; |
1396 |
|
} |
1397 |
0
|
Type type = getterMethod.getReturnType(); |
1398 |
0
|
return this.calcRealJavaClass(type); |
1399 |
|
} |
1400 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1401 |
0
|
private JavaClass calcRealJavaClassOfSetterFirstParam(JavaMethod setterMethod) {... |
1402 |
0
|
JavaParameter param = setterMethod.getParameters()[0]; |
1403 |
0
|
return this.calcRealJavaClass(param); |
1404 |
|
} |
1405 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1406 |
0
|
private JavaClass calcRealJavaClass(JavaParameter param) {... |
1407 |
0
|
Type type = param.getType(); |
1408 |
0
|
return calcRealJavaClass(type); |
1409 |
|
} |
1410 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
|
1411 |
0
|
private JavaClass calcRealJavaClass(Type type) {... |
1412 |
0
|
if (type == null) { |
1413 |
0
|
return null; |
1414 |
|
} |
1415 |
0
|
JavaClass javaClass = type.getJavaClass(); |
1416 |
0
|
if (javaClass.getName().equals(LOCALE_KEY_LIST)) { |
1417 |
0
|
return STRING_JAVA_CLASS; |
1418 |
|
} |
1419 |
0
|
if (javaClass.getName().equals(MESSAGE_GROUP_KEY_LIST)) { |
1420 |
0
|
return STRING_JAVA_CLASS; |
1421 |
|
} |
1422 |
0
|
if (!this.isCollection(javaClass)) { |
1423 |
0
|
return javaClass; |
1424 |
|
} |
1425 |
|
|
1426 |
|
|
1427 |
|
|
1428 |
|
|
1429 |
|
|
1430 |
|
|
1431 |
|
|
1432 |
0
|
Type t = type.getActualTypeArguments()[0]; |
1433 |
0
|
return t.getJavaClass(); |
1434 |
|
} |
1435 |
|
|
|
|
| 0% |
Uncovered Elements: 121 (121) |
Complexity: 31 |
Complexity Density: 0.51 |
|
1436 |
0
|
private boolean isComplex(JavaClass javaClass) {... |
1437 |
0
|
if (javaClass.isEnum()) { |
1438 |
0
|
return false; |
1439 |
|
} |
1440 |
0
|
if (javaClass.getName().equals(String.class.getSimpleName())) { |
1441 |
0
|
return false; |
1442 |
|
} |
1443 |
0
|
if (javaClass.getName().equals(Integer.class.getSimpleName())) { |
1444 |
0
|
return false; |
1445 |
|
} |
1446 |
0
|
if (javaClass.getName().equals(Date.class.getSimpleName())) { |
1447 |
0
|
return false; |
1448 |
|
} |
1449 |
0
|
if (javaClass.getName().equals(Long.class.getSimpleName())) { |
1450 |
0
|
return false; |
1451 |
|
} |
1452 |
0
|
if (javaClass.getName().equals(Boolean.class.getSimpleName())) { |
1453 |
0
|
return false; |
1454 |
|
} |
1455 |
0
|
if (javaClass.getName().equals(Double.class.getSimpleName())) { |
1456 |
0
|
return false; |
1457 |
|
} |
1458 |
0
|
if (javaClass.getName().equals(Float.class.getSimpleName())) { |
1459 |
0
|
return false; |
1460 |
|
} |
1461 |
0
|
if (javaClass.getName().equals(int.class.getSimpleName())) { |
1462 |
0
|
return false; |
1463 |
|
} |
1464 |
0
|
if (javaClass.getName().equals(long.class.getSimpleName())) { |
1465 |
0
|
return false; |
1466 |
|
} |
1467 |
0
|
if (javaClass.getName().equals(boolean.class.getSimpleName())) { |
1468 |
0
|
return false; |
1469 |
|
} |
1470 |
0
|
if (javaClass.getName().equals(double.class.getSimpleName())) { |
1471 |
0
|
return false; |
1472 |
|
} |
1473 |
0
|
if (javaClass.getName().equals(float.class.getSimpleName())) { |
1474 |
0
|
return false; |
1475 |
|
} |
1476 |
0
|
if (javaClass.getName().equals(Map.class.getSimpleName())) { |
1477 |
0
|
return false; |
1478 |
|
} |
1479 |
|
|
1480 |
0
|
if (javaClass.getName().equals(String.class.getName())) { |
1481 |
0
|
return false; |
1482 |
|
} |
1483 |
0
|
if (javaClass.getName().equals(Integer.class.getName())) { |
1484 |
0
|
return false; |
1485 |
|
} |
1486 |
0
|
if (javaClass.getName().equals(Date.class.getName())) { |
1487 |
0
|
return false; |
1488 |
|
} |
1489 |
0
|
if (javaClass.getName().equals(Long.class.getName())) { |
1490 |
0
|
return false; |
1491 |
|
} |
1492 |
0
|
if (javaClass.getName().equals(Boolean.class.getName())) { |
1493 |
0
|
return false; |
1494 |
|
} |
1495 |
0
|
if (javaClass.getName().equals(Double.class.getName())) { |
1496 |
0
|
return false; |
1497 |
|
} |
1498 |
0
|
if (javaClass.getName().equals(Float.class.getName())) { |
1499 |
0
|
return false; |
1500 |
|
} |
1501 |
0
|
if (javaClass.getName().equals(int.class.getName())) { |
1502 |
0
|
return false; |
1503 |
|
} |
1504 |
0
|
if (javaClass.getName().equals(long.class.getName())) { |
1505 |
0
|
return false; |
1506 |
|
} |
1507 |
0
|
if (javaClass.getName().equals(boolean.class.getName())) { |
1508 |
0
|
return false; |
1509 |
|
} |
1510 |
0
|
if (javaClass.getName().equals(double.class.getName())) { |
1511 |
0
|
return false; |
1512 |
|
} |
1513 |
0
|
if (javaClass.getName().equals(float.class.getName())) { |
1514 |
0
|
return false; |
1515 |
|
} |
1516 |
0
|
if (javaClass.getName().equals(Map.class.getName())) { |
1517 |
0
|
return false; |
1518 |
|
} |
1519 |
0
|
if (javaClass.getName().equals(LOCALE_KEY_LIST)) { |
1520 |
0
|
return false; |
1521 |
|
} |
1522 |
0
|
if (javaClass.getName().equals(MESSAGE_GROUP_KEY_LIST)) { |
1523 |
0
|
return false; |
1524 |
|
} |
1525 |
0
|
if (javaClass.getName().equals("java$util$Map")) { |
1526 |
0
|
return false; |
1527 |
|
} |
1528 |
0
|
return true; |
1529 |
|
} |
1530 |
|
} |