1
2
3
4
5
6 package org.apache.maven.buildcache.xml.config.io.xpp3;
7
8
9
10
11
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.io.Reader;
15 import java.text.DateFormat;
16 import org.apache.maven.buildcache.xml.config.AttachedOutputs;
17 import org.apache.maven.buildcache.xml.config.CacheConfig;
18 import org.apache.maven.buildcache.xml.config.Configuration;
19 import org.apache.maven.buildcache.xml.config.CoordinatesBase;
20 import org.apache.maven.buildcache.xml.config.DirName;
21 import org.apache.maven.buildcache.xml.config.DirScanConfig;
22 import org.apache.maven.buildcache.xml.config.Discovery;
23 import org.apache.maven.buildcache.xml.config.EffectivePom;
24 import org.apache.maven.buildcache.xml.config.Exclude;
25 import org.apache.maven.buildcache.xml.config.Executables;
26 import org.apache.maven.buildcache.xml.config.ExecutionConfigurationScan;
27 import org.apache.maven.buildcache.xml.config.ExecutionControl;
28 import org.apache.maven.buildcache.xml.config.ExecutionIdsList;
29 import org.apache.maven.buildcache.xml.config.GoalId;
30 import org.apache.maven.buildcache.xml.config.GoalReconciliation;
31 import org.apache.maven.buildcache.xml.config.GoalsList;
32 import org.apache.maven.buildcache.xml.config.Include;
33 import org.apache.maven.buildcache.xml.config.Input;
34 import org.apache.maven.buildcache.xml.config.Local;
35 import org.apache.maven.buildcache.xml.config.MultiModule;
36 import org.apache.maven.buildcache.xml.config.Output;
37 import org.apache.maven.buildcache.xml.config.OutputExclude;
38 import org.apache.maven.buildcache.xml.config.PathSet;
39 import org.apache.maven.buildcache.xml.config.PluginConfigurationScan;
40 import org.apache.maven.buildcache.xml.config.PluginSet;
41 import org.apache.maven.buildcache.xml.config.ProjectVersioning;
42 import org.apache.maven.buildcache.xml.config.PropertyName;
43 import org.apache.maven.buildcache.xml.config.Reconcile;
44 import org.apache.maven.buildcache.xml.config.Remote;
45 import org.apache.maven.buildcache.xml.config.TagExclude;
46 import org.apache.maven.buildcache.xml.config.TagScanConfig;
47 import org.apache.maven.buildcache.xml.config.TrackedProperty;
48 import org.codehaus.plexus.util.ReaderFactory;
49 import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
50 import org.codehaus.plexus.util.xml.pull.MXParser;
51 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
52 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
53
54
55
56
57
58
59 @SuppressWarnings( "all" )
60 public class BuildCacheConfigXpp3Reader
61 {
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 private boolean addDefaultEntities = true;
78
79
80
81
82 public final ContentTransformer contentTransformer;
83
84
85
86
87
88
89 public BuildCacheConfigXpp3Reader()
90 {
91 this( new ContentTransformer()
92 {
93 public String transform( String source, String fieldName )
94 {
95 return source;
96 }
97 } );
98 }
99
100 public BuildCacheConfigXpp3Reader(ContentTransformer contentTransformer)
101 {
102 this.contentTransformer = contentTransformer;
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed )
122 throws XmlPullParserException
123 {
124 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
125 {
126 return false;
127 }
128 if ( !parsed.add( tagName ) )
129 {
130 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
131 }
132 return true;
133 }
134
135
136
137
138
139
140
141
142
143
144
145
146 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
147 throws XmlPullParserException, IOException
148 {
149
150 if ( strict )
151 {
152 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
153 }
154 }
155
156
157
158
159
160
161
162
163
164
165 private void checkUnknownElement( XmlPullParser parser, boolean strict )
166 throws XmlPullParserException, IOException
167 {
168 if ( strict )
169 {
170 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
171 }
172
173 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
174 {
175 int eventType = parser.next();
176 if ( eventType == XmlPullParser.START_TAG )
177 {
178 unrecognizedTagCount++;
179 }
180 else if ( eventType == XmlPullParser.END_TAG )
181 {
182 unrecognizedTagCount--;
183 }
184 }
185 }
186
187
188
189
190
191
192 public boolean getAddDefaultEntities()
193 {
194 return addDefaultEntities;
195 }
196
197
198
199
200
201
202
203
204
205
206
207 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
208 throws XmlPullParserException
209 {
210 return getBooleanValue( s, attribute, parser, null );
211 }
212
213
214
215
216
217
218
219
220
221
222
223
224 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
225 throws XmlPullParserException
226 {
227 if ( s != null && s.length() != 0 )
228 {
229 return Boolean.valueOf( s ).booleanValue();
230 }
231 if ( defaultValue != null )
232 {
233 return Boolean.valueOf( defaultValue ).booleanValue();
234 }
235 return false;
236 }
237
238
239
240
241
242
243
244
245
246
247
248
249 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
250 throws XmlPullParserException
251 {
252 if ( s != null )
253 {
254 try
255 {
256 return Byte.valueOf( s ).byteValue();
257 }
258 catch ( NumberFormatException nfe )
259 {
260 if ( strict )
261 {
262 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
263 }
264 }
265 }
266 return 0;
267 }
268
269
270
271
272
273
274
275
276
277
278
279 private char getCharacterValue( String s, String attribute, XmlPullParser parser )
280 throws XmlPullParserException
281 {
282 if ( s != null )
283 {
284 return s.charAt( 0 );
285 }
286 return 0;
287 }
288
289
290
291
292
293
294
295
296
297
298
299 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
300 throws XmlPullParserException
301 {
302 return getDateValue( s, attribute, null, parser );
303 }
304
305
306
307
308
309
310
311
312
313
314
315
316 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
317 throws XmlPullParserException
318 {
319 if ( s != null )
320 {
321 String effectiveDateFormat = dateFormat;
322 if ( dateFormat == null )
323 {
324 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
325 }
326 if ( "long".equals( effectiveDateFormat ) )
327 {
328 try
329 {
330 return new java.util.Date( Long.parseLong( s ) );
331 }
332 catch ( NumberFormatException e )
333 {
334 throw new XmlPullParserException( e.getMessage(), parser, e );
335 }
336 }
337 else
338 {
339 try
340 {
341 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
342 return dateParser.parse( s );
343 }
344 catch ( java.text.ParseException e )
345 {
346 throw new XmlPullParserException( e.getMessage(), parser, e );
347 }
348 }
349 }
350 return null;
351 }
352
353
354
355
356
357
358
359
360
361
362
363
364 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
365 throws XmlPullParserException
366 {
367 if ( s != null )
368 {
369 try
370 {
371 return Double.valueOf( s ).doubleValue();
372 }
373 catch ( NumberFormatException nfe )
374 {
375 if ( strict )
376 {
377 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
378 }
379 }
380 }
381 return 0;
382 }
383
384
385
386
387
388
389
390
391
392
393
394
395 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
396 throws XmlPullParserException
397 {
398 if ( s != null )
399 {
400 try
401 {
402 return Float.valueOf( s ).floatValue();
403 }
404 catch ( NumberFormatException nfe )
405 {
406 if ( strict )
407 {
408 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
409 }
410 }
411 }
412 return 0;
413 }
414
415
416
417
418
419
420
421
422
423
424
425
426 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
427 throws XmlPullParserException
428 {
429 if ( s != null )
430 {
431 try
432 {
433 return Integer.valueOf( s ).intValue();
434 }
435 catch ( NumberFormatException nfe )
436 {
437 if ( strict )
438 {
439 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
440 }
441 }
442 }
443 return 0;
444 }
445
446
447
448
449
450
451
452
453
454
455
456
457 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
458 throws XmlPullParserException
459 {
460 if ( s != null )
461 {
462 try
463 {
464 return Long.valueOf( s ).longValue();
465 }
466 catch ( NumberFormatException nfe )
467 {
468 if ( strict )
469 {
470 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
471 }
472 }
473 }
474 return 0;
475 }
476
477
478
479
480
481
482
483
484
485
486
487
488 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
489 throws XmlPullParserException
490 {
491 if ( s == null )
492 {
493 if ( strict )
494 {
495 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
496 }
497 }
498 return s;
499 }
500
501
502
503
504
505
506
507
508
509
510
511
512 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
513 throws XmlPullParserException
514 {
515 if ( s != null )
516 {
517 try
518 {
519 return Short.valueOf( s ).shortValue();
520 }
521 catch ( NumberFormatException nfe )
522 {
523 if ( strict )
524 {
525 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
526 }
527 }
528 }
529 return 0;
530 }
531
532
533
534
535
536
537
538 private String getTrimmedValue( String s )
539 {
540 if ( s != null )
541 {
542 s = s.trim();
543 }
544 return s;
545 }
546
547
548
549
550
551
552
553
554 private String interpolatedTrimmed( String value, String context )
555 {
556 return getTrimmedValue( contentTransformer.transform( value, context ) );
557 }
558
559
560
561
562
563
564
565
566
567
568 private int nextTag( XmlPullParser parser )
569 throws IOException, XmlPullParserException
570 {
571 int eventType = parser.next();
572 if ( eventType == XmlPullParser.TEXT )
573 {
574 eventType = parser.next();
575 }
576 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
577 {
578 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
579 }
580 return eventType;
581 }
582
583
584
585
586
587
588
589
590
591
592
593 public CacheConfig read( XmlPullParser parser, boolean strict )
594 throws IOException, XmlPullParserException
595 {
596 CacheConfig cacheConfig = null;
597 int eventType = parser.getEventType();
598 boolean parsed = false;
599 while ( eventType != XmlPullParser.END_DOCUMENT )
600 {
601 if ( eventType == XmlPullParser.START_TAG )
602 {
603 if ( strict && ! "cache".equals( parser.getName() ) )
604 {
605 throw new XmlPullParserException( "Expected root element 'cache' but found '" + parser.getName() + "'", parser, null );
606 }
607 else if ( parsed )
608 {
609
610 throw new XmlPullParserException( "Duplicated tag: 'cache'", parser, null );
611 }
612 cacheConfig = parseCacheConfig( parser, strict );
613 cacheConfig.setModelEncoding( parser.getInputEncoding() );
614 parsed = true;
615 }
616 eventType = parser.next();
617 }
618 if ( parsed )
619 {
620 return cacheConfig;
621 }
622 throw new XmlPullParserException( "Expected root element 'cache' but found no element at all: invalid XML document", parser, null );
623 }
624
625
626
627
628
629
630
631
632
633
634
635 public CacheConfig read( Reader reader, boolean strict )
636 throws IOException, XmlPullParserException
637 {
638 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
639
640 parser.setInput( reader );
641
642
643 return read( parser, strict );
644 }
645
646
647
648
649
650
651
652
653
654
655 public CacheConfig read( Reader reader )
656 throws IOException, XmlPullParserException
657 {
658 return read( reader, true );
659 }
660
661
662
663
664
665
666
667
668
669
670
671 public CacheConfig read( InputStream in, boolean strict )
672 throws IOException, XmlPullParserException
673 {
674 return read( ReaderFactory.newXmlReader( in ), strict );
675 }
676
677
678
679
680
681
682
683
684
685
686 public CacheConfig read( InputStream in )
687 throws IOException, XmlPullParserException
688 {
689 return read( ReaderFactory.newXmlReader( in ) );
690 }
691
692
693
694
695
696
697
698
699
700
701
702 private AttachedOutputs parseAttachedOutputs( XmlPullParser parser, boolean strict )
703 throws IOException, XmlPullParserException
704 {
705 String tagName = parser.getName();
706 AttachedOutputs attachedOutputs = new AttachedOutputs();
707 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
708 {
709 String name = parser.getAttributeName( i );
710 String value = parser.getAttributeValue( i );
711
712 if ( name.indexOf( ':' ) >= 0 )
713 {
714
715 }
716 else
717 {
718 checkUnknownAttribute( parser, name, tagName, strict );
719 }
720 }
721 java.util.Set parsed = new java.util.HashSet();
722 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
723 {
724 if ( checkFieldWithDuplicate( parser, "dirNames", null, parsed ) )
725 {
726 java.util.List<DirName> dirNames = new java.util.ArrayList<DirName>();
727 while ( parser.nextTag() == XmlPullParser.START_TAG )
728 {
729 if ( "dirName".equals( parser.getName() ) )
730 {
731 dirNames.add( parseDirName( parser, strict ) );
732 }
733 else
734 {
735 checkUnknownElement( parser, strict );
736 }
737 }
738 attachedOutputs.setDirNames( dirNames );
739 }
740 else
741 {
742 checkUnknownElement( parser, strict );
743 }
744 }
745 return attachedOutputs;
746 }
747
748
749
750
751
752
753
754
755
756
757
758 private CacheConfig parseCacheConfig( XmlPullParser parser, boolean strict )
759 throws IOException, XmlPullParserException
760 {
761 String tagName = parser.getName();
762 CacheConfig cacheConfig = new CacheConfig();
763 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
764 {
765 String name = parser.getAttributeName( i );
766 String value = parser.getAttributeValue( i );
767
768 if ( name.indexOf( ':' ) >= 0 )
769 {
770
771 }
772 else if ( "xmlns".equals( name ) )
773 {
774
775 }
776 else
777 {
778 checkUnknownAttribute( parser, name, tagName, strict );
779 }
780 }
781 java.util.Set parsed = new java.util.HashSet();
782 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
783 {
784 if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
785 {
786 cacheConfig.setConfiguration( parseConfiguration( parser, strict ) );
787 }
788 else if ( checkFieldWithDuplicate( parser, "input", null, parsed ) )
789 {
790 cacheConfig.setInput( parseInput( parser, strict ) );
791 }
792 else if ( checkFieldWithDuplicate( parser, "output", null, parsed ) )
793 {
794 cacheConfig.setOutput( parseOutput( parser, strict ) );
795 }
796 else if ( checkFieldWithDuplicate( parser, "executionControl", null, parsed ) )
797 {
798 cacheConfig.setExecutionControl( parseExecutionControl( parser, strict ) );
799 }
800 else
801 {
802 checkUnknownElement( parser, strict );
803 }
804 }
805 return cacheConfig;
806 }
807
808
809
810
811
812
813
814
815
816
817
818 private Configuration parseConfiguration( XmlPullParser parser, boolean strict )
819 throws IOException, XmlPullParserException
820 {
821 String tagName = parser.getName();
822 Configuration configuration = new Configuration();
823 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
824 {
825 String name = parser.getAttributeName( i );
826 String value = parser.getAttributeValue( i );
827
828 if ( name.indexOf( ':' ) >= 0 )
829 {
830
831 }
832 else
833 {
834 checkUnknownAttribute( parser, name, tagName, strict );
835 }
836 }
837 java.util.Set parsed = new java.util.HashSet();
838 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
839 {
840 if ( checkFieldWithDuplicate( parser, "enabled", null, parsed ) )
841 {
842 configuration.setEnabled( getBooleanValue( interpolatedTrimmed( parser.nextText(), "enabled" ), "enabled", parser, "true" ) );
843 }
844 else if ( checkFieldWithDuplicate( parser, "hashAlgorithm", null, parsed ) )
845 {
846 configuration.setHashAlgorithm( interpolatedTrimmed( parser.nextText(), "hashAlgorithm" ) );
847 }
848 else if ( checkFieldWithDuplicate( parser, "validateXml", null, parsed ) )
849 {
850 configuration.setValidateXml( getBooleanValue( interpolatedTrimmed( parser.nextText(), "validateXml" ), "validateXml", parser, "false" ) );
851 }
852 else if ( checkFieldWithDuplicate( parser, "mandatoryClean", null, parsed ) )
853 {
854 configuration.setMandatoryClean( getBooleanValue( interpolatedTrimmed( parser.nextText(), "mandatoryClean" ), "mandatoryClean", parser, "false" ) );
855 }
856 else if ( checkFieldWithDuplicate( parser, "multiModule", null, parsed ) )
857 {
858 configuration.setMultiModule( parseMultiModule( parser, strict ) );
859 }
860 else if ( checkFieldWithDuplicate( parser, "projectVersioning", null, parsed ) )
861 {
862 configuration.setProjectVersioning( parseProjectVersioning( parser, strict ) );
863 }
864 else if ( checkFieldWithDuplicate( parser, "remote", null, parsed ) )
865 {
866 configuration.setRemote( parseRemote( parser, strict ) );
867 }
868 else if ( checkFieldWithDuplicate( parser, "attachedOutputs", null, parsed ) )
869 {
870 configuration.setAttachedOutputs( parseAttachedOutputs( parser, strict ) );
871 }
872 else if ( checkFieldWithDuplicate( parser, "local", null, parsed ) )
873 {
874 configuration.setLocal( parseLocal( parser, strict ) );
875 }
876 else if ( checkFieldWithDuplicate( parser, "debugs", null, parsed ) )
877 {
878 java.util.List<String> debugs = new java.util.ArrayList<String>();
879 while ( parser.nextTag() == XmlPullParser.START_TAG )
880 {
881 if ( "debug".equals( parser.getName() ) )
882 {
883 debugs.add( interpolatedTrimmed( parser.nextText(), "debugs" ) );
884 }
885 else
886 {
887 checkUnknownElement( parser, strict );
888 }
889 }
890 configuration.setDebugs( debugs );
891 }
892 else
893 {
894 checkUnknownElement( parser, strict );
895 }
896 }
897 return configuration;
898 }
899
900
901
902
903
904
905
906
907
908
909
910 private CoordinatesBase parseCoordinatesBase( XmlPullParser parser, boolean strict )
911 throws IOException, XmlPullParserException
912 {
913 String tagName = parser.getName();
914 CoordinatesBase coordinatesBase = new CoordinatesBase();
915 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
916 {
917 String name = parser.getAttributeName( i );
918 String value = parser.getAttributeValue( i );
919
920 if ( name.indexOf( ':' ) >= 0 )
921 {
922
923 }
924 else if ( "groupId".equals( name ) )
925 {
926 coordinatesBase.setGroupId( interpolatedTrimmed( value, "groupId" ) );
927 }
928 else if ( "artifactId".equals( name ) )
929 {
930 coordinatesBase.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
931 }
932 else
933 {
934 checkUnknownAttribute( parser, name, tagName, strict );
935 }
936 }
937 java.util.Set parsed = new java.util.HashSet();
938 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
939 {
940 checkUnknownElement( parser, strict );
941 }
942 return coordinatesBase;
943 }
944
945
946
947
948
949
950
951
952
953
954
955 private DirName parseDirName( XmlPullParser parser, boolean strict )
956 throws IOException, XmlPullParserException
957 {
958 String tagName = parser.getName();
959 DirName dirName = new DirName();
960 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
961 {
962 String name = parser.getAttributeName( i );
963 String value = parser.getAttributeValue( i );
964
965 if ( name.indexOf( ':' ) >= 0 )
966 {
967
968 }
969 else if ( "glob".equals( name ) )
970 {
971 dirName.setGlob( interpolatedTrimmed( value, "glob" ) );
972 }
973 else
974 {
975 checkUnknownAttribute( parser, name, tagName, strict );
976 }
977 }
978 dirName.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
979 return dirName;
980 }
981
982
983
984
985
986
987
988
989
990
991
992 private DirScanConfig parseDirScanConfig( XmlPullParser parser, boolean strict )
993 throws IOException, XmlPullParserException
994 {
995 String tagName = parser.getName();
996 DirScanConfig dirScanConfig = new DirScanConfig();
997 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
998 {
999 String name = parser.getAttributeName( i );
1000 String value = parser.getAttributeValue( i );
1001
1002 if ( name.indexOf( ':' ) >= 0 )
1003 {
1004
1005 }
1006 else if ( "ignoreParent".equals( name ) )
1007 {
1008 dirScanConfig.setIgnoreParent( getBooleanValue( interpolatedTrimmed( value, "ignoreParent" ), "ignoreParent", parser, "false" ) );
1009 }
1010 else if ( "mode".equals( name ) )
1011 {
1012 dirScanConfig.setMode( interpolatedTrimmed( value, "mode" ) );
1013 }
1014 else
1015 {
1016 checkUnknownAttribute( parser, name, tagName, strict );
1017 }
1018 }
1019 java.util.Set parsed = new java.util.HashSet();
1020 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1021 {
1022 if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1023 {
1024 java.util.List<TagScanConfig> includes = new java.util.ArrayList<TagScanConfig>();
1025 while ( parser.nextTag() == XmlPullParser.START_TAG )
1026 {
1027 if ( "include".equals( parser.getName() ) )
1028 {
1029 includes.add( parseTagScanConfig( parser, strict ) );
1030 }
1031 else
1032 {
1033 checkUnknownElement( parser, strict );
1034 }
1035 }
1036 dirScanConfig.setIncludes( includes );
1037 }
1038 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1039 {
1040 java.util.List<TagExclude> excludes = new java.util.ArrayList<TagExclude>();
1041 while ( parser.nextTag() == XmlPullParser.START_TAG )
1042 {
1043 if ( "exclude".equals( parser.getName() ) )
1044 {
1045 excludes.add( parseTagExclude( parser, strict ) );
1046 }
1047 else
1048 {
1049 checkUnknownElement( parser, strict );
1050 }
1051 }
1052 dirScanConfig.setExcludes( excludes );
1053 }
1054 else if ( checkFieldWithDuplicate( parser, "tagScanConfigs", null, parsed ) )
1055 {
1056 java.util.List<TagScanConfig> tagScanConfigs = new java.util.ArrayList<TagScanConfig>();
1057 while ( parser.nextTag() == XmlPullParser.START_TAG )
1058 {
1059 if ( "tagScanConfig".equals( parser.getName() ) )
1060 {
1061 tagScanConfigs.add( parseTagScanConfig( parser, strict ) );
1062 }
1063 else
1064 {
1065 checkUnknownElement( parser, strict );
1066 }
1067 }
1068 dirScanConfig.setTagScanConfigs( tagScanConfigs );
1069 }
1070 else
1071 {
1072 checkUnknownElement( parser, strict );
1073 }
1074 }
1075 return dirScanConfig;
1076 }
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088 private Discovery parseDiscovery( XmlPullParser parser, boolean strict )
1089 throws IOException, XmlPullParserException
1090 {
1091 String tagName = parser.getName();
1092 Discovery discovery = new Discovery();
1093 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1094 {
1095 String name = parser.getAttributeName( i );
1096 String value = parser.getAttributeValue( i );
1097
1098 if ( name.indexOf( ':' ) >= 0 )
1099 {
1100
1101 }
1102 else
1103 {
1104 checkUnknownAttribute( parser, name, tagName, strict );
1105 }
1106 }
1107 java.util.Set parsed = new java.util.HashSet();
1108 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1109 {
1110 if ( checkFieldWithDuplicate( parser, "scanProfiles", null, parsed ) )
1111 {
1112 java.util.List<String> scanProfiles = new java.util.ArrayList<String>();
1113 while ( parser.nextTag() == XmlPullParser.START_TAG )
1114 {
1115 if ( "scanProfile".equals( parser.getName() ) )
1116 {
1117 scanProfiles.add( interpolatedTrimmed( parser.nextText(), "scanProfiles" ) );
1118 }
1119 else
1120 {
1121 checkUnknownElement( parser, strict );
1122 }
1123 }
1124 discovery.setScanProfiles( scanProfiles );
1125 }
1126 else
1127 {
1128 checkUnknownElement( parser, strict );
1129 }
1130 }
1131 return discovery;
1132 }
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144 private EffectivePom parseEffectivePom( XmlPullParser parser, boolean strict )
1145 throws IOException, XmlPullParserException
1146 {
1147 String tagName = parser.getName();
1148 EffectivePom effectivePom = new EffectivePom();
1149 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1150 {
1151 String name = parser.getAttributeName( i );
1152 String value = parser.getAttributeValue( i );
1153
1154 if ( name.indexOf( ':' ) >= 0 )
1155 {
1156
1157 }
1158 else
1159 {
1160 checkUnknownAttribute( parser, name, tagName, strict );
1161 }
1162 }
1163 java.util.Set parsed = new java.util.HashSet();
1164 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1165 {
1166 if ( checkFieldWithDuplicate( parser, "excludeProperties", null, parsed ) )
1167 {
1168 java.util.List<String> excludeProperties = new java.util.ArrayList<String>();
1169 while ( parser.nextTag() == XmlPullParser.START_TAG )
1170 {
1171 if ( "excludeProperty".equals( parser.getName() ) )
1172 {
1173 excludeProperties.add( interpolatedTrimmed( parser.nextText(), "excludeProperties" ) );
1174 }
1175 else
1176 {
1177 checkUnknownElement( parser, strict );
1178 }
1179 }
1180 effectivePom.setExcludeProperties( excludeProperties );
1181 }
1182 else
1183 {
1184 checkUnknownElement( parser, strict );
1185 }
1186 }
1187 return effectivePom;
1188 }
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200 private Exclude parseExclude( XmlPullParser parser, boolean strict )
1201 throws IOException, XmlPullParserException
1202 {
1203 String tagName = parser.getName();
1204 Exclude exclude = new Exclude();
1205 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1206 {
1207 String name = parser.getAttributeName( i );
1208 String value = parser.getAttributeValue( i );
1209
1210 if ( name.indexOf( ':' ) >= 0 )
1211 {
1212
1213 }
1214 else if ( "glob".equals( name ) )
1215 {
1216 exclude.setGlob( interpolatedTrimmed( value, "glob" ) );
1217 }
1218 else if ( "entryType".equals( name ) )
1219 {
1220 exclude.setEntryType( interpolatedTrimmed( value, "entryType" ) );
1221 }
1222 else if ( "matcherType".equals( name ) )
1223 {
1224 exclude.setMatcherType( interpolatedTrimmed( value, "matcherType" ) );
1225 }
1226 else
1227 {
1228 checkUnknownAttribute( parser, name, tagName, strict );
1229 }
1230 }
1231 exclude.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
1232 return exclude;
1233 }
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245 private Executables parseExecutables( XmlPullParser parser, boolean strict )
1246 throws IOException, XmlPullParserException
1247 {
1248 String tagName = parser.getName();
1249 Executables executables = new Executables();
1250 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1251 {
1252 String name = parser.getAttributeName( i );
1253 String value = parser.getAttributeValue( i );
1254
1255 if ( name.indexOf( ':' ) >= 0 )
1256 {
1257
1258 }
1259 else
1260 {
1261 checkUnknownAttribute( parser, name, tagName, strict );
1262 }
1263 }
1264 java.util.Set parsed = new java.util.HashSet();
1265 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1266 {
1267 if ( checkFieldWithDuplicate( parser, "plugins", null, parsed ) )
1268 {
1269 java.util.List<PluginSet> plugins = new java.util.ArrayList<PluginSet>();
1270 while ( parser.nextTag() == XmlPullParser.START_TAG )
1271 {
1272 if ( "plugin".equals( parser.getName() ) )
1273 {
1274 plugins.add( parsePluginSet( parser, strict ) );
1275 }
1276 else
1277 {
1278 checkUnknownElement( parser, strict );
1279 }
1280 }
1281 executables.setPlugins( plugins );
1282 }
1283 else if ( checkFieldWithDuplicate( parser, "executions", null, parsed ) )
1284 {
1285 java.util.List<ExecutionIdsList> executions = new java.util.ArrayList<ExecutionIdsList>();
1286 while ( parser.nextTag() == XmlPullParser.START_TAG )
1287 {
1288 if ( "execution".equals( parser.getName() ) )
1289 {
1290 executions.add( parseExecutionIdsList( parser, strict ) );
1291 }
1292 else
1293 {
1294 checkUnknownElement( parser, strict );
1295 }
1296 }
1297 executables.setExecutions( executions );
1298 }
1299 else if ( checkFieldWithDuplicate( parser, "goalsLists", null, parsed ) )
1300 {
1301 java.util.List<GoalsList> goalsLists = new java.util.ArrayList<GoalsList>();
1302 while ( parser.nextTag() == XmlPullParser.START_TAG )
1303 {
1304 if ( "goalsList".equals( parser.getName() ) )
1305 {
1306 goalsLists.add( parseGoalsList( parser, strict ) );
1307 }
1308 else
1309 {
1310 checkUnknownElement( parser, strict );
1311 }
1312 }
1313 executables.setGoalsLists( goalsLists );
1314 }
1315 else
1316 {
1317 checkUnknownElement( parser, strict );
1318 }
1319 }
1320 return executables;
1321 }
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333 private ExecutionConfigurationScan parseExecutionConfigurationScan( XmlPullParser parser, boolean strict )
1334 throws IOException, XmlPullParserException
1335 {
1336 String tagName = parser.getName();
1337 ExecutionConfigurationScan executionConfigurationScan = new ExecutionConfigurationScan();
1338 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1339 {
1340 String name = parser.getAttributeName( i );
1341 String value = parser.getAttributeValue( i );
1342
1343 if ( name.indexOf( ':' ) >= 0 )
1344 {
1345
1346 }
1347 else if ( "ignoreParentConfig".equals( name ) )
1348 {
1349 executionConfigurationScan.setIgnoreParentConfig( getBooleanValue( interpolatedTrimmed( value, "ignoreParentConfig" ), "ignoreParentConfig", parser, "false" ) );
1350 }
1351 else
1352 {
1353 checkUnknownAttribute( parser, name, tagName, strict );
1354 }
1355 }
1356 java.util.Set parsed = new java.util.HashSet();
1357 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1358 {
1359 if ( checkFieldWithDuplicate( parser, "execIds", null, parsed ) )
1360 {
1361 java.util.List<String> execIds = new java.util.ArrayList<String>();
1362 while ( parser.nextTag() == XmlPullParser.START_TAG )
1363 {
1364 if ( "execId".equals( parser.getName() ) )
1365 {
1366 execIds.add( interpolatedTrimmed( parser.nextText(), "execIds" ) );
1367 }
1368 else
1369 {
1370 checkUnknownElement( parser, strict );
1371 }
1372 }
1373 executionConfigurationScan.setExecIds( execIds );
1374 }
1375 else if ( checkFieldWithDuplicate( parser, "dirScan", null, parsed ) )
1376 {
1377 executionConfigurationScan.setDirScan( parseDirScanConfig( parser, strict ) );
1378 }
1379 else
1380 {
1381 checkUnknownElement( parser, strict );
1382 }
1383 }
1384 return executionConfigurationScan;
1385 }
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397 private ExecutionControl parseExecutionControl( XmlPullParser parser, boolean strict )
1398 throws IOException, XmlPullParserException
1399 {
1400 String tagName = parser.getName();
1401 ExecutionControl executionControl = new ExecutionControl();
1402 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1403 {
1404 String name = parser.getAttributeName( i );
1405 String value = parser.getAttributeValue( i );
1406
1407 if ( name.indexOf( ':' ) >= 0 )
1408 {
1409
1410 }
1411 else
1412 {
1413 checkUnknownAttribute( parser, name, tagName, strict );
1414 }
1415 }
1416 java.util.Set parsed = new java.util.HashSet();
1417 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1418 {
1419 if ( checkFieldWithDuplicate( parser, "runAlways", null, parsed ) )
1420 {
1421 executionControl.setRunAlways( parseExecutables( parser, strict ) );
1422 }
1423 else if ( checkFieldWithDuplicate( parser, "ignoreMissing", null, parsed ) )
1424 {
1425 executionControl.setIgnoreMissing( parseExecutables( parser, strict ) );
1426 }
1427 else if ( checkFieldWithDuplicate( parser, "reconcile", null, parsed ) )
1428 {
1429 executionControl.setReconcile( parseReconcile( parser, strict ) );
1430 }
1431 else
1432 {
1433 checkUnknownElement( parser, strict );
1434 }
1435 }
1436 return executionControl;
1437 }
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449 private ExecutionIdsList parseExecutionIdsList( XmlPullParser parser, boolean strict )
1450 throws IOException, XmlPullParserException
1451 {
1452 String tagName = parser.getName();
1453 ExecutionIdsList executionIdsList = new ExecutionIdsList();
1454 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1455 {
1456 String name = parser.getAttributeName( i );
1457 String value = parser.getAttributeValue( i );
1458
1459 if ( name.indexOf( ':' ) >= 0 )
1460 {
1461
1462 }
1463 else if ( "groupId".equals( name ) )
1464 {
1465 executionIdsList.setGroupId( interpolatedTrimmed( value, "groupId" ) );
1466 }
1467 else if ( "artifactId".equals( name ) )
1468 {
1469 executionIdsList.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
1470 }
1471 else
1472 {
1473 checkUnknownAttribute( parser, name, tagName, strict );
1474 }
1475 }
1476 java.util.Set parsed = new java.util.HashSet();
1477 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1478 {
1479 if ( checkFieldWithDuplicate( parser, "execIds", null, parsed ) )
1480 {
1481 java.util.List<String> execIds = new java.util.ArrayList<String>();
1482 while ( parser.nextTag() == XmlPullParser.START_TAG )
1483 {
1484 if ( "execId".equals( parser.getName() ) )
1485 {
1486 execIds.add( interpolatedTrimmed( parser.nextText(), "execIds" ) );
1487 }
1488 else
1489 {
1490 checkUnknownElement( parser, strict );
1491 }
1492 }
1493 executionIdsList.setExecIds( execIds );
1494 }
1495 else
1496 {
1497 checkUnknownElement( parser, strict );
1498 }
1499 }
1500 return executionIdsList;
1501 }
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513 private GoalId parseGoalId( XmlPullParser parser, boolean strict )
1514 throws IOException, XmlPullParserException
1515 {
1516 String tagName = parser.getName();
1517 GoalId goalId = new GoalId();
1518 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1519 {
1520 String name = parser.getAttributeName( i );
1521 String value = parser.getAttributeValue( i );
1522
1523 if ( name.indexOf( ':' ) >= 0 )
1524 {
1525
1526 }
1527 else if ( "goal".equals( name ) )
1528 {
1529 goalId.setGoal( interpolatedTrimmed( value, "goal" ) );
1530 }
1531 else if ( "groupId".equals( name ) )
1532 {
1533 goalId.setGroupId( interpolatedTrimmed( value, "groupId" ) );
1534 }
1535 else if ( "artifactId".equals( name ) )
1536 {
1537 goalId.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
1538 }
1539 else
1540 {
1541 checkUnknownAttribute( parser, name, tagName, strict );
1542 }
1543 }
1544 java.util.Set parsed = new java.util.HashSet();
1545 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1546 {
1547 checkUnknownElement( parser, strict );
1548 }
1549 return goalId;
1550 }
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562 private GoalReconciliation parseGoalReconciliation( XmlPullParser parser, boolean strict )
1563 throws IOException, XmlPullParserException
1564 {
1565 String tagName = parser.getName();
1566 GoalReconciliation goalReconciliation = new GoalReconciliation();
1567 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1568 {
1569 String name = parser.getAttributeName( i );
1570 String value = parser.getAttributeValue( i );
1571
1572 if ( name.indexOf( ':' ) >= 0 )
1573 {
1574
1575 }
1576 else if ( "goal".equals( name ) )
1577 {
1578 goalReconciliation.setGoal( interpolatedTrimmed( value, "goal" ) );
1579 }
1580 else if ( "groupId".equals( name ) )
1581 {
1582 goalReconciliation.setGroupId( interpolatedTrimmed( value, "groupId" ) );
1583 }
1584 else if ( "artifactId".equals( name ) )
1585 {
1586 goalReconciliation.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
1587 }
1588 else
1589 {
1590 checkUnknownAttribute( parser, name, tagName, strict );
1591 }
1592 }
1593 java.util.Set parsed = new java.util.HashSet();
1594 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1595 {
1596 if ( checkFieldWithDuplicate( parser, "reconciles", null, parsed ) )
1597 {
1598 java.util.List<TrackedProperty> reconciles = new java.util.ArrayList<TrackedProperty>();
1599 while ( parser.nextTag() == XmlPullParser.START_TAG )
1600 {
1601 if ( "reconcile".equals( parser.getName() ) )
1602 {
1603 reconciles.add( parseTrackedProperty( parser, strict ) );
1604 }
1605 else
1606 {
1607 checkUnknownElement( parser, strict );
1608 }
1609 }
1610 goalReconciliation.setReconciles( reconciles );
1611 }
1612 else if ( checkFieldWithDuplicate( parser, "logs", null, parsed ) )
1613 {
1614 java.util.List<PropertyName> logs = new java.util.ArrayList<PropertyName>();
1615 while ( parser.nextTag() == XmlPullParser.START_TAG )
1616 {
1617 if ( "log".equals( parser.getName() ) )
1618 {
1619 logs.add( parsePropertyName( parser, strict ) );
1620 }
1621 else
1622 {
1623 checkUnknownElement( parser, strict );
1624 }
1625 }
1626 goalReconciliation.setLogs( logs );
1627 }
1628 else if ( checkFieldWithDuplicate( parser, "nologs", null, parsed ) )
1629 {
1630 java.util.List<PropertyName> nologs = new java.util.ArrayList<PropertyName>();
1631 while ( parser.nextTag() == XmlPullParser.START_TAG )
1632 {
1633 if ( "nolog".equals( parser.getName() ) )
1634 {
1635 nologs.add( parsePropertyName( parser, strict ) );
1636 }
1637 else
1638 {
1639 checkUnknownElement( parser, strict );
1640 }
1641 }
1642 goalReconciliation.setNologs( nologs );
1643 }
1644 else if ( checkFieldWithDuplicate( parser, "logAll", null, parsed ) )
1645 {
1646 goalReconciliation.setLogAll( getBooleanValue( interpolatedTrimmed( parser.nextText(), "logAll" ), "logAll", parser, "true" ) );
1647 }
1648 else
1649 {
1650 checkUnknownElement( parser, strict );
1651 }
1652 }
1653 return goalReconciliation;
1654 }
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666 private GoalsList parseGoalsList( XmlPullParser parser, boolean strict )
1667 throws IOException, XmlPullParserException
1668 {
1669 String tagName = parser.getName();
1670 GoalsList goalsList = new GoalsList();
1671 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1672 {
1673 String name = parser.getAttributeName( i );
1674 String value = parser.getAttributeValue( i );
1675
1676 if ( name.indexOf( ':' ) >= 0 )
1677 {
1678
1679 }
1680 else if ( "groupId".equals( name ) )
1681 {
1682 goalsList.setGroupId( interpolatedTrimmed( value, "groupId" ) );
1683 }
1684 else if ( "artifactId".equals( name ) )
1685 {
1686 goalsList.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
1687 }
1688 else
1689 {
1690 checkUnknownAttribute( parser, name, tagName, strict );
1691 }
1692 }
1693 java.util.Set parsed = new java.util.HashSet();
1694 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1695 {
1696 if ( checkFieldWithDuplicate( parser, "goals", null, parsed ) )
1697 {
1698 java.util.List<String> goals = new java.util.ArrayList<String>();
1699 while ( parser.nextTag() == XmlPullParser.START_TAG )
1700 {
1701 if ( "goal".equals( parser.getName() ) )
1702 {
1703 goals.add( interpolatedTrimmed( parser.nextText(), "goals" ) );
1704 }
1705 else
1706 {
1707 checkUnknownElement( parser, strict );
1708 }
1709 }
1710 goalsList.setGoals( goals );
1711 }
1712 else
1713 {
1714 checkUnknownElement( parser, strict );
1715 }
1716 }
1717 return goalsList;
1718 }
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730 private Include parseInclude( XmlPullParser parser, boolean strict )
1731 throws IOException, XmlPullParserException
1732 {
1733 String tagName = parser.getName();
1734 Include include = new Include();
1735 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1736 {
1737 String name = parser.getAttributeName( i );
1738 String value = parser.getAttributeValue( i );
1739
1740 if ( name.indexOf( ':' ) >= 0 )
1741 {
1742
1743 }
1744 else if ( "recursive".equals( name ) )
1745 {
1746 include.setRecursive( getBooleanValue( interpolatedTrimmed( value, "recursive" ), "recursive", parser, "true" ) );
1747 }
1748 else if ( "glob".equals( name ) )
1749 {
1750 include.setGlob( interpolatedTrimmed( value, "glob" ) );
1751 }
1752 else
1753 {
1754 checkUnknownAttribute( parser, name, tagName, strict );
1755 }
1756 }
1757 include.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
1758 return include;
1759 }
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771 private Input parseInput( XmlPullParser parser, boolean strict )
1772 throws IOException, XmlPullParserException
1773 {
1774 String tagName = parser.getName();
1775 Input input = new Input();
1776 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1777 {
1778 String name = parser.getAttributeName( i );
1779 String value = parser.getAttributeValue( i );
1780
1781 if ( name.indexOf( ':' ) >= 0 )
1782 {
1783
1784 }
1785 else
1786 {
1787 checkUnknownAttribute( parser, name, tagName, strict );
1788 }
1789 }
1790 java.util.Set parsed = new java.util.HashSet();
1791 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1792 {
1793 if ( checkFieldWithDuplicate( parser, "global", null, parsed ) )
1794 {
1795 input.setGlobal( parsePathSet( parser, strict ) );
1796 }
1797 else if ( checkFieldWithDuplicate( parser, "plugins", null, parsed ) )
1798 {
1799 java.util.List<PluginConfigurationScan> plugins = new java.util.ArrayList<PluginConfigurationScan>();
1800 while ( parser.nextTag() == XmlPullParser.START_TAG )
1801 {
1802 if ( "plugin".equals( parser.getName() ) )
1803 {
1804 plugins.add( parsePluginConfigurationScan( parser, strict ) );
1805 }
1806 else
1807 {
1808 checkUnknownElement( parser, strict );
1809 }
1810 }
1811 input.setPlugins( plugins );
1812 }
1813 else
1814 {
1815 checkUnknownElement( parser, strict );
1816 }
1817 }
1818 return input;
1819 }
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831 private Local parseLocal( XmlPullParser parser, boolean strict )
1832 throws IOException, XmlPullParserException
1833 {
1834 String tagName = parser.getName();
1835 Local local = new Local();
1836 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1837 {
1838 String name = parser.getAttributeName( i );
1839 String value = parser.getAttributeValue( i );
1840
1841 if ( name.indexOf( ':' ) >= 0 )
1842 {
1843
1844 }
1845 else
1846 {
1847 checkUnknownAttribute( parser, name, tagName, strict );
1848 }
1849 }
1850 java.util.Set parsed = new java.util.HashSet();
1851 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1852 {
1853 if ( checkFieldWithDuplicate( parser, "location", null, parsed ) )
1854 {
1855 local.setLocation( interpolatedTrimmed( parser.nextText(), "location" ) );
1856 }
1857 else if ( checkFieldWithDuplicate( parser, "maxBuildsCached", null, parsed ) )
1858 {
1859 local.setMaxBuildsCached( getIntegerValue( interpolatedTrimmed( parser.nextText(), "maxBuildsCached" ), "maxBuildsCached", parser, strict ) );
1860 }
1861 else
1862 {
1863 checkUnknownElement( parser, strict );
1864 }
1865 }
1866 return local;
1867 }
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879 private MultiModule parseMultiModule( XmlPullParser parser, boolean strict )
1880 throws IOException, XmlPullParserException
1881 {
1882 String tagName = parser.getName();
1883 MultiModule multiModule = new MultiModule();
1884 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1885 {
1886 String name = parser.getAttributeName( i );
1887 String value = parser.getAttributeValue( i );
1888
1889 if ( name.indexOf( ':' ) >= 0 )
1890 {
1891
1892 }
1893 else
1894 {
1895 checkUnknownAttribute( parser, name, tagName, strict );
1896 }
1897 }
1898 java.util.Set parsed = new java.util.HashSet();
1899 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1900 {
1901 if ( checkFieldWithDuplicate( parser, "discovery", null, parsed ) )
1902 {
1903 multiModule.setDiscovery( parseDiscovery( parser, strict ) );
1904 }
1905 else
1906 {
1907 checkUnknownElement( parser, strict );
1908 }
1909 }
1910 return multiModule;
1911 }
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923 private Output parseOutput( XmlPullParser parser, boolean strict )
1924 throws IOException, XmlPullParserException
1925 {
1926 String tagName = parser.getName();
1927 Output output = new Output();
1928 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1929 {
1930 String name = parser.getAttributeName( i );
1931 String value = parser.getAttributeValue( i );
1932
1933 if ( name.indexOf( ':' ) >= 0 )
1934 {
1935
1936 }
1937 else
1938 {
1939 checkUnknownAttribute( parser, name, tagName, strict );
1940 }
1941 }
1942 java.util.Set parsed = new java.util.HashSet();
1943 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1944 {
1945 if ( checkFieldWithDuplicate( parser, "exclude", null, parsed ) )
1946 {
1947 output.setExclude( parseOutputExclude( parser, strict ) );
1948 }
1949 else
1950 {
1951 checkUnknownElement( parser, strict );
1952 }
1953 }
1954 return output;
1955 }
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967 private OutputExclude parseOutputExclude( XmlPullParser parser, boolean strict )
1968 throws IOException, XmlPullParserException
1969 {
1970 String tagName = parser.getName();
1971 OutputExclude outputExclude = new OutputExclude();
1972 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1973 {
1974 String name = parser.getAttributeName( i );
1975 String value = parser.getAttributeValue( i );
1976
1977 if ( name.indexOf( ':' ) >= 0 )
1978 {
1979
1980 }
1981 else
1982 {
1983 checkUnknownAttribute( parser, name, tagName, strict );
1984 }
1985 }
1986 java.util.Set parsed = new java.util.HashSet();
1987 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1988 {
1989 if ( checkFieldWithDuplicate( parser, "patterns", null, parsed ) )
1990 {
1991 java.util.List<String> patterns = new java.util.ArrayList<String>();
1992 while ( parser.nextTag() == XmlPullParser.START_TAG )
1993 {
1994 if ( "pattern".equals( parser.getName() ) )
1995 {
1996 patterns.add( interpolatedTrimmed( parser.nextText(), "patterns" ) );
1997 }
1998 else
1999 {
2000 checkUnknownElement( parser, strict );
2001 }
2002 }
2003 outputExclude.setPatterns( patterns );
2004 }
2005 else
2006 {
2007 checkUnknownElement( parser, strict );
2008 }
2009 }
2010 return outputExclude;
2011 }
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023 private PathSet parsePathSet( XmlPullParser parser, boolean strict )
2024 throws IOException, XmlPullParserException
2025 {
2026 String tagName = parser.getName();
2027 PathSet pathSet = new PathSet();
2028 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2029 {
2030 String name = parser.getAttributeName( i );
2031 String value = parser.getAttributeValue( i );
2032
2033 if ( name.indexOf( ':' ) >= 0 )
2034 {
2035
2036 }
2037 else
2038 {
2039 checkUnknownAttribute( parser, name, tagName, strict );
2040 }
2041 }
2042 java.util.Set parsed = new java.util.HashSet();
2043 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2044 {
2045 if ( checkFieldWithDuplicate( parser, "glob", null, parsed ) )
2046 {
2047 pathSet.setGlob( interpolatedTrimmed( parser.nextText(), "glob" ) );
2048 }
2049 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
2050 {
2051 java.util.List<Include> includes = new java.util.ArrayList<Include>();
2052 while ( parser.nextTag() == XmlPullParser.START_TAG )
2053 {
2054 if ( "include".equals( parser.getName() ) )
2055 {
2056 includes.add( parseInclude( parser, strict ) );
2057 }
2058 else
2059 {
2060 checkUnknownElement( parser, strict );
2061 }
2062 }
2063 pathSet.setIncludes( includes );
2064 }
2065 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
2066 {
2067 java.util.List<Exclude> excludes = new java.util.ArrayList<Exclude>();
2068 while ( parser.nextTag() == XmlPullParser.START_TAG )
2069 {
2070 if ( "exclude".equals( parser.getName() ) )
2071 {
2072 excludes.add( parseExclude( parser, strict ) );
2073 }
2074 else
2075 {
2076 checkUnknownElement( parser, strict );
2077 }
2078 }
2079 pathSet.setExcludes( excludes );
2080 }
2081 else
2082 {
2083 checkUnknownElement( parser, strict );
2084 }
2085 }
2086 return pathSet;
2087 }
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099 private PluginConfigurationScan parsePluginConfigurationScan( XmlPullParser parser, boolean strict )
2100 throws IOException, XmlPullParserException
2101 {
2102 String tagName = parser.getName();
2103 PluginConfigurationScan pluginConfigurationScan = new PluginConfigurationScan();
2104 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2105 {
2106 String name = parser.getAttributeName( i );
2107 String value = parser.getAttributeValue( i );
2108
2109 if ( name.indexOf( ':' ) >= 0 )
2110 {
2111
2112 }
2113 else if ( "groupId".equals( name ) )
2114 {
2115 pluginConfigurationScan.setGroupId( interpolatedTrimmed( value, "groupId" ) );
2116 }
2117 else if ( "artifactId".equals( name ) )
2118 {
2119 pluginConfigurationScan.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
2120 }
2121 else
2122 {
2123 checkUnknownAttribute( parser, name, tagName, strict );
2124 }
2125 }
2126 java.util.Set parsed = new java.util.HashSet();
2127 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2128 {
2129 if ( checkFieldWithDuplicate( parser, "effectivePom", null, parsed ) )
2130 {
2131 pluginConfigurationScan.setEffectivePom( parseEffectivePom( parser, strict ) );
2132 }
2133 else if ( checkFieldWithDuplicate( parser, "dirScan", null, parsed ) )
2134 {
2135 pluginConfigurationScan.setDirScan( parseDirScanConfig( parser, strict ) );
2136 }
2137 else if ( checkFieldWithDuplicate( parser, "executions", null, parsed ) )
2138 {
2139 java.util.List<ExecutionConfigurationScan> executions = new java.util.ArrayList<ExecutionConfigurationScan>();
2140 while ( parser.nextTag() == XmlPullParser.START_TAG )
2141 {
2142 if ( "execution".equals( parser.getName() ) )
2143 {
2144 executions.add( parseExecutionConfigurationScan( parser, strict ) );
2145 }
2146 else
2147 {
2148 checkUnknownElement( parser, strict );
2149 }
2150 }
2151 pluginConfigurationScan.setExecutions( executions );
2152 }
2153 else
2154 {
2155 checkUnknownElement( parser, strict );
2156 }
2157 }
2158 return pluginConfigurationScan;
2159 }
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171 private PluginSet parsePluginSet( XmlPullParser parser, boolean strict )
2172 throws IOException, XmlPullParserException
2173 {
2174 String tagName = parser.getName();
2175 PluginSet pluginSet = new PluginSet();
2176 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2177 {
2178 String name = parser.getAttributeName( i );
2179 String value = parser.getAttributeValue( i );
2180
2181 if ( name.indexOf( ':' ) >= 0 )
2182 {
2183
2184 }
2185 else if ( "groupId".equals( name ) )
2186 {
2187 pluginSet.setGroupId( interpolatedTrimmed( value, "groupId" ) );
2188 }
2189 else if ( "artifactId".equals( name ) )
2190 {
2191 pluginSet.setArtifactId( interpolatedTrimmed( value, "artifactId" ) );
2192 }
2193 else
2194 {
2195 checkUnknownAttribute( parser, name, tagName, strict );
2196 }
2197 }
2198 java.util.Set parsed = new java.util.HashSet();
2199 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2200 {
2201 checkUnknownElement( parser, strict );
2202 }
2203 return pluginSet;
2204 }
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216 private ProjectVersioning parseProjectVersioning( XmlPullParser parser, boolean strict )
2217 throws IOException, XmlPullParserException
2218 {
2219 String tagName = parser.getName();
2220 ProjectVersioning projectVersioning = new ProjectVersioning();
2221 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2222 {
2223 String name = parser.getAttributeName( i );
2224 String value = parser.getAttributeValue( i );
2225
2226 if ( name.indexOf( ':' ) >= 0 )
2227 {
2228
2229 }
2230 else if ( "adjustMetaInf".equals( name ) )
2231 {
2232 projectVersioning.setAdjustMetaInf( getBooleanValue( interpolatedTrimmed( value, "adjustMetaInf" ), "adjustMetaInf", parser, "false" ) );
2233 }
2234 else if ( "calculateProjectVersionChecksum".equals( name ) )
2235 {
2236 projectVersioning.setCalculateProjectVersionChecksum( getBooleanValue( interpolatedTrimmed( value, "calculateProjectVersionChecksum" ), "calculateProjectVersionChecksum", parser, "false" ) );
2237 }
2238 else
2239 {
2240 checkUnknownAttribute( parser, name, tagName, strict );
2241 }
2242 }
2243 java.util.Set parsed = new java.util.HashSet();
2244 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2245 {
2246 checkUnknownElement( parser, strict );
2247 }
2248 return projectVersioning;
2249 }
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261 private PropertyName parsePropertyName( XmlPullParser parser, boolean strict )
2262 throws IOException, XmlPullParserException
2263 {
2264 String tagName = parser.getName();
2265 PropertyName propertyName = new PropertyName();
2266 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2267 {
2268 String name = parser.getAttributeName( i );
2269 String value = parser.getAttributeValue( i );
2270
2271 if ( name.indexOf( ':' ) >= 0 )
2272 {
2273
2274 }
2275 else if ( "propertyName".equals( name ) )
2276 {
2277 propertyName.setPropertyName( interpolatedTrimmed( value, "propertyName" ) );
2278 }
2279 else
2280 {
2281 checkUnknownAttribute( parser, name, tagName, strict );
2282 }
2283 }
2284 propertyName.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
2285 return propertyName;
2286 }
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298 private Reconcile parseReconcile( XmlPullParser parser, boolean strict )
2299 throws IOException, XmlPullParserException
2300 {
2301 String tagName = parser.getName();
2302 Reconcile reconcile = new Reconcile();
2303 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2304 {
2305 String name = parser.getAttributeName( i );
2306 String value = parser.getAttributeValue( i );
2307
2308 if ( name.indexOf( ':' ) >= 0 )
2309 {
2310
2311 }
2312 else if ( "logAllProperties".equals( name ) )
2313 {
2314 reconcile.setLogAllProperties( getBooleanValue( interpolatedTrimmed( value, "logAllProperties" ), "logAllProperties", parser, "true" ) );
2315 }
2316 else
2317 {
2318 checkUnknownAttribute( parser, name, tagName, strict );
2319 }
2320 }
2321 java.util.Set parsed = new java.util.HashSet();
2322 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2323 {
2324 if ( checkFieldWithDuplicate( parser, "plugins", null, parsed ) )
2325 {
2326 java.util.List<GoalReconciliation> plugins = new java.util.ArrayList<GoalReconciliation>();
2327 while ( parser.nextTag() == XmlPullParser.START_TAG )
2328 {
2329 if ( "plugin".equals( parser.getName() ) )
2330 {
2331 plugins.add( parseGoalReconciliation( parser, strict ) );
2332 }
2333 else
2334 {
2335 checkUnknownElement( parser, strict );
2336 }
2337 }
2338 reconcile.setPlugins( plugins );
2339 }
2340 else
2341 {
2342 checkUnknownElement( parser, strict );
2343 }
2344 }
2345 return reconcile;
2346 }
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358 private Remote parseRemote( XmlPullParser parser, boolean strict )
2359 throws IOException, XmlPullParserException
2360 {
2361 String tagName = parser.getName();
2362 Remote remote = new Remote();
2363 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2364 {
2365 String name = parser.getAttributeName( i );
2366 String value = parser.getAttributeValue( i );
2367
2368 if ( name.indexOf( ':' ) >= 0 )
2369 {
2370
2371 }
2372 else if ( "enabled".equals( name ) )
2373 {
2374 remote.setEnabled( getBooleanValue( interpolatedTrimmed( value, "enabled" ), "enabled", parser, "true" ) );
2375 }
2376 else if ( "saveToRemote".equals( name ) )
2377 {
2378 remote.setSaveToRemote( getBooleanValue( interpolatedTrimmed( value, "saveToRemote" ), "saveToRemote", parser, "false" ) );
2379 }
2380 else if ( "transport".equals( name ) )
2381 {
2382 remote.setTransport( interpolatedTrimmed( value, "transport" ) );
2383 }
2384 else if ( "id".equals( name ) )
2385 {
2386 remote.setId( interpolatedTrimmed( value, "id" ) );
2387 }
2388 else
2389 {
2390 checkUnknownAttribute( parser, name, tagName, strict );
2391 }
2392 }
2393 java.util.Set parsed = new java.util.HashSet();
2394 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2395 {
2396 if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
2397 {
2398 remote.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
2399 }
2400 else
2401 {
2402 checkUnknownElement( parser, strict );
2403 }
2404 }
2405 return remote;
2406 }
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418 private TagExclude parseTagExclude( XmlPullParser parser, boolean strict )
2419 throws IOException, XmlPullParserException
2420 {
2421 String tagName = parser.getName();
2422 TagExclude tagExclude = new TagExclude();
2423 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2424 {
2425 String name = parser.getAttributeName( i );
2426 String value = parser.getAttributeValue( i );
2427
2428 if ( name.indexOf( ':' ) >= 0 )
2429 {
2430
2431 }
2432 else if ( "tagName".equals( name ) )
2433 {
2434 tagExclude.setTagName( interpolatedTrimmed( value, "tagName" ) );
2435 }
2436 else
2437 {
2438 checkUnknownAttribute( parser, name, tagName, strict );
2439 }
2440 }
2441 java.util.Set parsed = new java.util.HashSet();
2442 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2443 {
2444 checkUnknownElement( parser, strict );
2445 }
2446 return tagExclude;
2447 }
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459 private TagScanConfig parseTagScanConfig( XmlPullParser parser, boolean strict )
2460 throws IOException, XmlPullParserException
2461 {
2462 String tagName = parser.getName();
2463 TagScanConfig tagScanConfig = new TagScanConfig();
2464 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2465 {
2466 String name = parser.getAttributeName( i );
2467 String value = parser.getAttributeValue( i );
2468
2469 if ( name.indexOf( ':' ) >= 0 )
2470 {
2471
2472 }
2473 else if ( "recursive".equals( name ) )
2474 {
2475 tagScanConfig.setRecursive( getBooleanValue( interpolatedTrimmed( value, "recursive" ), "recursive", parser, "true" ) );
2476 }
2477 else if ( "glob".equals( name ) )
2478 {
2479 tagScanConfig.setGlob( interpolatedTrimmed( value, "glob" ) );
2480 }
2481 else if ( "tagName".equals( name ) )
2482 {
2483 tagScanConfig.setTagName( interpolatedTrimmed( value, "tagName" ) );
2484 }
2485 else
2486 {
2487 checkUnknownAttribute( parser, name, tagName, strict );
2488 }
2489 }
2490 java.util.Set parsed = new java.util.HashSet();
2491 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
2492 {
2493 checkUnknownElement( parser, strict );
2494 }
2495 return tagScanConfig;
2496 }
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508 private TrackedProperty parseTrackedProperty( XmlPullParser parser, boolean strict )
2509 throws IOException, XmlPullParserException
2510 {
2511 String tagName = parser.getName();
2512 TrackedProperty trackedProperty = new TrackedProperty();
2513 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
2514 {
2515 String name = parser.getAttributeName( i );
2516 String value = parser.getAttributeValue( i );
2517
2518 if ( name.indexOf( ':' ) >= 0 )
2519 {
2520
2521 }
2522 else if ( "propertyName".equals( name ) )
2523 {
2524 trackedProperty.setPropertyName( interpolatedTrimmed( value, "propertyName" ) );
2525 }
2526 else if ( "skipValue".equals( name ) )
2527 {
2528 trackedProperty.setSkipValue( interpolatedTrimmed( value, "skipValue" ) );
2529 }
2530 else if ( "defaultValue".equals( name ) )
2531 {
2532 trackedProperty.setDefaultValue( interpolatedTrimmed( value, "defaultValue" ) );
2533 }
2534 else
2535 {
2536 checkUnknownAttribute( parser, name, tagName, strict );
2537 }
2538 }
2539 trackedProperty.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
2540 return trackedProperty;
2541 }
2542
2543
2544
2545
2546
2547
2548 public void setAddDefaultEntities( boolean addDefaultEntities )
2549 {
2550 this.addDefaultEntities = addDefaultEntities;
2551 }
2552
2553 public static interface ContentTransformer
2554 {
2555
2556
2557
2558
2559
2560
2561
2562 String transform( String source, String fieldName );
2563 }
2564
2565 }