1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks;
21
22 import java.util.Vector;
23
24 import org.apache.tools.ant.BuildException;
25 import org.apache.tools.ant.types.DataType;
26 import org.apache.tools.ant.types.Reference;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public final class VersionInfo extends DataType {
45
46
47
48 private String ifCond;
49
50
51
52 private String unlessCond;
53
54
55
56
57 private Reference extendsRef;
58
59
60
61
62
63 private String fileVersion;
64
65
66
67
68 private String productVersion;
69
70
71
72
73 private String language;
74
75
76
77
78
79 private String fileComments;
80
81
82
83
84 private String companyName;
85
86
87
88
89 private String fileDescription;
90
91
92
93 private String internalName;
94
95
96
97
98 private String legalCopyright;
99
100
101
102
103 private String legalTrademarks;
104
105
106
107
108 private String originalFilename;
109
110
111
112
113 private String privateBuild;
114
115
116
117
118 private String productName;
119
120
121
122 private String specialBuild;
123
124
125
126
127 private String compatibilityVersion;
128
129
130
131
132
133 private Boolean prerelease;
134
135
136
137
138
139 private Boolean patched;
140
141
142
143
144
145 public VersionInfo() {
146 }
147
148
149
150
151
152
153
154 private VersionInfo(final Vector<VersionInfo> stack) {
155 VersionInfo source = null;
156 for (int i = stack.size() - 1; i >= 0; i--) {
157 source = stack.elementAt(i);
158 if (source.getIf() != null) {
159 this.ifCond = source.getIf();
160 }
161 if (source.getUnless() != null) {
162 this.unlessCond = source.getUnless();
163 }
164 if (source.getFileversion() != null) {
165 this.fileVersion = source.getFileversion();
166 }
167 if (source.getProductversion() != null) {
168 this.productVersion = source.getProductversion();
169 }
170 if (source.getLanguage() != null) {
171 this.language = source.getLanguage();
172 }
173 if (source.getFilecomments() != null) {
174 this.fileComments = source.getFilecomments();
175 }
176 if (source.getCompanyname() != null) {
177 this.companyName = source.getCompanyname();
178 }
179 if (source.getFiledescription() != null) {
180 this.fileDescription = source.getFiledescription();
181 }
182 if (source.getInternalname() != null) {
183 this.internalName = source.getInternalname();
184 }
185 if (source.getLegalcopyright() != null) {
186 this.legalCopyright = source.getLegalcopyright();
187 }
188 if (source.getLegaltrademarks() != null) {
189 this.legalTrademarks = source.getLegaltrademarks();
190 }
191 if (source.getOriginalfilename() != null) {
192 this.originalFilename = source.getOriginalfilename();
193 }
194 if (source.getPrivatebuild() != null) {
195 this.privateBuild = source.getPrivatebuild();
196 }
197 if (source.getProductname() != null) {
198 this.productName = source.getProductname();
199 }
200 if (source.getSpecialbuild() != null) {
201 this.specialBuild = source.getSpecialbuild();
202 }
203 if (source.getCompatibilityversion() != null) {
204 this.compatibilityVersion = source.getCompatibilityversion();
205 }
206 if (source.getPrerelease() != null) {
207 this.prerelease = source.getPrerelease();
208 }
209 if (source.getPatched() != null) {
210 this.patched = source.getPatched();
211 }
212 }
213 setProject(source.getProject());
214 }
215
216
217
218
219
220
221
222
223 public void execute() throws org.apache.tools.ant.BuildException {
224 throw new org.apache.tools.ant.BuildException("Not an actual task, but looks like one for documentation purposes");
225 }
226
227
228
229
230
231
232 public String getCompanyname() {
233 return this.companyName;
234 }
235
236
237
238
239
240
241 public String getCompatibilityversion() {
242 return this.compatibilityVersion;
243 }
244
245 public Reference getExtends() {
246 return this.extendsRef;
247 }
248
249
250
251
252
253
254 public String getFilecomments() {
255 return this.fileComments;
256 }
257
258
259
260
261
262
263 public String getFiledescription() {
264 return this.fileDescription;
265 }
266
267
268
269
270
271
272
273 public String getFileversion() {
274 return this.fileVersion;
275 }
276
277
278
279
280
281
282 public final String getIf() {
283 return this.ifCond;
284 }
285
286
287
288
289
290
291 public String getInternalname() {
292 return this.internalName;
293 }
294
295
296
297
298
299
300
301 public String getLanguage() {
302 return this.language;
303 }
304
305
306
307
308
309
310 public String getLegalcopyright() {
311 return this.legalCopyright;
312 }
313
314
315
316
317
318
319 public String getLegaltrademarks() {
320 return this.legalTrademarks;
321 }
322
323
324
325
326
327
328 public String getOriginalfilename() {
329 return this.originalFilename;
330 }
331
332
333
334
335
336
337 public Boolean getPatched() {
338 return this.patched;
339 }
340
341
342
343
344
345
346 public Boolean getPrerelease() {
347 return this.prerelease;
348 }
349
350
351
352
353
354
355 public String getPrivatebuild() {
356 return this.privateBuild;
357 }
358
359
360
361
362
363
364 public String getProductname() {
365 return this.productName;
366 }
367
368
369
370
371
372
373 public String getProductversion() {
374 return this.productVersion;
375 }
376
377
378
379
380
381
382 public String getSpecialbuild() {
383 return this.specialBuild;
384 }
385
386
387
388
389
390
391 public final String getUnless() {
392 return this.unlessCond;
393 }
394
395
396
397
398
399
400
401
402 public final boolean isActive() throws BuildException {
403 return CUtil.isActive(getProject(), this.ifCond, this.unlessCond);
404 }
405
406
407
408
409
410
411
412 public VersionInfo merge() {
413 if (isReference()) {
414 final VersionInfo refVersion = (VersionInfo) getCheckedRef(VersionInfo.class, "VersionInfo");
415 return refVersion.merge();
416 }
417 Reference currentRef = this.getExtends();
418 if (currentRef == null) {
419 return this;
420 }
421 final Vector<VersionInfo> stack = new Vector<>(5);
422 stack.addElement(this);
423 while (currentRef != null) {
424 final Object obj = currentRef.getReferencedObject(getProject());
425 if (obj instanceof VersionInfo) {
426 VersionInfo current = (VersionInfo) obj;
427 if (current.isReference()) {
428 current = (VersionInfo) current.getCheckedRef(VersionInfo.class, "VersionInfo");
429 }
430 if (stack.contains(current)) {
431 throw this.circularReference();
432 }
433 stack.addElement(current);
434 currentRef = current.getExtends();
435 } else {
436 throw new BuildException("Referenced element " + currentRef.getRefId() + " is not a versioninfo.");
437 }
438 }
439 return new VersionInfo(stack);
440 }
441
442
443
444
445
446
447
448
449
450 public void setCompanyname(final String value) throws BuildException {
451 if (isReference()) {
452 throw tooManyAttributes();
453 }
454 this.companyName = value;
455 }
456
457
458
459
460
461
462
463
464
465 public void setCompatibilityversion(final String value) throws BuildException {
466 if (isReference()) {
467 throw tooManyAttributes();
468 }
469 this.compatibilityVersion = value;
470 }
471
472
473
474
475
476
477
478
479
480
481
482
483 public void setExtends(final Reference extendsRef) throws BuildException {
484 if (isReference()) {
485 throw tooManyAttributes();
486 }
487 this.extendsRef = extendsRef;
488 }
489
490
491
492
493
494
495
496
497
498 public void setFilecomments(final String value) throws BuildException {
499 if (isReference()) {
500 throw tooManyAttributes();
501 }
502 this.fileComments = value;
503 }
504
505
506
507
508
509
510
511 public void setFiledescription(final String value) {
512 if (isReference()) {
513 throw tooManyAttributes();
514 }
515 this.fileDescription = value;
516 }
517
518
519
520
521
522
523
524
525
526 public void setFileversion(final String value) throws BuildException {
527 if (isReference()) {
528 throw tooManyAttributes();
529 }
530 this.fileVersion = value;
531 }
532
533
534
535
536
537
538
539 public void setId(final String id) {
540
541
542
543
544 }
545
546
547
548
549
550
551
552
553
554
555
556
557
558 public final void setIf(final String propName) {
559 if (isReference()) {
560 throw tooManyAttributes();
561 }
562 this.ifCond = propName;
563 }
564
565
566
567
568
569
570
571
572
573
574
575 public void setInternalname(final String value) throws BuildException {
576 if (isReference()) {
577 throw tooManyAttributes();
578 }
579 this.internalName = value;
580 }
581
582
583
584
585
586
587
588
589
590 public void setLanguage(final String value) throws BuildException {
591 if (isReference()) {
592 throw tooManyAttributes();
593 }
594 this.language = value;
595 }
596
597
598
599
600
601
602
603
604
605 public void setLegalcopyright(final String value) throws BuildException {
606 if (isReference()) {
607 throw tooManyAttributes();
608 }
609 this.legalCopyright = value;
610 }
611
612
613
614
615
616
617
618
619
620 public void setLegaltrademarks(final String value) throws BuildException {
621 if (isReference()) {
622 throw tooManyAttributes();
623 }
624 this.legalTrademarks = value;
625 }
626
627
628
629
630
631
632
633
634
635
636 public void setOriginalfilename(final String value) throws BuildException {
637 if (isReference()) {
638 throw tooManyAttributes();
639 }
640 this.originalFilename = value;
641 }
642
643
644
645
646
647
648
649
650
651 public void setPatched(final boolean value) throws BuildException {
652 if (isReference()) {
653 throw tooManyAttributes();
654 }
655 if (value) {
656 this.patched = Boolean.TRUE;
657 } else {
658 this.patched = Boolean.FALSE;
659 }
660 }
661
662
663
664
665
666
667
668
669
670 public void setPrerelease(final boolean value) throws BuildException {
671 if (isReference()) {
672 throw tooManyAttributes();
673 }
674 if (value) {
675 this.prerelease = Boolean.TRUE;
676 } else {
677 this.prerelease = Boolean.FALSE;
678 }
679 }
680
681
682
683
684
685
686
687
688
689 public void setPrivatebuild(final String value) throws BuildException {
690 if (isReference()) {
691 throw tooManyAttributes();
692 }
693 this.privateBuild = value;
694 }
695
696
697
698
699
700
701
702
703
704 public void setProductname(final String value) throws BuildException {
705 if (isReference()) {
706 throw tooManyAttributes();
707 }
708 this.productName = value;
709 }
710
711
712
713
714
715
716
717
718
719 public void setProductversion(final String value) throws BuildException {
720 if (isReference()) {
721 throw tooManyAttributes();
722 }
723 this.productVersion = value;
724 }
725
726
727
728
729
730
731
732 @Override
733 public void setRefid(final Reference r) throws BuildException {
734 super.setRefid(r);
735 }
736
737
738
739
740
741
742
743
744
745 public void setSpecialbuild(final String value) throws BuildException {
746 if (isReference()) {
747 throw tooManyAttributes();
748 }
749 this.specialBuild = value;
750 }
751
752
753
754
755
756
757
758
759
760
761
762
763
764 public final void setUnless(final String propName) {
765 if (isReference()) {
766 throw tooManyAttributes();
767 }
768 this.unlessCond = propName;
769 }
770 }