1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.deduced.generator.java; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Arrays; |
21 | |
import java.util.LinkedList; |
22 | |
import java.util.List; |
23 | |
import java.util.logging.Level; |
24 | |
import java.util.logging.Logger; |
25 | |
|
26 | |
import org.apache.commons.collections.list.TreeList; |
27 | |
import org.apache.commons.lang.StringEscapeUtils; |
28 | |
import org.apache.commons.lang.StringUtils; |
29 | |
import org.deduced.BasicTypes; |
30 | |
import org.deduced.DeducedModelLayer; |
31 | |
import org.deduced.DeducedSchemaLayer; |
32 | |
import org.deduced.DeducedUtilities; |
33 | |
import org.deduced.OrderedPropertyListType; |
34 | |
import org.deduced.OrderedPropertyListTypeHolder; |
35 | |
import org.deduced.OrderingPropertyCollectionType; |
36 | |
import org.deduced.OrderingPropertyCollectionTypeHolder; |
37 | |
import org.deduced.PropertyCollection; |
38 | |
import org.deduced.PropertyCollectionListInstance; |
39 | |
import org.deduced.PropertyCollectionListInstanceHolder; |
40 | |
import org.deduced.PropertyCollectionType; |
41 | |
import org.deduced.PropertyCollectionTypeHolder; |
42 | |
import org.deduced.PropertyInstance; |
43 | |
import org.deduced.PropertyInstanceHolder; |
44 | |
import org.deduced.PropertyList; |
45 | |
import org.deduced.PropertyMap; |
46 | |
import org.deduced.PropertyPackage; |
47 | |
import org.deduced.PropertyType; |
48 | |
import org.deduced.PropertyTypeHolder; |
49 | |
import org.deduced.generator.StringAdjuster; |
50 | |
import org.deduced.implementation.DeducedSchemaLayerImplementation; |
51 | |
import org.deduced.implementation.EnumerationPropertyTypeImplementation; |
52 | |
import org.deduced.implementation.OrderedPropertyListTypeImplementation; |
53 | |
import org.deduced.implementation.OrderingPropertyCollectionTypeImplementation; |
54 | |
import org.deduced.implementation.PropertyCollectionListInstanceImplementation; |
55 | |
import org.deduced.implementation.PropertyCollectionTypeImplementation; |
56 | |
import org.deduced.implementation.PropertyInstanceImplementation; |
57 | |
import org.deduced.implementation.PropertyPackageImplementation; |
58 | |
import org.deduced.rule.DeductionRuleLibrary; |
59 | |
import org.deduced.utilities.FileUtilities; |
60 | |
import org.deduced.validation.model.NullableValidationModel; |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | 2 | public class JavaNamingUtilities |
68 | |
{ |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | 1 | private static final Logger LOGGER = Logger |
74 | |
.getLogger(JavaNamingUtilities.class.getName()); |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | 1 | public static final JavaNamingUtilities DEFAULT = new JavaNamingUtilities(); |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | 1 | private static final StringAdjuster METHOD_NAME_ADJUSTER = |
85 | |
new StringAdjuster(); |
86 | |
|
87 | |
|
88 | |
|
89 | 1 | private static final StringAdjuster MEMBER_NAME_ADJUSTER = |
90 | |
new StringAdjuster(); |
91 | |
|
92 | |
|
93 | |
|
94 | 1 | private static final StringAdjuster PACKAGE_NAME_ADJUSTER = |
95 | |
new StringAdjuster(); |
96 | |
|
97 | |
|
98 | |
|
99 | 1 | private static final StringAdjuster CLASS_NAME_ADJUSTER = |
100 | |
new StringAdjuster(); |
101 | |
|
102 | |
|
103 | |
|
104 | 1 | private static final StringAdjuster STATIC_NAME_ADJUSTER = |
105 | |
new StringAdjuster(); |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public static final String PACKAGE_SEPARATOR = "."; |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public static final String GETTER_PREFIX = "get "; |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public static final String BOOLEAN_GETTER_PREFIX = "is "; |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
public static final String SETTER_PREFIX = "set "; |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public static final String TYPE_SUFFIX = " Type"; |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
public static final String KEY_LIST_SUFFIX = " key list"; |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
public static final String INSTANCE_SUFFIX = " instance"; |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public static final String LITERAL_SUFFIX = " literal"; |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
public static final String IMPLEMENTATION_SUFFIX = " implementation"; |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
static |
156 | |
{ |
157 | 1 | CLASS_NAME_ADJUSTER.setFirstLetterOfEachWordUpperCase(true); |
158 | 1 | CLASS_NAME_ADJUSTER.setUpperCaseFirstLetter(true); |
159 | 1 | CLASS_NAME_ADJUSTER.setWhiteSpaceReplaceString(""); |
160 | 1 | CLASS_NAME_ADJUSTER.setAcceptingOnlyBaseCharacters(true); |
161 | |
|
162 | 1 | STATIC_NAME_ADJUSTER.setAllInUpperCase(true); |
163 | 1 | STATIC_NAME_ADJUSTER.setWhiteSpaceReplaceString("_"); |
164 | 1 | STATIC_NAME_ADJUSTER.setAcceptingOnlyBaseCharacters(true); |
165 | |
|
166 | 1 | PACKAGE_NAME_ADJUSTER.setAllInLowerCase(true); |
167 | 1 | PACKAGE_NAME_ADJUSTER.setWhiteSpaceReplaceString(""); |
168 | 1 | PACKAGE_NAME_ADJUSTER.setAcceptingOnlyBaseCharacters(true); |
169 | |
|
170 | 1 | METHOD_NAME_ADJUSTER.setFirstLetterOfEachWordUpperCase(true); |
171 | 1 | METHOD_NAME_ADJUSTER.setLowerCaseFirstLetter(true); |
172 | 1 | METHOD_NAME_ADJUSTER.setWhiteSpaceReplaceString(""); |
173 | 1 | METHOD_NAME_ADJUSTER.setAcceptingOnlyBaseCharacters(true); |
174 | |
|
175 | 1 | MEMBER_NAME_ADJUSTER.setFirstLetterOfEachWordUpperCase(true); |
176 | 1 | MEMBER_NAME_ADJUSTER.setLowerCaseFirstLetter(true); |
177 | 1 | MEMBER_NAME_ADJUSTER.setWhiteSpaceReplaceString(""); |
178 | 1 | MEMBER_NAME_ADJUSTER.setAcceptingOnlyBaseCharacters(true); |
179 | |
|
180 | 1 | } |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
public static String getInterfaceName( |
189 | |
PropertyCollection<?, ?> type) |
190 | |
{ |
191 | 153 | return getClassName(DeducedUtilities.getCollectionName(type)); |
192 | |
} |
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
public static String getImplementationName( |
201 | |
PropertyCollection<?, ?> type) |
202 | |
{ |
203 | 107 | return getClassName(DeducedUtilities.getCollectionName(type) |
204 | |
+ IMPLEMENTATION_SUFFIX); |
205 | |
} |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
public static String getClassName( |
214 | |
String baseName) |
215 | |
{ |
216 | 326 | return CLASS_NAME_ADJUSTER.adjustString(baseName); |
217 | |
} |
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
public static String getPackageDeclaration( |
226 | |
String packageName) |
227 | |
{ |
228 | 14 | String retVal = ""; |
229 | 14 | if (!StringUtils.isBlank(packageName)) |
230 | |
{ |
231 | 14 | retVal = "package " + packageName + ";"; |
232 | |
} |
233 | 14 | return retVal; |
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
public static String getSchemaClassName( |
243 | |
String schemaName) |
244 | |
{ |
245 | 60 | String retVal = schemaName; |
246 | 60 | int lastDotIndex = retVal.lastIndexOf('.'); |
247 | 60 | if (lastDotIndex != -1) |
248 | |
{ |
249 | 14 | int length = retVal.length(); |
250 | 14 | retVal = retVal.substring(lastDotIndex, length); |
251 | |
} |
252 | 60 | retVal = getClassName(retVal); |
253 | 60 | if (retVal.isEmpty()) |
254 | |
{ |
255 | 4 | retVal = "DefaultSchemaClassName"; |
256 | |
} |
257 | |
|
258 | 60 | return retVal; |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
public static String getFullyQualifiedSchemaClassName( |
268 | |
String schemaName) |
269 | |
{ |
270 | 25 | String className = getSchemaClassName(schemaName); |
271 | 25 | String packageName = getSchemaPackageName(schemaName); |
272 | 25 | String retVal = getFullyQualifiedJavaClassName(packageName, className); |
273 | 25 | return retVal; |
274 | |
} |
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
public static String getFullyQualifiedJavaClassName( |
285 | |
String packageName, String className) |
286 | |
{ |
287 | 32 | String retVal = className; |
288 | 32 | if (!StringUtils.isBlank(packageName)) |
289 | |
{ |
290 | 30 | retVal = packageName + PACKAGE_SEPARATOR + className; |
291 | 30 | retVal = retVal.replaceAll("\\.\\.*", "."); |
292 | 30 | retVal = retVal.replaceAll("^\\.*", ""); |
293 | |
} |
294 | 32 | return retVal; |
295 | |
} |
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
public static String getSchemaPackageName( |
304 | |
String schemaName) |
305 | |
{ |
306 | 71 | int lastDotIndex = schemaName.lastIndexOf('.'); |
307 | 71 | String retVal = ""; |
308 | 71 | if (lastDotIndex != -1) |
309 | |
{ |
310 | 23 | retVal = schemaName.substring(0, lastDotIndex); |
311 | |
} |
312 | |
|
313 | 71 | String[] packageSplit = retVal.split("\\."); |
314 | 190 | for (int i = 0; i < packageSplit.length; i++) |
315 | |
{ |
316 | 119 | packageSplit[i] = getPackageName(packageSplit[i]); |
317 | |
} |
318 | |
|
319 | 71 | List<String> packageNameList = Arrays.asList(packageSplit); |
320 | 71 | retVal = |
321 | |
concatenateStringListWithSeparatorSkipBlank(PACKAGE_SEPARATOR, |
322 | |
packageNameList); |
323 | |
|
324 | 71 | if (StringUtils.isEmpty(retVal)) |
325 | |
{ |
326 | |
|
327 | 48 | retVal = "factory"; |
328 | |
} |
329 | |
|
330 | 71 | return retVal; |
331 | |
} |
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
|
339 | |
public static String getSchemaFolderName( |
340 | |
String schemaName) |
341 | |
{ |
342 | 23 | String retVal = getSchemaPackageName(schemaName); |
343 | 23 | retVal = retVal.replace('.', '/'); |
344 | 23 | return retVal; |
345 | |
} |
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
public static String getStaticVariableName( |
354 | |
String baseName) |
355 | |
{ |
356 | 324 | return STATIC_NAME_ADJUSTER.adjustString(baseName); |
357 | |
} |
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
public static String getMethodName( |
366 | |
String baseName) |
367 | |
{ |
368 | 209 | return METHOD_NAME_ADJUSTER.adjustString(baseName); |
369 | |
} |
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
public static String getInterfacePackageName( |
379 | |
PropertyCollection<?, ?> collectionType) |
380 | |
{ |
381 | 296 | List<PropertyCollection<?, ?>> packageList = |
382 | |
getPackageListFromType(collectionType); |
383 | |
|
384 | 296 | return getPackageNameFromPackageList(packageList); |
385 | |
} |
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
public static String getPackageNameFromPackageList( |
398 | |
List<? extends PropertyCollection<?, ?>> packageList) |
399 | |
{ |
400 | 307 | String packageSeparator = PACKAGE_SEPARATOR; |
401 | |
|
402 | 307 | return concatenatePackageNamesWithSeparator(packageList, |
403 | |
packageSeparator); |
404 | |
} |
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
private static String concatenatePackageNamesWithSeparator( |
416 | |
List<? extends PropertyCollection<?, ?>> packageList, |
417 | |
String packageSeparator) |
418 | |
{ |
419 | 440 | List<String> nameList = new ArrayList<String>(); |
420 | |
|
421 | 440 | if (packageList != null) |
422 | |
{ |
423 | 439 | for (PropertyCollection<?, ?> currentPackage : packageList) |
424 | |
{ |
425 | 841 | nameList.add(getPackageNameFromPackage(currentPackage)); |
426 | |
} |
427 | |
} |
428 | |
|
429 | 440 | return concatenateStringListWithSeparatorSkipBlank(packageSeparator, |
430 | |
nameList); |
431 | |
} |
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
public static String concatenateStringListWithSeparatorSkipBlank( |
441 | |
String separator, List<String> stringList) |
442 | |
{ |
443 | 511 | StringBuilder retVal = new StringBuilder(); |
444 | 511 | boolean first = true; |
445 | 511 | for (String currentString : stringList) |
446 | |
{ |
447 | 960 | if (!StringUtils.isBlank(currentString)) |
448 | |
{ |
449 | 555 | if (first) |
450 | |
{ |
451 | 400 | first = false; |
452 | |
} |
453 | |
else |
454 | |
{ |
455 | 155 | retVal.append(separator); |
456 | |
} |
457 | |
|
458 | 555 | retVal.append(currentString); |
459 | |
} |
460 | |
} |
461 | 511 | return retVal.toString(); |
462 | |
} |
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
public static String getPackageNameFromPackage( |
471 | |
PropertyCollection<?, ?> propertyPackage) |
472 | |
{ |
473 | 841 | String packageName = |
474 | |
DeducedUtilities.getCollectionName(propertyPackage); |
475 | 841 | return getPackageName(packageName); |
476 | |
} |
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
public static String getPackageName( |
485 | |
String nameToAdjust) |
486 | |
{ |
487 | 960 | String adjustedPackageName = |
488 | |
PACKAGE_NAME_ADJUSTER.adjustString(nameToAdjust); |
489 | 960 | return adjustedPackageName; |
490 | |
} |
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
|
498 | |
public static String getPackageVariableName( |
499 | |
PropertyCollection<?, ?> propertyPackage) |
500 | |
{ |
501 | 133 | List<PropertyCollection<?, ?>> packageList = |
502 | |
getParentPackageListFromPackage(propertyPackage); |
503 | |
|
504 | 133 | String concatenatedPackageName = |
505 | |
concatenatePackageNamesWithSeparator(packageList, " "); |
506 | |
|
507 | 133 | if (StringUtils.isBlank(concatenatedPackageName)) |
508 | |
{ |
509 | 50 | concatenatedPackageName = "root"; |
510 | |
} |
511 | |
|
512 | 133 | return STATIC_NAME_ADJUSTER.adjustString(concatenatedPackageName |
513 | |
+ " package"); |
514 | |
} |
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
|
522 | |
@SuppressWarnings("unchecked") |
523 | |
public static List<PropertyCollection<?, ?>> getParentPackageListFromPackage( |
524 | |
PropertyCollection<?, ?> propertyPackage) |
525 | |
{ |
526 | 457 | List<PropertyCollection<?, ?>> retVal = new TreeList(); |
527 | |
|
528 | 457 | PropertyCollection<?, ?> parent = propertyPackage; |
529 | |
|
530 | 1320 | while (parent != null) |
531 | |
{ |
532 | 1302 | if (DeducedUtilities.isInstanceOf(parent.type(), |
533 | |
PropertyPackage.PROPERTY_PACKAGE_TYPE |
534 | |
.getPropertyCollectionType())) |
535 | |
{ |
536 | |
|
537 | 863 | retVal.add(0, parent); |
538 | |
} |
539 | |
else |
540 | |
{ |
541 | |
break; |
542 | |
} |
543 | 863 | parent = parent.parent(); |
544 | 863 | if (parent != null) |
545 | |
{ |
546 | 849 | parent = parent.parent(); |
547 | |
} |
548 | |
} |
549 | 457 | return retVal; |
550 | |
} |
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
|
558 | |
public static List<PropertyCollection<?, ?>> getPackageListFromType( |
559 | |
PropertyCollection<?, ?> type) |
560 | |
{ |
561 | 304 | PropertyCollection<?, ?> packageParent = type; |
562 | |
|
563 | 304 | if (packageParent != null) |
564 | |
{ |
565 | 302 | packageParent = packageParent.parent(); |
566 | |
} |
567 | |
|
568 | 304 | if (packageParent != null) |
569 | |
{ |
570 | 300 | packageParent = packageParent.parent(); |
571 | |
} |
572 | |
|
573 | 304 | return getParentPackageListFromPackage(packageParent); |
574 | |
} |
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
|
580 | |
|
581 | |
|
582 | |
public static String getInterfaceTypeHolderName( |
583 | |
PropertyCollection<?, ?> collectionType) |
584 | |
{ |
585 | 86 | if (collectionType == null) |
586 | |
{ |
587 | 1 | return null; |
588 | |
} |
589 | 85 | return getStaticVariableName(DeducedUtilities |
590 | |
.getCollectionName(collectionType) + TYPE_SUFFIX); |
591 | |
} |
592 | |
|
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
|
600 | |
public static String getFullyQualifiedTypeInterfaceName( |
601 | |
PropertyCollection<?, ?> collectionType) |
602 | |
{ |
603 | 126 | String interfacePackageName = getInterfacePackageName(collectionType); |
604 | 126 | String interfaceName = getInterfaceName(collectionType); |
605 | 126 | String retVal = |
606 | |
extractFullyQualifiedJavaClassName(interfacePackageName, |
607 | |
interfaceName); |
608 | 126 | return retVal; |
609 | |
} |
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
private static String extractFullyQualifiedJavaClassName( |
621 | |
String packageName, String className) |
622 | |
{ |
623 | 207 | String retVal = null; |
624 | 207 | if (StringUtils.isBlank(packageName)) |
625 | |
{ |
626 | 1 | retVal = className; |
627 | |
} |
628 | |
else |
629 | |
{ |
630 | 206 | retVal = packageName + PACKAGE_SEPARATOR + className; |
631 | |
} |
632 | 207 | return retVal; |
633 | |
} |
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
public static String getFullyQualifiedTypeImplementationName( |
643 | |
PropertyCollection<?, ?> collectionType) |
644 | |
{ |
645 | 98 | String retVal = null; |
646 | 98 | if (collectionType == PropertyList.PROPERTY_LIST_TYPE |
647 | |
.getPropertyCollectionType()) |
648 | |
{ |
649 | 17 | retVal = PropertyList.class.getName(); |
650 | |
} |
651 | |
else |
652 | |
{ |
653 | 81 | String implementationPackageName = |
654 | |
getImplementationPackageName(collectionType); |
655 | 81 | String implementationName = getImplementationName(collectionType); |
656 | 81 | retVal = |
657 | |
extractFullyQualifiedJavaClassName(implementationPackageName, |
658 | |
implementationName); |
659 | |
} |
660 | 98 | return retVal; |
661 | |
} |
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
@SuppressWarnings("unchecked") |
670 | |
public static List<PropertyCollection<?, ?>> getPropertyCollectionTypeParentList( |
671 | |
PropertyCollection<?, ?> collectionType) |
672 | |
{ |
673 | 22 | return PropertyCollectionTypeImplementation.getParentList( |
674 | |
collectionType).asValueList(); |
675 | |
} |
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
|
683 | |
@SuppressWarnings("unchecked") |
684 | |
public static PropertyCollection<?, ?> getOrderingPropertyCollectionTypeValueInstance( |
685 | |
PropertyCollection<?, ?> collectionType) |
686 | |
{ |
687 | 8 | return OrderingPropertyCollectionTypeImplementation |
688 | |
.getValueInstance(collectionType); |
689 | |
} |
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
@SuppressWarnings("unchecked") |
698 | |
public static PropertyCollection<?, ?> getOrderingPropertyCollectionTypeOrderingInstance( |
699 | |
PropertyCollection<?, ?> collectionType) |
700 | |
{ |
701 | 8 | return OrderingPropertyCollectionTypeImplementation |
702 | |
.getOrderingInstance(collectionType); |
703 | |
} |
704 | |
|
705 | |
|
706 | |
|
707 | |
|
708 | |
|
709 | |
|
710 | |
|
711 | |
@SuppressWarnings("unchecked") |
712 | |
public static List<PropertyCollection<?, ?>> getPropertyCollectionTypePropertyInstanceList( |
713 | |
PropertyCollection<?, ?> collectionType) |
714 | |
{ |
715 | 21 | return PropertyCollectionTypeImplementation.getPropertyInstanceList( |
716 | |
collectionType).asValueList(); |
717 | |
} |
718 | |
|
719 | |
|
720 | |
|
721 | |
|
722 | |
|
723 | |
|
724 | |
|
725 | |
|
726 | |
@SuppressWarnings("unchecked") |
727 | |
public static List<PropertyCollection<?, ?>> getFullPropertyCollectionTypePropertyCollectionListInstanceList( |
728 | |
PropertyCollection<?, ?> collectionType) |
729 | |
{ |
730 | 9 | return DeductionRuleLibrary |
731 | |
.filter( |
732 | |
getFullPropertyCollectionTypePropertyInstanceList(collectionType), |
733 | |
DeductionRuleLibrary.not(DeductionRuleLibrary |
734 | |
.instanceOf(PropertyCollectionListInstance.PROPERTY_COLLECTION_LIST_INSTANCE_TYPE |
735 | |
.getPropertyCollectionType()))); |
736 | |
} |
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
|
743 | |
|
744 | |
@SuppressWarnings("unchecked") |
745 | |
public static List<PropertyCollection<?, ?>> getFullPropertyCollectionTypePropertyInstanceList( |
746 | |
PropertyCollection<?, ?> collectionType) |
747 | |
{ |
748 | 22 | List<PropertyCollection<?, ?>> retVal = |
749 | |
new ArrayList<PropertyCollection<?, ?>>(); |
750 | |
|
751 | 22 | List<PropertyCollection<?, ?>> fullPropertyCollectionTypeParentList = |
752 | |
getFullPropertyCollectionTypeParentList(collectionType); |
753 | 22 | for (PropertyCollection<?, ?> currentType : fullPropertyCollectionTypeParentList) |
754 | |
{ |
755 | 58 | retVal.addAll(PropertyCollectionTypeImplementation |
756 | |
.getPropertyInstanceList(currentType).asValueList()); |
757 | |
} |
758 | 22 | return retVal; |
759 | |
} |
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
public static List<PropertyCollection<?, ?>> getFullPropertyCollectionTypeParentList( |
771 | |
PropertyCollection<?, ?> collectionType) |
772 | |
{ |
773 | 24 | List<PropertyCollection<?, ?>> retVal = |
774 | |
new ArrayList<PropertyCollection<?, ?>>(); |
775 | 24 | addTypeToList(collectionType, retVal); |
776 | 24 | return retVal; |
777 | |
} |
778 | |
|
779 | |
|
780 | |
|
781 | |
|
782 | |
|
783 | |
|
784 | |
|
785 | |
private static void addTypeToList( |
786 | |
PropertyCollection<?, ?> collectionType, |
787 | |
List<PropertyCollection<?, ?>> retVal) |
788 | |
{ |
789 | 70 | if (collectionType != null && !retVal.contains(collectionType)) |
790 | |
{ |
791 | 67 | retVal.add(collectionType); |
792 | 67 | List<?> parentList = |
793 | |
PropertyCollectionTypeImplementation.getParentList( |
794 | |
collectionType).asValueList(); |
795 | 67 | for (Object object : parentList) |
796 | |
{ |
797 | 46 | addTypeToList((PropertyCollection<?, ?>) object, retVal); |
798 | |
} |
799 | |
} |
800 | 70 | } |
801 | |
|
802 | |
|
803 | |
|
804 | |
|
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
public static boolean isListPropertyInstance( |
810 | |
PropertyCollection<?, ?> instance) |
811 | |
{ |
812 | 151 | return DeducedUtilities |
813 | |
.isInstanceOf( |
814 | |
instance.type(), |
815 | |
PropertyCollectionListInstance.PROPERTY_COLLECTION_LIST_INSTANCE_TYPE |
816 | |
.getPropertyCollectionType()); |
817 | |
} |
818 | |
|
819 | |
|
820 | |
|
821 | |
|
822 | |
|
823 | |
|
824 | |
|
825 | |
public static String getInstanceHolderVariableName( |
826 | |
PropertyCollection<?, ?> instance) |
827 | |
{ |
828 | 238 | if (instance == null) |
829 | |
{ |
830 | 1 | return null; |
831 | |
} |
832 | 237 | return getStaticVariableName(DeducedUtilities |
833 | |
.getCollectionName(instance) + INSTANCE_SUFFIX); |
834 | |
} |
835 | |
|
836 | |
|
837 | |
|
838 | |
|
839 | |
|
840 | |
|
841 | |
|
842 | |
public static String getEnumerationHolderVariableName( |
843 | |
PropertyCollection<?, ?> instance) |
844 | |
{ |
845 | 0 | if (instance == null) |
846 | |
{ |
847 | 0 | return null; |
848 | |
} |
849 | 0 | return getStaticVariableName(DeducedUtilities |
850 | |
.getCollectionName(instance) + LITERAL_SUFFIX); |
851 | |
} |
852 | |
|
853 | |
|
854 | |
|
855 | |
|
856 | |
|
857 | |
|
858 | |
|
859 | |
public static String getInstanceMemberVariableName( |
860 | |
PropertyCollection<?, ?> instance) |
861 | |
{ |
862 | 187 | return getMemberName(DeducedUtilities.getCollectionName(instance)); |
863 | |
} |
864 | |
|
865 | |
|
866 | |
|
867 | |
|
868 | |
|
869 | |
|
870 | |
|
871 | |
public static String getMemberName( |
872 | |
String memberNameToAdjust) |
873 | |
{ |
874 | 190 | return MEMBER_NAME_ADJUSTER.adjustString(memberNameToAdjust); |
875 | |
} |
876 | |
|
877 | |
|
878 | |
|
879 | |
|
880 | |
|
881 | |
|
882 | |
|
883 | |
|
884 | |
|
885 | |
|
886 | |
|
887 | |
public static String getFullyQualifiedInstanceTypeName( |
888 | |
PropertyCollection<?, ?> instance) |
889 | |
{ |
890 | 129 | PropertyCollection<?, ?> type = |
891 | |
PropertyInstanceImplementation.getInstanceType(instance); |
892 | |
|
893 | 129 | if (isInstanceTypeNative(instance)) |
894 | |
{ |
895 | |
|
896 | 1 | Class<?> classFromType = BasicTypes.getNativeClassFromType(type); |
897 | 1 | return classFromType.getCanonicalName(); |
898 | |
} |
899 | |
|
900 | 128 | return getFullyQualifiedTypeName(type); |
901 | |
} |
902 | |
|
903 | |
|
904 | |
|
905 | |
|
906 | |
|
907 | |
|
908 | |
|
909 | |
|
910 | |
|
911 | |
public static boolean isInstanceTypeNative( |
912 | |
PropertyCollection<?, ?> instance) |
913 | |
{ |
914 | 282 | PropertyCollection<?, ?> propertyInstanceValidationModel = |
915 | |
PropertyInstanceImplementation.getValidationModel(instance); |
916 | 282 | PropertyCollection<?, ?> type = |
917 | |
PropertyInstanceImplementation.getInstanceType(instance); |
918 | 282 | Object nullValidKey = |
919 | |
NullableValidationModel.IS_NULL_VALID_INSTANCE.getKey(); |
920 | |
|
921 | 282 | if (propertyInstanceValidationModel != null |
922 | |
&& propertyInstanceValidationModel.containsKey(nullValidKey)) |
923 | |
{ |
924 | 58 | Boolean isNullValid = |
925 | |
(Boolean) propertyInstanceValidationModel |
926 | |
.getPropertyValue(nullValidKey); |
927 | |
|
928 | 58 | if (isNullValid != null && !isNullValid.booleanValue()) |
929 | |
{ |
930 | 54 | return BasicTypes.isTypeNative(type); |
931 | |
} |
932 | |
} |
933 | |
|
934 | 228 | return false; |
935 | |
} |
936 | |
|
937 | |
|
938 | |
|
939 | |
|
940 | |
|
941 | |
|
942 | |
public static void debug( |
943 | |
String print) |
944 | |
{ |
945 | 6 | if (LOGGER.isLoggable(Level.FINEST)) |
946 | |
{ |
947 | 2 | LOGGER.log(Level.FINEST, "Debug : " + print); |
948 | |
} |
949 | 6 | } |
950 | |
|
951 | |
|
952 | |
|
953 | |
|
954 | |
|
955 | |
|
956 | |
|
957 | |
|
958 | |
|
959 | |
public static String getFullyQualifiedTypeName( |
960 | |
PropertyCollection<?, ?> type) |
961 | |
{ |
962 | 225 | String returnValue = null; |
963 | 225 | if (type.type() == PropertyType.PROPERTY_TYPE_TYPE |
964 | |
.getPropertyCollectionType()) |
965 | |
{ |
966 | 57 | Class<?> classFromType = BasicTypes.getClassFromType(type); |
967 | 57 | returnValue = classFromType.getCanonicalName(); |
968 | 57 | } |
969 | 160 | else if (type == PropertyList.PROPERTY_LIST_TYPE |
970 | |
.getPropertyCollectionType()) |
971 | |
{ |
972 | 115 | returnValue = PropertyList.class.getCanonicalName(); |
973 | |
} |
974 | 45 | else if (type == PropertyList.PROPERTY_COLLECTION_TYPE |
975 | |
.getPropertyCollectionType()) |
976 | |
{ |
977 | 3 | returnValue = PropertyCollection.class.getCanonicalName(); |
978 | |
} |
979 | |
else |
980 | |
{ |
981 | 42 | returnValue = getFullyQualifiedTypeInterfaceName(type); |
982 | |
} |
983 | 217 | return returnValue; |
984 | |
} |
985 | |
|
986 | |
|
987 | |
|
988 | |
|
989 | |
|
990 | |
|
991 | |
|
992 | |
public static PropertyCollection<?, ?> getPropertyInstanceInstanceType( |
993 | |
PropertyCollection<?, ?> instance) |
994 | |
{ |
995 | 136 | return PropertyInstanceImplementation.getInstanceType(instance); |
996 | |
} |
997 | |
|
998 | |
|
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
|
1004 | |
public static PropertyCollection<?, ?> getOrderedPropertyListTypeOrderingType( |
1005 | |
PropertyCollection<?, ?> type) |
1006 | |
{ |
1007 | 0 | return OrderedPropertyListTypeImplementation.getOrderingType(type); |
1008 | |
} |
1009 | |
|
1010 | |
|
1011 | |
|
1012 | |
|
1013 | |
|
1014 | |
|
1015 | |
|
1016 | |
public static Boolean getPropertyInstanceIsReference( |
1017 | |
PropertyCollection<?, ?> instance) |
1018 | |
{ |
1019 | 144 | return PropertyInstanceImplementation.isReference(instance); |
1020 | |
} |
1021 | |
|
1022 | |
|
1023 | |
|
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
public static PropertyCollection<?, ?> getPropertyCollectionListInstanceListFixedInstance( |
1029 | |
PropertyCollection<?, ?> instance) |
1030 | |
{ |
1031 | 16 | return PropertyCollectionListInstanceImplementation |
1032 | |
.getListFixedInstance(instance); |
1033 | |
} |
1034 | |
|
1035 | |
|
1036 | |
|
1037 | |
|
1038 | |
|
1039 | |
|
1040 | |
|
1041 | |
@SuppressWarnings("unchecked") |
1042 | |
public static List<PropertyCollection<?, ?>> getEnumerationPropertyTypeEnumerationLiteralList( |
1043 | |
PropertyCollection<?, ?> instance) |
1044 | |
{ |
1045 | 20 | PropertyCollection enumerationLiteralList = |
1046 | |
EnumerationPropertyTypeImplementation |
1047 | |
.getEnumerationLiteralList(instance); |
1048 | |
|
1049 | 20 | if (enumerationLiteralList != null) |
1050 | |
{ |
1051 | 0 | return enumerationLiteralList.asValueList(); |
1052 | |
} |
1053 | |
|
1054 | 20 | return new LinkedList<PropertyCollection<?, ?>>(); |
1055 | |
} |
1056 | |
|
1057 | |
|
1058 | |
|
1059 | |
|
1060 | |
|
1061 | |
|
1062 | |
|
1063 | |
public static PropertyCollection<?, ?> getDeducedSchemaLayerRootPackage( |
1064 | |
PropertyCollection<?, ?> instance) |
1065 | |
{ |
1066 | 14 | return DeducedSchemaLayerImplementation.getRootPackage(instance); |
1067 | |
} |
1068 | |
|
1069 | |
|
1070 | |
|
1071 | |
|
1072 | |
|
1073 | |
|
1074 | |
|
1075 | |
public static PropertyCollection<?, ?> getPropertyPackagePropertyPackageList( |
1076 | |
PropertyCollection<?, ?> instance) |
1077 | |
{ |
1078 | 20 | return PropertyPackageImplementation.getPropertyPackageList(instance); |
1079 | |
} |
1080 | |
|
1081 | |
|
1082 | |
|
1083 | |
|
1084 | |
|
1085 | |
|
1086 | |
|
1087 | |
public static PropertyCollection<?, ?> getPropertyPackagePropertyTypeList( |
1088 | |
PropertyCollection<?, ?> instance) |
1089 | |
{ |
1090 | 20 | return PropertyPackageImplementation.getPropertyTypeList(instance); |
1091 | |
} |
1092 | |
|
1093 | |
|
1094 | |
|
1095 | |
|
1096 | |
|
1097 | |
|
1098 | |
|
1099 | |
|
1100 | |
|
1101 | |
|
1102 | |
|
1103 | |
public static String getTypeCastString( |
1104 | |
PropertyCollection<?, ?> type) |
1105 | |
{ |
1106 | 31 | if (type == BasicTypes.OBJECT_TYPE.getPropertyType()) |
1107 | |
{ |
1108 | 1 | return ""; |
1109 | |
} |
1110 | |
|
1111 | 30 | return "(" + getFullyQualifiedTypeName(type) + ")"; |
1112 | |
} |
1113 | |
|
1114 | |
|
1115 | |
|
1116 | |
|
1117 | |
|
1118 | |
|
1119 | |
|
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
public static String getInstanceGetterMethodName( |
1125 | |
PropertyCollection<?, ?> instance) |
1126 | |
{ |
1127 | 85 | String prefix = GETTER_PREFIX; |
1128 | 85 | PropertyCollection<?, ?> propertyInstanceInstanceType = |
1129 | |
PropertyInstanceImplementation.getInstanceType(instance); |
1130 | 85 | String collectionName = DeducedUtilities.getCollectionName(instance); |
1131 | |
|
1132 | 85 | if (propertyInstanceInstanceType == BasicTypes.BOOLEAN_TYPE |
1133 | |
.getPropertyType()) |
1134 | |
{ |
1135 | 4 | if (collectionName.toLowerCase().startsWith("is")) |
1136 | |
{ |
1137 | 2 | prefix = ""; |
1138 | |
} |
1139 | |
else |
1140 | |
{ |
1141 | 2 | prefix = BOOLEAN_GETTER_PREFIX; |
1142 | |
} |
1143 | |
} |
1144 | |
|
1145 | 85 | return getMethodName(prefix + collectionName); |
1146 | |
} |
1147 | |
|
1148 | |
|
1149 | |
|
1150 | |
|
1151 | |
|
1152 | |
|
1153 | |
|
1154 | |
|
1155 | |
|
1156 | |
public static String getInstanceSetterMethodName( |
1157 | |
PropertyCollection<?, ?> instance) |
1158 | |
{ |
1159 | 122 | return getMethodName(SETTER_PREFIX |
1160 | |
+ DeducedUtilities.getCollectionName(instance)); |
1161 | |
} |
1162 | |
|
1163 | |
|
1164 | |
|
1165 | |
|
1166 | |
|
1167 | |
|
1168 | |
|
1169 | |
|
1170 | |
public static String getImplementationPackageName( |
1171 | |
PropertyCollection<?, ?> type) |
1172 | |
{ |
1173 | 107 | return getInterfacePackageName(type) + ".implementation"; |
1174 | |
} |
1175 | |
|
1176 | |
|
1177 | |
|
1178 | |
|
1179 | |
|
1180 | |
|
1181 | |
|
1182 | |
public static PropertyCollection<?, ?> getPropertyInstanceParentPropertyCollectionType( |
1183 | |
PropertyCollection<?, ?> instance) |
1184 | |
{ |
1185 | 27 | PropertyCollection<?, ?> parent = instance; |
1186 | 27 | PropertyCollectionType propertyCollectionType = |
1187 | |
PropertyCollectionType.PROPERTY_COLLECTION_TYPE_TYPE |
1188 | |
.getPropertyCollectionType(); |
1189 | |
while (parent != null |
1190 | 82 | && !DeducedUtilities.isInstanceOf(parent.type(), |
1191 | |
propertyCollectionType)) |
1192 | |
{ |
1193 | 55 | parent = parent.parent(); |
1194 | |
} |
1195 | 27 | return parent; |
1196 | |
} |
1197 | |
|
1198 | |
|
1199 | |
|
1200 | |
|
1201 | |
|
1202 | |
|
1203 | |
|
1204 | |
public static String getInterfaceFileName( |
1205 | |
PropertyCollection<?, ?> type) |
1206 | |
{ |
1207 | 13 | return getInterfaceName(type) + ".java"; |
1208 | |
} |
1209 | |
|
1210 | |
|
1211 | |
|
1212 | |
|
1213 | |
|
1214 | |
|
1215 | |
|
1216 | |
public static String getImplementationFileName( |
1217 | |
PropertyCollection<?, ?> type) |
1218 | |
{ |
1219 | 13 | return getImplementationName(type) + ".java"; |
1220 | |
} |
1221 | |
|
1222 | |
|
1223 | |
|
1224 | |
|
1225 | |
|
1226 | |
|
1227 | |
|
1228 | |
public static String getInterfaceFolderName( |
1229 | |
PropertyCollection<?, ?> type) |
1230 | |
{ |
1231 | 13 | return getFolderNameFromPackageName(getInterfacePackageName(type)); |
1232 | |
} |
1233 | |
|
1234 | |
|
1235 | |
|
1236 | |
|
1237 | |
|
1238 | |
|
1239 | |
|
1240 | |
public static String getImplementationFolderName( |
1241 | |
PropertyCollection<?, ?> type) |
1242 | |
{ |
1243 | |
|
1244 | 13 | return getFolderNameFromPackageName(getImplementationPackageName(type)); |
1245 | |
} |
1246 | |
|
1247 | |
|
1248 | |
|
1249 | |
|
1250 | |
|
1251 | |
|
1252 | |
|
1253 | |
public static String getFolderNameFromPackageName( |
1254 | |
String packageName) |
1255 | |
{ |
1256 | 27 | return packageName.replace(PACKAGE_SEPARATOR, |
1257 | |
FileUtilities.FOLDER_SEPARATOR); |
1258 | |
} |
1259 | |
|
1260 | |
|
1261 | |
|
1262 | |
|
1263 | |
|
1264 | |
|
1265 | |
|
1266 | |
public static String getFullyQualifiedTypeHolderName( |
1267 | |
PropertyCollection<?, ?> type) |
1268 | |
{ |
1269 | 106 | String retVal = null; |
1270 | 106 | if (type.type() == PropertyType.PROPERTY_TYPE_TYPE |
1271 | |
.getPropertyCollectionType()) |
1272 | |
{ |
1273 | |
|
1274 | 12 | String typeName = DeducedUtilities.getCollectionName(type); |
1275 | 12 | String holderName = |
1276 | |
STATIC_NAME_ADJUSTER.adjustString(typeName + TYPE_SUFFIX); |
1277 | 12 | retVal = "org.deduced.BasicTypes." + holderName; |
1278 | 12 | } |
1279 | 94 | else if (type == PropertyMap.PROPERTY_MAP_TYPE.getPropertyType()) |
1280 | |
{ |
1281 | 1 | retVal = "org.deduced.PropertyMap.PROPERTY_MAP_TYPE"; |
1282 | |
} |
1283 | 93 | else if (type == PropertyList.PROPERTY_LIST_TYPE.getPropertyType()) |
1284 | |
{ |
1285 | 33 | retVal = "org.deduced.PropertyList.PROPERTY_LIST_TYPE"; |
1286 | |
} |
1287 | |
else |
1288 | |
{ |
1289 | 60 | String interfaceName = getFullyQualifiedTypeInterfaceName(type); |
1290 | 60 | String typeHolder = getInterfaceTypeHolderName(type); |
1291 | 60 | retVal = interfaceName + PACKAGE_SEPARATOR + typeHolder; |
1292 | |
} |
1293 | 106 | return retVal; |
1294 | |
} |
1295 | |
|
1296 | |
|
1297 | |
|
1298 | |
|
1299 | |
|
1300 | |
|
1301 | |
|
1302 | |
public static List<PropertyCollection<?, ?>> getPropertyCollectionTypeListFromSchema( |
1303 | |
PropertyCollection<?, ?> schema) |
1304 | |
{ |
1305 | 27 | PropertyCollection<?, ?> rootPackage = |
1306 | |
(PropertyCollection<?, ?>) schema |
1307 | |
.getPropertyValue(DeducedSchemaLayer.ROOT_PACKAGE_INSTANCE |
1308 | |
.getKey()); |
1309 | |
|
1310 | 27 | List<PropertyCollection<?, ?>> packageList = |
1311 | |
getRecursivePackageListFromPackage(rootPackage); |
1312 | |
|
1313 | 27 | List<PropertyCollection<?, ?>> retVal = |
1314 | |
new ArrayList<PropertyCollection<?, ?>>(); |
1315 | |
|
1316 | 27 | for (PropertyCollection<?, ?> currentPackage : packageList) |
1317 | |
{ |
1318 | 35 | retVal |
1319 | |
.addAll(getPropertyCollectionTypeListFromPackage(currentPackage)); |
1320 | |
} |
1321 | |
|
1322 | 27 | return retVal; |
1323 | |
} |
1324 | |
|
1325 | |
|
1326 | |
|
1327 | |
|
1328 | |
|
1329 | |
|
1330 | |
|
1331 | |
public static List<PropertyCollection<?, ?>> getPropertyCollectionTypeListFromPackage( |
1332 | |
PropertyCollection<?, ?> propertyPackage) |
1333 | |
{ |
1334 | 39 | List<PropertyCollection<?, ?>> retVal = |
1335 | |
new ArrayList<PropertyCollection<?, ?>>(); |
1336 | |
|
1337 | 39 | if (propertyPackage != null) |
1338 | |
{ |
1339 | 39 | PropertyCollection<?, ?> propertyPackagePropertyTypeList = |
1340 | |
PropertyPackageImplementation |
1341 | |
.getPropertyTypeList(propertyPackage); |
1342 | |
|
1343 | 39 | if (propertyPackagePropertyTypeList != null) |
1344 | |
{ |
1345 | 39 | List<?> typeList = |
1346 | |
propertyPackagePropertyTypeList.asValueList(); |
1347 | 39 | for (Object object : typeList) |
1348 | |
{ |
1349 | 29 | PropertyCollection<?, ?> type = |
1350 | |
(PropertyCollection<?, ?>) object; |
1351 | |
|
1352 | 29 | if (DeducedUtilities.isTypeCollection(type.type())) |
1353 | |
{ |
1354 | 25 | retVal.add(type); |
1355 | |
} |
1356 | 29 | } |
1357 | |
} |
1358 | |
} |
1359 | |
|
1360 | 39 | return retVal; |
1361 | |
} |
1362 | |
|
1363 | |
|
1364 | |
|
1365 | |
|
1366 | |
|
1367 | |
|
1368 | |
|
1369 | |
|
1370 | |
public static List<PropertyCollection<?, ?>> getRecursivePackageListFromPackage( |
1371 | |
PropertyCollection<?, ?> propertyPackage) |
1372 | |
{ |
1373 | 43 | List<PropertyCollection<?, ?>> retVal = |
1374 | |
new ArrayList<PropertyCollection<?, ?>>(); |
1375 | |
|
1376 | 43 | internalGetRecursivePackageListFromPackage(propertyPackage, retVal); |
1377 | |
|
1378 | 43 | return retVal; |
1379 | |
} |
1380 | |
|
1381 | |
|
1382 | |
|
1383 | |
|
1384 | |
|
1385 | |
|
1386 | |
|
1387 | |
|
1388 | |
private static void internalGetRecursivePackageListFromPackage( |
1389 | |
PropertyCollection<?, ?> propertyPackage, |
1390 | |
List<PropertyCollection<?, ?>> retVal) |
1391 | |
{ |
1392 | 68 | if (propertyPackage != null) |
1393 | |
{ |
1394 | 61 | retVal.add(propertyPackage); |
1395 | |
|
1396 | 61 | PropertyCollection<?, ?> propertyPackagePropertyPackageList = |
1397 | |
DeducedUtilities |
1398 | |
.getPropertyPackagePropertyPackageList(propertyPackage); |
1399 | |
|
1400 | 61 | if (propertyPackagePropertyPackageList != null) |
1401 | |
{ |
1402 | 61 | List<?> packageList = |
1403 | |
propertyPackagePropertyPackageList.asValueList(); |
1404 | 61 | for (Object object : packageList) |
1405 | |
{ |
1406 | 25 | internalGetRecursivePackageListFromPackage( |
1407 | |
(PropertyCollection<?, ?>) object, retVal); |
1408 | |
} |
1409 | |
} |
1410 | |
} |
1411 | 68 | } |
1412 | |
|
1413 | |
|
1414 | |
|
1415 | |
|
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
public static String getSchemaXmlFileName( |
1420 | |
String schemaName) |
1421 | |
{ |
1422 | 14 | String retVal = getFullyQualifiedSchemaClassName(schemaName); |
1423 | 14 | retVal = retVal.replace('.', '/'); |
1424 | 14 | retVal += ".xml"; |
1425 | 14 | return retVal; |
1426 | |
} |
1427 | |
|
1428 | |
|
1429 | |
|
1430 | |
|
1431 | |
|
1432 | |
|
1433 | |
|
1434 | |
public static String getJavaString( |
1435 | |
String value) |
1436 | |
{ |
1437 | 77 | if (value == null) |
1438 | |
{ |
1439 | 17 | return "null"; |
1440 | |
} |
1441 | |
|
1442 | 60 | String retVal = StringEscapeUtils.escapeJava(value); |
1443 | |
|
1444 | 60 | retVal = "\"" + retVal + "\""; |
1445 | 60 | return retVal; |
1446 | |
} |
1447 | |
|
1448 | |
|
1449 | |
|
1450 | |
|
1451 | |
|
1452 | |
|
1453 | |
|
1454 | |
@SuppressWarnings("unchecked") |
1455 | |
public static List<PropertyCollection<?, ?>> getDependentSchemaList( |
1456 | |
PropertyCollection<?, ?> schema) |
1457 | |
{ |
1458 | 28 | PropertyCollection<?, ?> dependentSchemaList = |
1459 | |
(PropertyCollection<?, ?>) schema |
1460 | |
.getPropertyValue(DeducedSchemaLayer.DEPENDENT_SCHEMA_LIST_INSTANCE |
1461 | |
.getKey()); |
1462 | |
|
1463 | 28 | return (List<PropertyCollection<?, ?>>) dependentSchemaList |
1464 | |
.asValueList(); |
1465 | |
} |
1466 | |
|
1467 | |
|
1468 | |
|
1469 | |
|
1470 | |
|
1471 | |
|
1472 | |
|
1473 | |
@SuppressWarnings("unchecked") |
1474 | |
public static List<PropertyCollection<?, ?>> getModelSchemaList( |
1475 | |
PropertyCollection<?, ?> model) |
1476 | |
{ |
1477 | 14 | PropertyCollection<?, ?> schemaList = |
1478 | |
(PropertyCollection<?, ?>) model |
1479 | |
.getPropertyValue(DeducedModelLayer.SCHEMA_LIST_INSTANCE |
1480 | |
.getKey()); |
1481 | |
|
1482 | 14 | return (List<PropertyCollection<?, ?>>) schemaList.asValueList(); |
1483 | |
} |
1484 | |
|
1485 | |
|
1486 | |
|
1487 | |
|
1488 | |
|
1489 | |
|
1490 | |
|
1491 | |
@SuppressWarnings("unchecked") |
1492 | |
public static List<PropertyCollection<?, ?>> removePropertyListTypeFromList( |
1493 | |
List<PropertyCollection<?, ?>> typeList) |
1494 | |
{ |
1495 | 0 | List<PropertyCollection<?, ?>> retVal = |
1496 | |
new ArrayList<PropertyCollection<?, ?>>(typeList); |
1497 | |
|
1498 | 0 | retVal.remove(PropertyList.PROPERTY_LIST_TYPE |
1499 | |
.getPropertyCollectionType()); |
1500 | |
|
1501 | 0 | return retVal; |
1502 | |
} |
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
|
1510 | |
public static String getHolderClassName( |
1511 | |
PropertyCollection<?, ?> objectToHold) |
1512 | |
{ |
1513 | 20 | if (objectToHold == null) |
1514 | |
{ |
1515 | 1 | return null; |
1516 | |
} |
1517 | |
|
1518 | 19 | PropertyCollection<?, ?> type = objectToHold.type(); |
1519 | |
|
1520 | 19 | String retVal = null; |
1521 | |
|
1522 | 19 | if (DeducedUtilities.isInstanceOf(type, |
1523 | |
OrderedPropertyListType.ORDERED_PROPERTY_LIST_TYPE_TYPE |
1524 | |
.getPropertyCollectionType())) |
1525 | |
{ |
1526 | 1 | retVal = OrderedPropertyListTypeHolder.class.getName(); |
1527 | |
} |
1528 | 18 | else if (DeducedUtilities |
1529 | |
.isInstanceOf( |
1530 | |
type, |
1531 | |
OrderingPropertyCollectionType.ORDERING_PROPERTY_COLLECTION_TYPE_TYPE |
1532 | |
.getPropertyCollectionType())) |
1533 | |
{ |
1534 | 1 | retVal = OrderingPropertyCollectionTypeHolder.class.getName(); |
1535 | |
} |
1536 | 17 | else if (DeducedUtilities.isInstanceOf(type, |
1537 | |
PropertyCollectionType.PROPERTY_COLLECTION_TYPE_TYPE |
1538 | |
.getPropertyCollectionType())) |
1539 | |
{ |
1540 | 13 | retVal = PropertyCollectionTypeHolder.class.getName(); |
1541 | |
} |
1542 | 4 | else if (DeducedUtilities.isInstanceOf(type, |
1543 | |
PropertyType.PROPERTY_TYPE_TYPE.getPropertyCollectionType())) |
1544 | |
{ |
1545 | 1 | retVal = PropertyTypeHolder.class.getName(); |
1546 | |
} |
1547 | 3 | else if (DeducedUtilities |
1548 | |
.isInstanceOf( |
1549 | |
type, |
1550 | |
PropertyCollectionListInstance.PROPERTY_COLLECTION_LIST_INSTANCE_TYPE |
1551 | |
.getPropertyCollectionType())) |
1552 | |
{ |
1553 | 1 | retVal = PropertyCollectionListInstanceHolder.class.getName(); |
1554 | |
} |
1555 | 2 | else if (DeducedUtilities |
1556 | |
.isInstanceOf(type, PropertyInstance.PROPERTY_INSTANCE_TYPE |
1557 | |
.getPropertyCollectionType())) |
1558 | |
{ |
1559 | 1 | retVal = PropertyInstanceHolder.class.getName(); |
1560 | |
} |
1561 | |
|
1562 | 19 | return retVal; |
1563 | |
} |
1564 | |
|
1565 | |
} |