| 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.DocletTag; |
| 21 | |
import com.thoughtworks.qdox.model.JavaClass; |
| 22 | |
import com.thoughtworks.qdox.model.JavaField; |
| 23 | |
import com.thoughtworks.qdox.model.JavaMethod; |
| 24 | |
import com.thoughtworks.qdox.model.JavaParameter; |
| 25 | |
import com.thoughtworks.qdox.model.Type; |
| 26 | |
import java.io.File; |
| 27 | |
import java.util.ArrayList; |
| 28 | |
import java.util.Arrays; |
| 29 | |
import java.util.Collection; |
| 30 | |
import java.util.Collections; |
| 31 | |
import java.util.Date; |
| 32 | |
import java.util.LinkedHashMap; |
| 33 | |
import java.util.LinkedHashSet; |
| 34 | |
import java.util.List; |
| 35 | |
import java.util.Map; |
| 36 | |
import java.util.Set; |
| 37 | |
|
| 38 | |
import org.kuali.student.contract.model.MessageStructure; |
| 39 | |
import org.kuali.student.contract.model.Service; |
| 40 | |
import org.kuali.student.contract.model.ServiceContractModel; |
| 41 | |
import org.kuali.student.contract.model.ServiceMethod; |
| 42 | |
import org.kuali.student.contract.model.ServiceMethodError; |
| 43 | |
import org.kuali.student.contract.model.ServiceMethodParameter; |
| 44 | |
import org.kuali.student.contract.model.ServiceMethodReturnValue; |
| 45 | |
import org.kuali.student.contract.model.XmlType; |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public class ServiceContractModelQDoxLoader implements |
| 52 | |
ServiceContractModel |
| 53 | |
{ |
| 54 | |
|
| 55 | |
private static final String LOCALE_KEY_LIST = "LocaleKeyList"; |
| 56 | |
private static final String MESSAGE_GROUP_KEY_LIST = "MessageGroupKeyList"; |
| 57 | 0 | private static final JavaClass STRING_JAVA_CLASS = new JavaClass ( |
| 58 | |
"java.lang.String"); |
| 59 | 0 | private List<String> sourceDirectories = null; |
| 60 | 0 | private List<Service> services = null; |
| 61 | 0 | private List<ServiceMethod> serviceMethods = null; |
| 62 | 0 | private Map<String, XmlType> xmlTypeMap = null; |
| 63 | |
private List<MessageStructure> messageStructures; |
| 64 | |
|
| 65 | |
public ServiceContractModelQDoxLoader (List<String> sourceDirectories) |
| 66 | 0 | { |
| 67 | 0 | this.sourceDirectories = sourceDirectories; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
@Override |
| 71 | |
public List<ServiceMethod> getServiceMethods () |
| 72 | |
{ |
| 73 | 0 | if (this.serviceMethods == null) |
| 74 | |
{ |
| 75 | 0 | this.parse (); |
| 76 | |
} |
| 77 | 0 | return this.serviceMethods; |
| 78 | |
} |
| 79 | |
|
| 80 | |
@Override |
| 81 | |
public List<String> getSourceNames () |
| 82 | |
{ |
| 83 | 0 | List<String> list = new ArrayList (this.sourceDirectories.size ()); |
| 84 | 0 | for (String javaFile : this.sourceDirectories) |
| 85 | |
{ |
| 86 | 0 | list.add (javaFile); |
| 87 | |
} |
| 88 | 0 | return list; |
| 89 | |
} |
| 90 | |
|
| 91 | |
@Override |
| 92 | |
public List<Service> getServices () |
| 93 | |
{ |
| 94 | 0 | if (services == null) |
| 95 | |
{ |
| 96 | 0 | this.parse (); |
| 97 | |
} |
| 98 | 0 | return services; |
| 99 | |
} |
| 100 | |
|
| 101 | |
@Override |
| 102 | |
public List<XmlType> getXmlTypes () |
| 103 | |
{ |
| 104 | 0 | if (xmlTypeMap == null) |
| 105 | |
{ |
| 106 | 0 | this.parse (); |
| 107 | |
} |
| 108 | 0 | return new ArrayList (xmlTypeMap.values ()); |
| 109 | |
} |
| 110 | |
|
| 111 | |
@Override |
| 112 | |
public List<MessageStructure> getMessageStructures () |
| 113 | |
{ |
| 114 | 0 | if (messageStructures == null) |
| 115 | |
{ |
| 116 | 0 | this.parse (); |
| 117 | |
} |
| 118 | 0 | return this.messageStructures; |
| 119 | |
} |
| 120 | |
|
| 121 | |
private String dump (DocletTag tag) |
| 122 | |
{ |
| 123 | 0 | if (tag == null) |
| 124 | |
{ |
| 125 | 0 | return null; |
| 126 | |
} |
| 127 | 0 | StringBuilder bldr = new StringBuilder (); |
| 128 | 0 | bldr.append (tag.getName ()); |
| 129 | 0 | bldr.append ("="); |
| 130 | 0 | if (tag.getNamedParameterMap () == null |
| 131 | |
|| tag.getNamedParameterMap ().isEmpty ()) |
| 132 | |
{ |
| 133 | 0 | bldr.append (tag.getValue ()); |
| 134 | |
} |
| 135 | |
else |
| 136 | |
{ |
| 137 | 0 | for (Object key : tag.getNamedParameterMap ().keySet ()) |
| 138 | |
{ |
| 139 | 0 | Object value = tag.getNamedParameterMap ().get (key); |
| 140 | 0 | bldr.append ("("); |
| 141 | 0 | bldr.append (key); |
| 142 | 0 | bldr.append ("="); |
| 143 | 0 | bldr.append (value); |
| 144 | 0 | bldr.append (")"); |
| 145 | 0 | } |
| 146 | |
} |
| 147 | 0 | return bldr.toString (); |
| 148 | |
} |
| 149 | |
|
| 150 | |
private void parse () |
| 151 | |
{ |
| 152 | |
|
| 153 | 0 | services = new ArrayList (); |
| 154 | 0 | serviceMethods = new ArrayList (); |
| 155 | 0 | xmlTypeMap = new LinkedHashMap (); |
| 156 | 0 | messageStructures = new ArrayList (); |
| 157 | 0 | JavaDocBuilder builder = new JavaDocBuilder (); |
| 158 | 0 | for (String sourceDirectory : sourceDirectories) |
| 159 | |
{ |
| 160 | 0 | builder.addSourceTree (new File (sourceDirectory)); |
| 161 | |
} |
| 162 | 0 | List<JavaClass> sortedClasses = Arrays.asList (builder.getClasses ()); |
| 163 | 0 | Collections.sort (sortedClasses); |
| 164 | 0 | for (JavaClass javaClass : sortedClasses) |
| 165 | |
{ |
| 166 | 0 | if ( ! this.isServiceToProcess (javaClass)) |
| 167 | |
{ |
| 168 | 0 | continue; |
| 169 | |
} |
| 170 | |
|
| 171 | 0 | Service service = new Service (); |
| 172 | 0 | services.add (service); |
| 173 | 0 | service.setKey (javaClass.getName ().substring (0, javaClass.getName ().length () |
| 174 | |
- "Service".length ())); |
| 175 | 0 | service.setName (javaClass.getName ()); |
| 176 | 0 | service.setComments (javaClass.getComment ()); |
| 177 | 0 | service.setUrl (this.calcServiceUrl (javaClass)); |
| 178 | 0 | service.setVersion ("???"); |
| 179 | 0 | service.setStatus ("???"); |
| 180 | 0 | service.setIncludedServices (calcIncludedServices (javaClass)); |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | 0 | for (JavaMethod javaMethod : javaClass.getMethods ()) |
| 189 | |
{ |
| 190 | |
|
| 191 | 0 | ServiceMethod serviceMethod = new ServiceMethod (); |
| 192 | 0 | serviceMethods.add (serviceMethod); |
| 193 | 0 | serviceMethod.setService (service.getKey ()); |
| 194 | 0 | serviceMethod.setName (javaMethod.getName ()); |
| 195 | 0 | serviceMethod.setDescription (calcMissing (javaMethod.getComment ())); |
| 196 | 0 | serviceMethod.setParameters (new ArrayList ()); |
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | 0 | for (JavaParameter parameter : javaMethod.getParameters ()) |
| 206 | |
{ |
| 207 | 0 | ServiceMethodParameter param = new ServiceMethodParameter (); |
| 208 | 0 | serviceMethod.getParameters ().add (param); |
| 209 | 0 | param.setName (parameter.getName ()); |
| 210 | 0 | param.setType (calcType (parameter.getType ())); |
| 211 | 0 | param.setDescription (calcMissing ( |
| 212 | |
calcParameterDescription (javaMethod, |
| 213 | |
param.getName ()))); |
| 214 | 0 | addXmlTypeAndMessageStructure (calcRealJavaClass (parameter.getType ()), |
| 215 | |
serviceMethod.getService ()); |
| 216 | |
} |
| 217 | |
|
| 218 | 0 | serviceMethod.setErrors (new ArrayList ()); |
| 219 | 0 | for (Type exception : javaMethod.getExceptions ()) |
| 220 | |
{ |
| 221 | 0 | ServiceMethodError error = new ServiceMethodError (); |
| 222 | 0 | error.setType (this.calcType (exception.getJavaClass ())); |
| 223 | 0 | error.setDescription (calcMissing ( |
| 224 | |
calcExceptionDescription (javaMethod, |
| 225 | |
error.getType ()))); |
| 226 | 0 | error.setPackageName (exception.getJavaClass ().getPackageName ()); |
| 227 | 0 | error.setClassName (exception.getJavaClass ().getName ()); |
| 228 | 0 | serviceMethod.getErrors ().add (error); |
| 229 | |
} |
| 230 | |
|
| 231 | 0 | ServiceMethodReturnValue rv = new ServiceMethodReturnValue (); |
| 232 | 0 | serviceMethod.setReturnValue (rv); |
| 233 | 0 | rv.setType (calcType (javaMethod.getReturnType ())); |
| 234 | 0 | rv.setDescription (calcMissing (this.calcReturnDescription (javaMethod))); |
| 235 | 0 | addXmlTypeAndMessageStructure (calcRealJavaClass ( |
| 236 | |
javaMethod.getReturnType ()), |
| 237 | |
serviceMethod.getService ()); |
| 238 | |
} |
| 239 | 0 | } |
| 240 | 0 | } |
| 241 | |
|
| 242 | |
private boolean isServiceToProcess (JavaClass javaClass) |
| 243 | |
{ |
| 244 | |
|
| 245 | 0 | if ( ! javaClass.getName ().endsWith ("Service")) |
| 246 | |
{ |
| 247 | 0 | return false; |
| 248 | |
} |
| 249 | 0 | if (javaClass.getPackageName ().contains (".old.")) |
| 250 | |
{ |
| 251 | |
|
| 252 | 0 | return false; |
| 253 | |
} |
| 254 | 0 | if (javaClass.getPackageName ().endsWith (".old")) |
| 255 | |
{ |
| 256 | 0 | return false; |
| 257 | |
} |
| 258 | 0 | for (Annotation annotation : javaClass.getAnnotations ()) |
| 259 | |
{ |
| 260 | |
|
| 261 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ("WebService")) |
| 262 | |
{ |
| 263 | |
|
| 264 | |
|
| 265 | 0 | return true; |
| 266 | |
} |
| 267 | |
} |
| 268 | |
|
| 269 | |
|
| 270 | 0 | return false; |
| 271 | |
} |
| 272 | |
|
| 273 | |
private String calcIncludedServices (JavaClass javaClass) |
| 274 | |
{ |
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
|
| 283 | |
|
| 284 | |
|
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
|
| 307 | |
|
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
|
| 323 | |
|
| 324 | |
|
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | 0 | return null; |
| 342 | |
} |
| 343 | |
|
| 344 | |
private String calcParameterDescription (JavaMethod method, |
| 345 | |
String parameterName) |
| 346 | |
{ |
| 347 | 0 | for (DocletTag tag : method.getTags ()) |
| 348 | |
{ |
| 349 | 0 | if (tag.getName ().equals ("param")) |
| 350 | |
{ |
| 351 | 0 | if (tag.getValue ().startsWith (parameterName + " ")) |
| 352 | |
{ |
| 353 | 0 | return tag.getValue ().substring (parameterName.length () + 1); |
| 354 | |
} |
| 355 | |
} |
| 356 | |
} |
| 357 | 0 | return null; |
| 358 | |
} |
| 359 | |
|
| 360 | |
private String calcExceptionDescription (JavaMethod serviceMethod, |
| 361 | |
String exceptionType) |
| 362 | |
{ |
| 363 | 0 | for (DocletTag tag : serviceMethod.getTags ()) |
| 364 | |
{ |
| 365 | 0 | if (tag.getName ().equals ("throws")) |
| 366 | |
{ |
| 367 | 0 | if (tag.getValue ().startsWith (exceptionType + " ")) |
| 368 | |
{ |
| 369 | 0 | return tag.getValue ().substring (exceptionType.length () + 1); |
| 370 | |
} |
| 371 | |
} |
| 372 | |
} |
| 373 | 0 | return null; |
| 374 | |
} |
| 375 | |
|
| 376 | |
private String calcReturnDescription (JavaMethod serviceMethod) |
| 377 | |
{ |
| 378 | 0 | for (DocletTag tag : serviceMethod.getTags ()) |
| 379 | |
{ |
| 380 | 0 | if (tag.getName ().equals ("return")) |
| 381 | |
{ |
| 382 | 0 | return tag.getValue (); |
| 383 | |
} |
| 384 | |
} |
| 385 | 0 | return null; |
| 386 | |
} |
| 387 | |
|
| 388 | |
private String calcServiceUrl (JavaClass serviceClass) |
| 389 | |
{ |
| 390 | 0 | for (DocletTag tag : serviceClass.getTags ()) |
| 391 | |
{ |
| 392 | 0 | if (tag.getName ().equals ("See")) |
| 393 | |
{ |
| 394 | 0 | return tag.getValue (); |
| 395 | |
} |
| 396 | |
} |
| 397 | 0 | return null; |
| 398 | |
} |
| 399 | |
|
| 400 | |
private void addXmlTypeAndMessageStructure (JavaClass messageStructureJavaClass, |
| 401 | |
String serviceKey) |
| 402 | |
{ |
| 403 | 0 | String name = calcType (messageStructureJavaClass); |
| 404 | 0 | XmlType xmlType = xmlTypeMap.get (name); |
| 405 | 0 | if (xmlType == null) |
| 406 | |
{ |
| 407 | 0 | xmlType = new XmlType (); |
| 408 | 0 | xmlTypeMap.put (name, xmlType); |
| 409 | 0 | xmlType.setName (name); |
| 410 | 0 | xmlType.setDesc (messageStructureJavaClass.getComment ()); |
| 411 | 0 | xmlType.setService (serviceKey); |
| 412 | 0 | xmlType.setVersion ("???"); |
| 413 | 0 | xmlType.setPrimitive (calcPrimitive (messageStructureJavaClass)); |
| 414 | 0 | if (xmlType.getPrimitive ().equals (XmlType.COMPLEX)) |
| 415 | |
{ |
| 416 | 0 | addMessageStructure (messageStructureJavaClass, serviceKey); |
| 417 | |
} |
| 418 | |
} |
| 419 | |
else |
| 420 | |
{ |
| 421 | 0 | addServiceToList (xmlType, serviceKey); |
| 422 | |
} |
| 423 | 0 | } |
| 424 | |
|
| 425 | |
private String calcPrimitive (JavaClass javaClass) |
| 426 | |
{ |
| 427 | 0 | if (this.isComplex (javaClass)) |
| 428 | |
{ |
| 429 | 0 | return XmlType.COMPLEX; |
| 430 | |
} |
| 431 | 0 | return "Primitive"; |
| 432 | |
} |
| 433 | |
|
| 434 | |
private Set<String> getShortNames (JavaClass messageStructureJavaClass) |
| 435 | |
{ |
| 436 | 0 | Set<String> fields = new LinkedHashSet (); |
| 437 | 0 | for (JavaMethod method : messageStructureJavaClass.getMethods (true)) |
| 438 | |
{ |
| 439 | 0 | if (isSetterMethodToProcess (method, messageStructureJavaClass.getName ())) |
| 440 | |
{ |
| 441 | 0 | String shortName = this.calcShortNameFromSetter (method); |
| 442 | 0 | fields.add (shortName); |
| 443 | 0 | continue; |
| 444 | |
} |
| 445 | 0 | if (isGetterMethodToProcess (method, messageStructureJavaClass.getName ())) |
| 446 | |
{ |
| 447 | 0 | String shortName = this.calcShortNameFromGetter (method); |
| 448 | 0 | fields.add (shortName); |
| 449 | 0 | continue; |
| 450 | |
} |
| 451 | |
} |
| 452 | 0 | return fields; |
| 453 | |
} |
| 454 | |
|
| 455 | |
private void addMessageStructure (JavaClass messageStructureJavaClass, |
| 456 | |
String serviceKey) |
| 457 | |
{ |
| 458 | 0 | Set<JavaClass> subObjectsToAdd = new LinkedHashSet (); |
| 459 | 0 | for (String shortName : this.getShortNames (messageStructureJavaClass)) |
| 460 | |
{ |
| 461 | 0 | JavaMethod setterMethod = findSetterMethod (messageStructureJavaClass, |
| 462 | |
shortName); |
| 463 | 0 | JavaMethod getterMethod = findGetterMethod (messageStructureJavaClass, |
| 464 | |
shortName); |
| 465 | 0 | if (getterMethod == null) |
| 466 | |
{ |
| 467 | 0 | throw new IllegalArgumentException ("shortName has no corresponding getter method: " |
| 468 | |
+ messageStructureJavaClass.getName () |
| 469 | |
+ "." + shortName); |
| 470 | |
} |
| 471 | 0 | JavaField beanField = this.findField (messageStructureJavaClass, |
| 472 | |
shortName, setterMethod); |
| 473 | 0 | if (beanField == null) |
| 474 | |
{ |
| 475 | 0 | String accessorType = getAccessorType (getterMethod); |
| 476 | 0 | if ("XmlAccessType.FIELD".equals (accessorType)) |
| 477 | |
{ |
| 478 | 0 | throw new IllegalArgumentException ("Setter method has no corresponding bean field: " |
| 479 | |
+ messageStructureJavaClass.getName () |
| 480 | |
+ "." + getterMethod.getName ()); |
| 481 | |
} |
| 482 | |
} |
| 483 | |
|
| 484 | |
|
| 485 | 0 | if (beanField != null) |
| 486 | |
{ |
| 487 | 0 | for (Annotation annotation : beanField.getAnnotations ()) |
| 488 | |
{ |
| 489 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ("XmlAttribute")) |
| 490 | |
{ |
| 491 | 0 | Object nameValue = annotation.getNamedParameter ("name"); |
| 492 | 0 | if (nameValue != null) |
| 493 | |
{ |
| 494 | 0 | shortName = stripQuotes (nameValue.toString ()); |
| 495 | |
} |
| 496 | |
} |
| 497 | |
} |
| 498 | |
} |
| 499 | 0 | MessageStructure ms = new MessageStructure (); |
| 500 | 0 | messageStructures.add (ms); |
| 501 | 0 | ms.setXmlObject (messageStructureJavaClass.getName ()); |
| 502 | 0 | ms.setShortName (shortName); |
| 503 | 0 | ms.setId (ms.getXmlObject () + "." + ms.getShortName ()); |
| 504 | 0 | ms.setName ("????"); |
| 505 | 0 | ms.setType (calcTypeOfGetterMethodReturn (getterMethod)); |
| 506 | 0 | if (ms.getType ().equals ("Object")) |
| 507 | |
{ |
| 508 | 0 | System.out.println ("WARNING " + ms.getId () |
| 509 | |
+ " has Object as it's type ==> Changing to String"); |
| 510 | 0 | ms.setType ("String"); |
| 511 | |
} |
| 512 | 0 | else if (ms.getType ().equals ("ObjectList")) |
| 513 | |
{ |
| 514 | 0 | System.out.println ("WARNING " + |
| 515 | |
ms.getId () |
| 516 | |
+ " has a list of Objects as it's type ==> Changing to List of String"); |
| 517 | 0 | ms.setType ("StringList"); |
| 518 | |
} |
| 519 | 0 | ms.setXmlAttribute (this.calcXmlAttribute (beanField)); |
| 520 | 0 | ms.setOptional ("???"); |
| 521 | 0 | ms.setCardinality (this.calcCardinalityOfReturn (getterMethod)); |
| 522 | 0 | ms.setDescription (calcMissing (calcDescription (getterMethod, setterMethod, |
| 523 | |
beanField))); |
| 524 | 0 | ms.setFeedback ("???"); |
| 525 | 0 | ms.setStatus ("???"); |
| 526 | 0 | JavaClass subObjToAdd = this.calcRealJavaClassOfGetterReturn (getterMethod); |
| 527 | 0 | if ( ! subObjToAdd.isEnum ()) |
| 528 | |
{ |
| 529 | 0 | if ( ! subObjToAdd.getName ().equals ("Object")) |
| 530 | |
{ |
| 531 | 0 | if ( ! subObjToAdd.getName ().equals ("LocaleKeyList")) |
| 532 | |
{ |
| 533 | 0 | if ( ! subObjToAdd.getName ().equals ("MessageGroupKeyList")) |
| 534 | |
{ |
| 535 | 0 | subObjectsToAdd.add (subObjToAdd); |
| 536 | |
} |
| 537 | |
} |
| 538 | |
} |
| 539 | |
} |
| 540 | 0 | } |
| 541 | |
|
| 542 | 0 | for (JavaClass subObjectToAdd : subObjectsToAdd) |
| 543 | |
{ |
| 544 | 0 | XmlType xmlType = xmlTypeMap.get (calcType (subObjectToAdd)); |
| 545 | 0 | if (xmlType == null) |
| 546 | |
{ |
| 547 | 0 | addXmlTypeAndMessageStructure (subObjectToAdd, serviceKey); |
| 548 | |
} |
| 549 | |
else |
| 550 | |
{ |
| 551 | 0 | addServiceToList (xmlType, serviceKey); |
| 552 | |
} |
| 553 | 0 | } |
| 554 | 0 | return; |
| 555 | |
} |
| 556 | |
|
| 557 | |
private String calcDescription (JavaMethod getterMethod, |
| 558 | |
JavaMethod setterMethod, JavaField beanField) |
| 559 | |
{ |
| 560 | 0 | String desc = null; |
| 561 | 0 | desc = getterMethod.getComment (); |
| 562 | 0 | if (isDescriptionOk (desc)) |
| 563 | |
{ |
| 564 | 0 | return desc; |
| 565 | |
} |
| 566 | 0 | if (setterMethod != null) |
| 567 | |
{ |
| 568 | 0 | desc = setterMethod.getComment (); |
| 569 | 0 | if (isDescriptionOk (desc)) |
| 570 | |
{ |
| 571 | 0 | return desc; |
| 572 | |
} |
| 573 | |
} |
| 574 | 0 | if (beanField != null) |
| 575 | |
{ |
| 576 | 0 | desc = beanField.getComment (); |
| 577 | 0 | if (isDescriptionOk (desc)) |
| 578 | |
{ |
| 579 | 0 | return desc; |
| 580 | |
} |
| 581 | |
} |
| 582 | 0 | desc = calcDescriptionRecursively (getterMethod); |
| 583 | 0 | if (isDescriptionOk (desc)) |
| 584 | |
{ |
| 585 | 0 | return desc; |
| 586 | |
} |
| 587 | 0 | desc = calcDescriptionRecursively (setterMethod); |
| 588 | 0 | if (isDescriptionOk (desc)) |
| 589 | |
{ |
| 590 | 0 | return desc; |
| 591 | |
} |
| 592 | 0 | return null; |
| 593 | |
} |
| 594 | |
|
| 595 | |
private String calcDescriptionRecursively (JavaMethod method) |
| 596 | |
{ |
| 597 | 0 | if (method == null) |
| 598 | |
{ |
| 599 | 0 | return null; |
| 600 | |
} |
| 601 | 0 | String desc = method.getComment (); |
| 602 | 0 | if (isDescriptionOk (desc)) |
| 603 | |
{ |
| 604 | 0 | return desc; |
| 605 | |
} |
| 606 | 0 | desc = calcDescriptionRecursively (findInterfaceMethod (method)); |
| 607 | 0 | if (isDescriptionOk (desc)) |
| 608 | |
{ |
| 609 | 0 | return desc; |
| 610 | |
} |
| 611 | 0 | desc = calcDescriptionRecursively (findSuperMethod (method)); |
| 612 | 0 | if (isDescriptionOk (desc)) |
| 613 | |
{ |
| 614 | 0 | return desc; |
| 615 | |
} |
| 616 | 0 | return null; |
| 617 | |
} |
| 618 | |
|
| 619 | |
private JavaMethod findInterfaceMethod (JavaMethod method) |
| 620 | |
{ |
| 621 | |
for (JavaClass interfaceClass : |
| 622 | 0 | method.getParentClass ().getImplementedInterfaces ()) |
| 623 | |
{ |
| 624 | 0 | for (JavaMethod superMethod : interfaceClass.getMethods (true)) |
| 625 | |
{ |
| 626 | 0 | if (method.getCallSignature ().equals (superMethod.getCallSignature ())) |
| 627 | |
{ |
| 628 | 0 | return superMethod; |
| 629 | |
} |
| 630 | |
} |
| 631 | |
} |
| 632 | 0 | return null; |
| 633 | |
} |
| 634 | |
|
| 635 | |
private JavaMethod findSuperMethod (JavaMethod method) |
| 636 | |
{ |
| 637 | |
|
| 638 | 0 | for (JavaMethod superMethod : method.getParentClass ().getMethods (true)) |
| 639 | |
{ |
| 640 | 0 | if (method.equals (superMethod)) |
| 641 | |
{ |
| 642 | 0 | continue; |
| 643 | |
} |
| 644 | 0 | if (method.getCallSignature ().equals (superMethod.getCallSignature ())) |
| 645 | |
{ |
| 646 | 0 | return superMethod; |
| 647 | |
} |
| 648 | |
} |
| 649 | |
|
| 650 | |
|
| 651 | 0 | return null; |
| 652 | |
} |
| 653 | |
|
| 654 | |
private boolean isDescriptionOk (String desc) |
| 655 | |
{ |
| 656 | 0 | if (desc == null) |
| 657 | |
{ |
| 658 | 0 | return false; |
| 659 | |
} |
| 660 | 0 | if (desc.trim ().isEmpty ()) |
| 661 | |
{ |
| 662 | 0 | return false; |
| 663 | |
} |
| 664 | 0 | if (desc.contains ("@inheritDoc")) |
| 665 | |
{ |
| 666 | 0 | return false; |
| 667 | |
} |
| 668 | 0 | return true; |
| 669 | |
} |
| 670 | |
|
| 671 | |
private String getAccessorType (JavaMethod method) |
| 672 | |
{ |
| 673 | 0 | String accessorType = getAccessorType (method.getAnnotations ()); |
| 674 | 0 | if (accessorType != null) |
| 675 | |
{ |
| 676 | 0 | return accessorType; |
| 677 | |
} |
| 678 | 0 | accessorType = getAccessorType (method.getParentClass ().getAnnotations ()); |
| 679 | 0 | return accessorType; |
| 680 | |
} |
| 681 | |
|
| 682 | |
private String getAccessorType (Annotation[] annotations) |
| 683 | |
{ |
| 684 | 0 | for (Annotation annotation : annotations) |
| 685 | |
{ |
| 686 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ( |
| 687 | |
"XmlAccessorType")) |
| 688 | |
{ |
| 689 | |
|
| 690 | |
|
| 691 | 0 | return annotation.getParameterValue ().toString (); |
| 692 | |
} |
| 693 | |
} |
| 694 | 0 | return null; |
| 695 | |
} |
| 696 | |
|
| 697 | |
private String stripQuotes (String str) |
| 698 | |
{ |
| 699 | 0 | if (str.startsWith ("\"")) |
| 700 | |
{ |
| 701 | 0 | str = str.substring (1); |
| 702 | |
} |
| 703 | 0 | if (str.endsWith ("\"")) |
| 704 | |
{ |
| 705 | 0 | str = str.substring (0, str.length () - 1); |
| 706 | |
} |
| 707 | 0 | return str; |
| 708 | |
} |
| 709 | |
|
| 710 | |
private String calcMissing (String str) |
| 711 | |
{ |
| 712 | 0 | if (str == null) |
| 713 | |
{ |
| 714 | 0 | return "???"; |
| 715 | |
} |
| 716 | 0 | if (str.trim ().isEmpty ()) |
| 717 | |
{ |
| 718 | 0 | return "???"; |
| 719 | |
} |
| 720 | 0 | return str; |
| 721 | |
} |
| 722 | |
|
| 723 | |
private void addServiceToList (XmlType xmlType, String serviceKey) |
| 724 | |
{ |
| 725 | 0 | if ( ! xmlType.getService ().contains (serviceKey)) |
| 726 | |
{ |
| 727 | 0 | xmlType.setService (xmlType.getService () + ", " + serviceKey); |
| 728 | |
} |
| 729 | 0 | } |
| 730 | |
|
| 731 | |
private String calcXmlAttribute (JavaField beanField) |
| 732 | |
{ |
| 733 | 0 | if (beanField == null) |
| 734 | |
{ |
| 735 | |
|
| 736 | 0 | return "No"; |
| 737 | |
} |
| 738 | 0 | for (Annotation annotation : beanField.getAnnotations ()) |
| 739 | |
{ |
| 740 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ("XmlAttribute")) |
| 741 | |
{ |
| 742 | 0 | return "Yes"; |
| 743 | |
} |
| 744 | |
} |
| 745 | 0 | return "No"; |
| 746 | |
} |
| 747 | |
|
| 748 | |
private JavaField findField (JavaClass javaClass, String shortName, |
| 749 | |
JavaMethod setterMethod) |
| 750 | |
{ |
| 751 | 0 | JavaField field = findField (javaClass, shortName); |
| 752 | 0 | if (field != null) |
| 753 | |
{ |
| 754 | 0 | return field; |
| 755 | |
} |
| 756 | 0 | if (setterMethod != null) |
| 757 | |
{ |
| 758 | 0 | String paramName = setterMethod.getParameters ()[0].getName (); |
| 759 | 0 | if (paramName.equalsIgnoreCase (shortName)) |
| 760 | |
{ |
| 761 | 0 | return null; |
| 762 | |
} |
| 763 | 0 | return findField (javaClass, paramName); |
| 764 | |
} |
| 765 | 0 | return null; |
| 766 | |
} |
| 767 | |
|
| 768 | |
private JavaField findField (JavaClass javaClass, String name) |
| 769 | |
{ |
| 770 | 0 | if (name == null) |
| 771 | |
{ |
| 772 | 0 | return null; |
| 773 | |
} |
| 774 | 0 | for (JavaField field : javaClass.getFields ()) |
| 775 | |
{ |
| 776 | 0 | if (field.getName ().equalsIgnoreCase (name)) |
| 777 | |
{ |
| 778 | 0 | return field; |
| 779 | |
} |
| 780 | |
|
| 781 | 0 | if (field.getName ().equals ("is" + name)) |
| 782 | |
{ |
| 783 | 0 | return field; |
| 784 | |
} |
| 785 | |
} |
| 786 | 0 | JavaClass superClass = javaClass.getSuperJavaClass (); |
| 787 | 0 | if (superClass == null) |
| 788 | |
{ |
| 789 | 0 | return null; |
| 790 | |
} |
| 791 | 0 | return findField (superClass, name); |
| 792 | |
} |
| 793 | |
|
| 794 | |
private JavaMethod findGetterMethod (JavaClass msClass, String shortName) |
| 795 | |
{ |
| 796 | 0 | for (JavaMethod method : msClass.getMethods (true)) |
| 797 | |
{ |
| 798 | 0 | if (method.getName ().equals ("get" + shortName)) |
| 799 | |
{ |
| 800 | 0 | return method; |
| 801 | |
} |
| 802 | |
|
| 803 | 0 | if (method.getName ().equals ("is" + shortName)) |
| 804 | |
{ |
| 805 | 0 | return method; |
| 806 | |
} |
| 807 | |
|
| 808 | 0 | if (method.getName ().equals ("getInState") && shortName.equals ( |
| 809 | |
"InStateFlag")) |
| 810 | |
{ |
| 811 | 0 | return method; |
| 812 | |
} |
| 813 | |
} |
| 814 | 0 | return null; |
| 815 | |
} |
| 816 | |
|
| 817 | |
private JavaMethod findSetterMethod (JavaClass msClass, String shortName) |
| 818 | |
{ |
| 819 | 0 | for (JavaMethod method : msClass.getMethods (true)) |
| 820 | |
{ |
| 821 | 0 | if (method.getName ().equals ("set" + shortName)) |
| 822 | |
{ |
| 823 | 0 | return method; |
| 824 | |
} |
| 825 | |
|
| 826 | 0 | if (method.getName ().equals ("setIs" + shortName)) |
| 827 | |
{ |
| 828 | 0 | return method; |
| 829 | |
} |
| 830 | |
|
| 831 | 0 | if (method.getName ().equals ("setInStateFlag") && shortName.equals ( |
| 832 | |
"InState")) |
| 833 | |
{ |
| 834 | 0 | return method; |
| 835 | |
} |
| 836 | |
} |
| 837 | 0 | return null; |
| 838 | |
} |
| 839 | 0 | private static final String[] SETTER_METHODS_TO_SKIP = |
| 840 | |
{ |
| 841 | |
|
| 842 | |
"ValidationResultInfo.setWarning", |
| 843 | |
"ValidationResultInfo.setError", |
| 844 | |
|
| 845 | |
"CredentialProgramInfo.setDiplomaTitle", |
| 846 | |
|
| 847 | |
"CredentialProgramInfo.setType", |
| 848 | |
|
| 849 | |
"CredentialProgramInfo.setHegisCode", |
| 850 | |
"CredentialProgramInfo.setCip2000Code", |
| 851 | |
"CredentialProgramInfo.setCip2010Code", |
| 852 | |
"CredentialProgramInfo.setSelectiveEnrollmentCode", |
| 853 | |
"CoreProgramInfo.setDiplomaTitle", |
| 854 | |
|
| 855 | |
|
| 856 | |
|
| 857 | |
"CoreProgramInfo.setHegisCode", |
| 858 | |
"CoreProgramInfo.setCip2000Code", |
| 859 | |
"CoreProgramInfo.setCip2010Code", |
| 860 | |
"CoreProgramInfo.setSelectiveEnrollmentCode", |
| 861 | |
"WhenConstraint.setValue" |
| 862 | |
}; |
| 863 | 0 | private static final String[] GETTER_METHODS_TO_SKIP = |
| 864 | |
{ |
| 865 | |
|
| 866 | |
"ValidationResultInfo.getWarning", |
| 867 | |
"ValidationResultInfo.getError", |
| 868 | |
|
| 869 | |
"CredentialProgramInfo.getDiplomaTitle", |
| 870 | |
|
| 871 | |
"CredentialProgramInfo.getType", |
| 872 | |
|
| 873 | |
"CredentialProgramInfo.getHegisCode", |
| 874 | |
"CredentialProgramInfo.getCip2000Code", |
| 875 | |
"CredentialProgramInfo.getCip2010Code", |
| 876 | |
"CredentialProgramInfo.getSelectiveEnrollmentCode", |
| 877 | |
"CoreProgramInfo.getDiplomaTitle", |
| 878 | |
|
| 879 | |
|
| 880 | |
|
| 881 | |
"CoreProgramInfo.getHegisCode", |
| 882 | |
"CoreProgramInfo.getCip2000Code", |
| 883 | |
"CoreProgramInfo.getCip2010Code", |
| 884 | |
"CoreProgramInfo.getSelectiveEnrollmentCode", |
| 885 | |
"WhenConstraint.getValue" |
| 886 | |
}; |
| 887 | |
|
| 888 | |
private boolean isSetterMethodToProcess (JavaMethod method, String className) |
| 889 | |
{ |
| 890 | 0 | if ( ! method.getName ().startsWith ("set")) |
| 891 | |
{ |
| 892 | 0 | return false; |
| 893 | |
} |
| 894 | 0 | if (method.getParameters ().length != 1) |
| 895 | |
{ |
| 896 | 0 | return false; |
| 897 | |
} |
| 898 | 0 | if (method.isPrivate ()) |
| 899 | |
{ |
| 900 | 0 | return false; |
| 901 | |
} |
| 902 | 0 | if (method.isProtected ()) |
| 903 | |
{ |
| 904 | 0 | return false; |
| 905 | |
} |
| 906 | 0 | if (method.isStatic ()) |
| 907 | |
{ |
| 908 | 0 | return false; |
| 909 | |
} |
| 910 | 0 | if (method.getParentClass ().getPackageName ().startsWith ("java")) |
| 911 | |
{ |
| 912 | 0 | return false; |
| 913 | |
} |
| 914 | 0 | String fullName = className + "." + method.getName (); |
| 915 | 0 | for (String skip : SETTER_METHODS_TO_SKIP) |
| 916 | |
{ |
| 917 | 0 | if (skip.equals (fullName)) |
| 918 | |
{ |
| 919 | 0 | return false; |
| 920 | |
} |
| 921 | |
} |
| 922 | |
|
| 923 | |
|
| 924 | |
|
| 925 | |
|
| 926 | 0 | for (Annotation annotation : method.getAnnotations ()) |
| 927 | |
{ |
| 928 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ("XmlTransient")) |
| 929 | |
{ |
| 930 | 0 | return false; |
| 931 | |
} |
| 932 | |
} |
| 933 | 0 | return true; |
| 934 | |
} |
| 935 | |
|
| 936 | |
private boolean isGetterMethodToProcess (JavaMethod method, String className) |
| 937 | |
{ |
| 938 | 0 | if ( ! method.getName ().startsWith ("get")) |
| 939 | |
{ |
| 940 | 0 | if ( ! method.getName ().startsWith ("is")) |
| 941 | |
{ |
| 942 | 0 | return false; |
| 943 | |
} |
| 944 | |
} |
| 945 | 0 | if (method.getParameters ().length != 0) |
| 946 | |
{ |
| 947 | 0 | return false; |
| 948 | |
} |
| 949 | 0 | if (method.isPrivate ()) |
| 950 | |
{ |
| 951 | 0 | return false; |
| 952 | |
} |
| 953 | 0 | if (method.isProtected ()) |
| 954 | |
{ |
| 955 | 0 | return false; |
| 956 | |
} |
| 957 | 0 | if (method.isStatic ()) |
| 958 | |
{ |
| 959 | 0 | return false; |
| 960 | |
} |
| 961 | 0 | if (method.getParentClass ().getPackageName ().startsWith ("java")) |
| 962 | |
{ |
| 963 | 0 | return false; |
| 964 | |
} |
| 965 | 0 | String fullName = className + "." + method.getName (); |
| 966 | 0 | for (String skip : GETTER_METHODS_TO_SKIP) |
| 967 | |
{ |
| 968 | 0 | if (skip.equals (fullName)) |
| 969 | |
{ |
| 970 | 0 | return false; |
| 971 | |
} |
| 972 | |
} |
| 973 | |
|
| 974 | |
|
| 975 | |
|
| 976 | |
|
| 977 | 0 | for (Annotation annotation : method.getAnnotations ()) |
| 978 | |
{ |
| 979 | 0 | if (annotation.getType ().getJavaClass ().getName ().equals ("XmlTransient")) |
| 980 | |
{ |
| 981 | 0 | return false; |
| 982 | |
} |
| 983 | |
} |
| 984 | 0 | return true; |
| 985 | |
} |
| 986 | |
|
| 987 | |
private String calcShortNameFromSetter (JavaMethod method) |
| 988 | |
{ |
| 989 | 0 | return method.getName ().substring (3); |
| 990 | |
} |
| 991 | |
|
| 992 | |
private String calcShortNameFromGetter (JavaMethod method) |
| 993 | |
{ |
| 994 | 0 | if (method.getName ().startsWith ("get")) |
| 995 | |
{ |
| 996 | 0 | return method.getName ().substring (3); |
| 997 | |
} |
| 998 | 0 | if (method.getName ().startsWith ("is")) |
| 999 | |
{ |
| 1000 | 0 | return method.getName ().substring (2); |
| 1001 | |
} |
| 1002 | 0 | throw new IllegalArgumentException (method.getName () |
| 1003 | |
+ " does not start with is or get"); |
| 1004 | |
} |
| 1005 | |
|
| 1006 | |
private String calcCardinalityOfReturn (JavaMethod getterMethod) |
| 1007 | |
{ |
| 1008 | 0 | if (isReturnAList (getterMethod)) |
| 1009 | |
{ |
| 1010 | 0 | return "Many"; |
| 1011 | |
} |
| 1012 | 0 | return "One"; |
| 1013 | |
} |
| 1014 | |
|
| 1015 | |
private boolean isReturnAList (JavaMethod method) |
| 1016 | |
{ |
| 1017 | 0 | return isList (method.getReturnType ()); |
| 1018 | |
} |
| 1019 | |
|
| 1020 | |
private boolean isList (Type type) |
| 1021 | |
{ |
| 1022 | 0 | JavaClass javaClass = type.getJavaClass (); |
| 1023 | 0 | return this.isList (javaClass); |
| 1024 | |
} |
| 1025 | |
|
| 1026 | |
private boolean isList (JavaClass javaClass) |
| 1027 | |
{ |
| 1028 | 0 | if (javaClass.getName ().equals ("LocalKeyList")) |
| 1029 | |
{ |
| 1030 | 0 | return true; |
| 1031 | |
} |
| 1032 | 0 | if (javaClass.getName ().equals ("MessageGroupKeyList")) |
| 1033 | |
{ |
| 1034 | 0 | return true; |
| 1035 | |
} |
| 1036 | 0 | if (javaClass.getName ().equals (List.class.getSimpleName ())) |
| 1037 | |
{ |
| 1038 | 0 | return true; |
| 1039 | |
} |
| 1040 | 0 | if (javaClass.getName ().equals (ArrayList.class.getSimpleName ())) |
| 1041 | |
{ |
| 1042 | 0 | return true; |
| 1043 | |
} |
| 1044 | 0 | if (javaClass.getName ().equals (Collection.class.getSimpleName ())) |
| 1045 | |
{ |
| 1046 | 0 | return true; |
| 1047 | |
} |
| 1048 | 0 | return false; |
| 1049 | |
} |
| 1050 | |
|
| 1051 | |
private String calcTypeOfGetterMethodReturn (JavaMethod getterMethod) |
| 1052 | |
{ |
| 1053 | 0 | Type type = getterMethod.getReturnType (); |
| 1054 | 0 | return calcType (type); |
| 1055 | |
} |
| 1056 | |
|
| 1057 | |
private String calcTypeOfSetterMethodFirstParam (JavaMethod setterMethod) |
| 1058 | |
{ |
| 1059 | 0 | JavaParameter param = setterMethod.getParameters ()[0]; |
| 1060 | 0 | return calcType (param); |
| 1061 | |
} |
| 1062 | |
|
| 1063 | |
private String calcType (JavaParameter parameter) |
| 1064 | |
{ |
| 1065 | 0 | return calcType (parameter.getType ()); |
| 1066 | |
} |
| 1067 | |
|
| 1068 | |
private String calcType (Type type) |
| 1069 | |
{ |
| 1070 | 0 | if (isList (type.getJavaClass ())) |
| 1071 | |
{ |
| 1072 | 0 | return calcType (calcRealJavaClass (type)) + "List"; |
| 1073 | |
} |
| 1074 | 0 | return calcType (calcRealJavaClass (type)); |
| 1075 | |
} |
| 1076 | |
|
| 1077 | |
private String calcType (JavaClass javaClass) |
| 1078 | |
{ |
| 1079 | 0 | if (javaClass.isEnum ()) |
| 1080 | |
{ |
| 1081 | 0 | if (javaClass.getName ().equals ("ErrorLevel")) |
| 1082 | |
{ |
| 1083 | 0 | return "Integer"; |
| 1084 | |
} |
| 1085 | 0 | if (javaClass.getName ().equals ("StatementOperatorTypeKey")) |
| 1086 | |
{ |
| 1087 | 0 | return "String"; |
| 1088 | |
} |
| 1089 | 0 | if (javaClass.getName ().equals ("WriteAccess")) |
| 1090 | |
{ |
| 1091 | 0 | return "String"; |
| 1092 | |
} |
| 1093 | 0 | if (javaClass.getName ().equals ("Widget")) |
| 1094 | |
{ |
| 1095 | 0 | return "String"; |
| 1096 | |
} |
| 1097 | 0 | if (javaClass.getName ().equals ("DataType")) |
| 1098 | |
{ |
| 1099 | 0 | return "String"; |
| 1100 | |
} |
| 1101 | 0 | if (javaClass.getName ().equals ("SortDirection")) |
| 1102 | |
{ |
| 1103 | 0 | return "String"; |
| 1104 | |
} |
| 1105 | 0 | if (javaClass.getName ().equals ("Usage")) |
| 1106 | |
{ |
| 1107 | 0 | return "String"; |
| 1108 | |
} |
| 1109 | |
} |
| 1110 | |
|
| 1111 | 0 | if (javaClass.getName ().equals (LOCALE_KEY_LIST)) |
| 1112 | |
{ |
| 1113 | 0 | return "StringList"; |
| 1114 | |
} |
| 1115 | 0 | if (javaClass.getName ().equals (MESSAGE_GROUP_KEY_LIST)) |
| 1116 | |
{ |
| 1117 | 0 | return "StringList"; |
| 1118 | |
} |
| 1119 | |
|
| 1120 | 0 | if (javaClass.getName ().equals ("java$util$Map")) |
| 1121 | |
{ |
| 1122 | 0 | return "Map<String, String>"; |
| 1123 | |
} |
| 1124 | 0 | if (javaClass.getName ().equals ("Map")) |
| 1125 | |
{ |
| 1126 | |
|
| 1127 | 0 | return "Map<String, String>"; |
| 1128 | |
} |
| 1129 | 0 | return javaClass.getName (); |
| 1130 | |
} |
| 1131 | |
|
| 1132 | |
private JavaClass calcRealJavaClassOfGetterReturn (JavaMethod getterMethod) |
| 1133 | |
{ |
| 1134 | 0 | Type type = getterMethod.getReturnType (); |
| 1135 | 0 | return this.calcRealJavaClass (type); |
| 1136 | |
} |
| 1137 | |
|
| 1138 | |
private JavaClass calcRealJavaClassOfSetterFirstParam (JavaMethod setterMethod) |
| 1139 | |
{ |
| 1140 | 0 | JavaParameter param = setterMethod.getParameters ()[0]; |
| 1141 | 0 | return this.calcRealJavaClass (param); |
| 1142 | |
} |
| 1143 | |
|
| 1144 | |
private JavaClass calcRealJavaClass (JavaParameter param) |
| 1145 | |
{ |
| 1146 | 0 | Type type = param.getType (); |
| 1147 | 0 | return calcRealJavaClass (type); |
| 1148 | |
} |
| 1149 | |
|
| 1150 | |
private JavaClass calcRealJavaClass (Type type) |
| 1151 | |
{ |
| 1152 | 0 | JavaClass javaClass = type.getJavaClass (); |
| 1153 | 0 | if (javaClass.getName ().equals (LOCALE_KEY_LIST)) |
| 1154 | |
{ |
| 1155 | 0 | return STRING_JAVA_CLASS; |
| 1156 | |
} |
| 1157 | 0 | if (javaClass.getName ().equals (MESSAGE_GROUP_KEY_LIST)) |
| 1158 | |
{ |
| 1159 | 0 | return STRING_JAVA_CLASS; |
| 1160 | |
} |
| 1161 | 0 | if ( ! this.isList (javaClass)) |
| 1162 | |
{ |
| 1163 | 0 | return javaClass; |
| 1164 | |
} |
| 1165 | |
|
| 1166 | |
|
| 1167 | |
|
| 1168 | |
|
| 1169 | |
|
| 1170 | |
|
| 1171 | |
|
| 1172 | 0 | Type t = type.getActualTypeArguments ()[0]; |
| 1173 | 0 | return t.getJavaClass (); |
| 1174 | |
} |
| 1175 | |
|
| 1176 | |
private boolean isComplex (JavaClass javaClass) |
| 1177 | |
{ |
| 1178 | 0 | if (javaClass.isEnum ()) |
| 1179 | |
{ |
| 1180 | 0 | return false; |
| 1181 | |
} |
| 1182 | 0 | if (javaClass.getName ().equals (String.class.getSimpleName ())) |
| 1183 | |
{ |
| 1184 | 0 | return false; |
| 1185 | |
} |
| 1186 | 0 | if (javaClass.getName ().equals (Integer.class.getSimpleName ())) |
| 1187 | |
{ |
| 1188 | 0 | return false; |
| 1189 | |
} |
| 1190 | 0 | if (javaClass.getName ().equals (Date.class.getSimpleName ())) |
| 1191 | |
{ |
| 1192 | 0 | return false; |
| 1193 | |
} |
| 1194 | 0 | if (javaClass.getName ().equals (Long.class.getSimpleName ())) |
| 1195 | |
{ |
| 1196 | 0 | return false; |
| 1197 | |
} |
| 1198 | 0 | if (javaClass.getName ().equals (Boolean.class.getSimpleName ())) |
| 1199 | |
{ |
| 1200 | 0 | return false; |
| 1201 | |
} |
| 1202 | 0 | if (javaClass.getName ().equals (Double.class.getSimpleName ())) |
| 1203 | |
{ |
| 1204 | 0 | return false; |
| 1205 | |
} |
| 1206 | 0 | if (javaClass.getName ().equals (Float.class.getSimpleName ())) |
| 1207 | |
{ |
| 1208 | 0 | return false; |
| 1209 | |
} |
| 1210 | 0 | if (javaClass.getName ().equals (int.class.getSimpleName ())) |
| 1211 | |
{ |
| 1212 | 0 | return false; |
| 1213 | |
} |
| 1214 | 0 | if (javaClass.getName ().equals (long.class.getSimpleName ())) |
| 1215 | |
{ |
| 1216 | 0 | return false; |
| 1217 | |
} |
| 1218 | 0 | if (javaClass.getName ().equals (boolean.class.getSimpleName ())) |
| 1219 | |
{ |
| 1220 | 0 | return false; |
| 1221 | |
} |
| 1222 | 0 | if (javaClass.getName ().equals (double.class.getSimpleName ())) |
| 1223 | |
{ |
| 1224 | 0 | return false; |
| 1225 | |
} |
| 1226 | 0 | if (javaClass.getName ().equals (float.class.getSimpleName ())) |
| 1227 | |
{ |
| 1228 | 0 | return false; |
| 1229 | |
} |
| 1230 | 0 | if (javaClass.getName ().equals (Map.class.getSimpleName ())) |
| 1231 | |
{ |
| 1232 | 0 | return false; |
| 1233 | |
} |
| 1234 | |
|
| 1235 | 0 | if (javaClass.getName ().equals (String.class.getName ())) |
| 1236 | |
{ |
| 1237 | 0 | return false; |
| 1238 | |
} |
| 1239 | 0 | if (javaClass.getName ().equals (Integer.class.getName ())) |
| 1240 | |
{ |
| 1241 | 0 | return false; |
| 1242 | |
} |
| 1243 | 0 | if (javaClass.getName ().equals (Date.class.getName ())) |
| 1244 | |
{ |
| 1245 | 0 | return false; |
| 1246 | |
} |
| 1247 | 0 | if (javaClass.getName ().equals (Long.class.getName ())) |
| 1248 | |
{ |
| 1249 | 0 | return false; |
| 1250 | |
} |
| 1251 | 0 | if (javaClass.getName ().equals (Boolean.class.getName ())) |
| 1252 | |
{ |
| 1253 | 0 | return false; |
| 1254 | |
} |
| 1255 | 0 | if (javaClass.getName ().equals (Double.class.getName ())) |
| 1256 | |
{ |
| 1257 | 0 | return false; |
| 1258 | |
} |
| 1259 | 0 | if (javaClass.getName ().equals (Float.class.getName ())) |
| 1260 | |
{ |
| 1261 | 0 | return false; |
| 1262 | |
} |
| 1263 | 0 | if (javaClass.getName ().equals (int.class.getName ())) |
| 1264 | |
{ |
| 1265 | 0 | return false; |
| 1266 | |
} |
| 1267 | 0 | if (javaClass.getName ().equals (long.class.getName ())) |
| 1268 | |
{ |
| 1269 | 0 | return false; |
| 1270 | |
} |
| 1271 | 0 | if (javaClass.getName ().equals (boolean.class.getName ())) |
| 1272 | |
{ |
| 1273 | 0 | return false; |
| 1274 | |
} |
| 1275 | 0 | if (javaClass.getName ().equals (double.class.getName ())) |
| 1276 | |
{ |
| 1277 | 0 | return false; |
| 1278 | |
} |
| 1279 | 0 | if (javaClass.getName ().equals (float.class.getName ())) |
| 1280 | |
{ |
| 1281 | 0 | return false; |
| 1282 | |
} |
| 1283 | 0 | if (javaClass.getName ().equals (Map.class.getName ())) |
| 1284 | |
{ |
| 1285 | 0 | return false; |
| 1286 | |
} |
| 1287 | 0 | if (javaClass.getName ().equals (LOCALE_KEY_LIST)) |
| 1288 | |
{ |
| 1289 | 0 | return false; |
| 1290 | |
} |
| 1291 | 0 | if (javaClass.getName ().equals (MESSAGE_GROUP_KEY_LIST)) |
| 1292 | |
{ |
| 1293 | 0 | return false; |
| 1294 | |
} |
| 1295 | 0 | if (javaClass.getName ().equals ("java$util$Map")) |
| 1296 | |
{ |
| 1297 | 0 | return false; |
| 1298 | |
} |
| 1299 | 0 | return true; |
| 1300 | |
} |
| 1301 | |
} |