1
2
3
4
5
6 package org.apache.maven.plugins.assembly.model.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.plugins.assembly.model.Assembly;
17 import org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig;
18 import org.apache.maven.plugins.assembly.model.DependencySet;
19 import org.apache.maven.plugins.assembly.model.FileItem;
20 import org.apache.maven.plugins.assembly.model.FileSet;
21 import org.apache.maven.plugins.assembly.model.GroupVersionAlignment;
22 import org.apache.maven.plugins.assembly.model.ModuleBinaries;
23 import org.apache.maven.plugins.assembly.model.ModuleSet;
24 import org.apache.maven.plugins.assembly.model.ModuleSources;
25 import org.apache.maven.plugins.assembly.model.Repository;
26 import org.apache.maven.plugins.assembly.model.UnpackOptions;
27 import org.codehaus.plexus.util.ReaderFactory;
28 import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
29 import org.codehaus.plexus.util.xml.pull.MXParser;
30 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
31 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
32
33
34
35
36
37
38 @SuppressWarnings( "all" )
39 public class AssemblyXpp3Reader
40 {
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 private boolean addDefaultEntities = true;
57
58
59
60
61 public final ContentTransformer contentTransformer;
62
63
64
65
66
67
68 public AssemblyXpp3Reader()
69 {
70 this( new ContentTransformer()
71 {
72 public String transform( String source, String fieldName )
73 {
74 return source;
75 }
76 } );
77 }
78
79 public AssemblyXpp3Reader(ContentTransformer contentTransformer)
80 {
81 this.contentTransformer = contentTransformer;
82 }
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed )
101 throws XmlPullParserException
102 {
103 if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
104 {
105 return false;
106 }
107 if ( !parsed.add( tagName ) )
108 {
109 throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
110 }
111 return true;
112 }
113
114
115
116
117
118
119
120
121
122
123
124
125 private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
126 throws XmlPullParserException, IOException
127 {
128
129 if ( strict )
130 {
131 throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
132 }
133 }
134
135
136
137
138
139
140
141
142
143
144 private void checkUnknownElement( XmlPullParser parser, boolean strict )
145 throws XmlPullParserException, IOException
146 {
147 if ( strict )
148 {
149 throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
150 }
151
152 for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
153 {
154 int eventType = parser.next();
155 if ( eventType == XmlPullParser.START_TAG )
156 {
157 unrecognizedTagCount++;
158 }
159 else if ( eventType == XmlPullParser.END_TAG )
160 {
161 unrecognizedTagCount--;
162 }
163 }
164 }
165
166
167
168
169
170
171 public boolean getAddDefaultEntities()
172 {
173 return addDefaultEntities;
174 }
175
176
177
178
179
180
181
182
183
184
185
186 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
187 throws XmlPullParserException
188 {
189 return getBooleanValue( s, attribute, parser, null );
190 }
191
192
193
194
195
196
197
198
199
200
201
202
203 private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
204 throws XmlPullParserException
205 {
206 if ( s != null && s.length() != 0 )
207 {
208 return Boolean.valueOf( s ).booleanValue();
209 }
210 if ( defaultValue != null )
211 {
212 return Boolean.valueOf( defaultValue ).booleanValue();
213 }
214 return false;
215 }
216
217
218
219
220
221
222
223
224
225
226
227
228 private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
229 throws XmlPullParserException
230 {
231 if ( s != null )
232 {
233 try
234 {
235 return Byte.valueOf( s ).byteValue();
236 }
237 catch ( NumberFormatException nfe )
238 {
239 if ( strict )
240 {
241 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
242 }
243 }
244 }
245 return 0;
246 }
247
248
249
250
251
252
253
254
255
256
257
258 private char getCharacterValue( String s, String attribute, XmlPullParser parser )
259 throws XmlPullParserException
260 {
261 if ( s != null )
262 {
263 return s.charAt( 0 );
264 }
265 return 0;
266 }
267
268
269
270
271
272
273
274
275
276
277
278 private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
279 throws XmlPullParserException
280 {
281 return getDateValue( s, attribute, null, parser );
282 }
283
284
285
286
287
288
289
290
291
292
293
294
295 private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
296 throws XmlPullParserException
297 {
298 if ( s != null )
299 {
300 String effectiveDateFormat = dateFormat;
301 if ( dateFormat == null )
302 {
303 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
304 }
305 if ( "long".equals( effectiveDateFormat ) )
306 {
307 try
308 {
309 return new java.util.Date( Long.parseLong( s ) );
310 }
311 catch ( NumberFormatException e )
312 {
313 throw new XmlPullParserException( e.getMessage(), parser, e );
314 }
315 }
316 else
317 {
318 try
319 {
320 DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
321 return dateParser.parse( s );
322 }
323 catch ( java.text.ParseException e )
324 {
325 throw new XmlPullParserException( e.getMessage(), parser, e );
326 }
327 }
328 }
329 return null;
330 }
331
332
333
334
335
336
337
338
339
340
341
342
343 private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
344 throws XmlPullParserException
345 {
346 if ( s != null )
347 {
348 try
349 {
350 return Double.valueOf( s ).doubleValue();
351 }
352 catch ( NumberFormatException nfe )
353 {
354 if ( strict )
355 {
356 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
357 }
358 }
359 }
360 return 0;
361 }
362
363
364
365
366
367
368
369
370
371
372
373
374 private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
375 throws XmlPullParserException
376 {
377 if ( s != null )
378 {
379 try
380 {
381 return Float.valueOf( s ).floatValue();
382 }
383 catch ( NumberFormatException nfe )
384 {
385 if ( strict )
386 {
387 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
388 }
389 }
390 }
391 return 0;
392 }
393
394
395
396
397
398
399
400
401
402
403
404
405 private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
406 throws XmlPullParserException
407 {
408 if ( s != null )
409 {
410 try
411 {
412 return Integer.valueOf( s ).intValue();
413 }
414 catch ( NumberFormatException nfe )
415 {
416 if ( strict )
417 {
418 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
419 }
420 }
421 }
422 return 0;
423 }
424
425
426
427
428
429
430
431
432
433
434
435
436 private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
437 throws XmlPullParserException
438 {
439 if ( s != null )
440 {
441 try
442 {
443 return Long.valueOf( s ).longValue();
444 }
445 catch ( NumberFormatException nfe )
446 {
447 if ( strict )
448 {
449 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
450 }
451 }
452 }
453 return 0;
454 }
455
456
457
458
459
460
461
462
463
464
465
466
467 private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
468 throws XmlPullParserException
469 {
470 if ( s == null )
471 {
472 if ( strict )
473 {
474 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
475 }
476 }
477 return s;
478 }
479
480
481
482
483
484
485
486
487
488
489
490
491 private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
492 throws XmlPullParserException
493 {
494 if ( s != null )
495 {
496 try
497 {
498 return Short.valueOf( s ).shortValue();
499 }
500 catch ( NumberFormatException nfe )
501 {
502 if ( strict )
503 {
504 throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
505 }
506 }
507 }
508 return 0;
509 }
510
511
512
513
514
515
516
517 private String getTrimmedValue( String s )
518 {
519 if ( s != null )
520 {
521 s = s.trim();
522 }
523 return s;
524 }
525
526
527
528
529
530
531
532
533 private String interpolatedTrimmed( String value, String context )
534 {
535 return getTrimmedValue( contentTransformer.transform( value, context ) );
536 }
537
538
539
540
541
542
543
544
545
546
547 private int nextTag( XmlPullParser parser )
548 throws IOException, XmlPullParserException
549 {
550 int eventType = parser.next();
551 if ( eventType == XmlPullParser.TEXT )
552 {
553 eventType = parser.next();
554 }
555 if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
556 {
557 throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
558 }
559 return eventType;
560 }
561
562
563
564
565
566
567
568
569
570
571
572 public Assembly read( Reader reader, boolean strict )
573 throws IOException, XmlPullParserException
574 {
575 XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
576
577 parser.setInput( reader );
578
579
580 return read( parser, strict );
581 }
582
583
584
585
586
587
588
589
590
591
592 public Assembly read( Reader reader )
593 throws IOException, XmlPullParserException
594 {
595 return read( reader, true );
596 }
597
598
599
600
601
602
603
604
605
606
607
608 public Assembly read( InputStream in, boolean strict )
609 throws IOException, XmlPullParserException
610 {
611 return read( ReaderFactory.newXmlReader( in ), strict );
612 }
613
614
615
616
617
618
619
620
621
622
623 public Assembly read( InputStream in )
624 throws IOException, XmlPullParserException
625 {
626 return read( ReaderFactory.newXmlReader( in ) );
627 }
628
629
630
631
632
633
634
635
636
637
638
639 private Assembly parseAssembly( XmlPullParser parser, boolean strict )
640 throws IOException, XmlPullParserException
641 {
642 String tagName = parser.getName();
643 Assembly assembly = new Assembly();
644 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
645 {
646 String name = parser.getAttributeName( i );
647 String value = parser.getAttributeValue( i );
648
649 if ( name.indexOf( ':' ) >= 0 )
650 {
651
652 }
653 else if ( "xmlns".equals( name ) )
654 {
655
656 }
657 else
658 {
659 checkUnknownAttribute( parser, name, tagName, strict );
660 }
661 }
662 java.util.Set parsed = new java.util.HashSet();
663 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
664 {
665 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
666 {
667 assembly.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
668 }
669 else if ( checkFieldWithDuplicate( parser, "formats", null, parsed ) )
670 {
671 java.util.List<String> formats = new java.util.ArrayList<String>();
672 assembly.setFormats( formats );
673 while ( parser.nextTag() == XmlPullParser.START_TAG )
674 {
675 if ( "format".equals( parser.getName() ) )
676 {
677 formats.add( interpolatedTrimmed( parser.nextText(), "formats" ) );
678 }
679 else
680 {
681 checkUnknownElement( parser, strict );
682 }
683 }
684 }
685 else if ( checkFieldWithDuplicate( parser, "includeBaseDirectory", null, parsed ) )
686 {
687 assembly.setIncludeBaseDirectory( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeBaseDirectory" ), "includeBaseDirectory", parser, "true" ) );
688 }
689 else if ( checkFieldWithDuplicate( parser, "baseDirectory", null, parsed ) )
690 {
691 assembly.setBaseDirectory( interpolatedTrimmed( parser.nextText(), "baseDirectory" ) );
692 }
693 else if ( checkFieldWithDuplicate( parser, "includeSiteDirectory", null, parsed ) )
694 {
695 assembly.setIncludeSiteDirectory( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeSiteDirectory" ), "includeSiteDirectory", parser, "false" ) );
696 }
697 else if ( checkFieldWithDuplicate( parser, "containerDescriptorHandlers", null, parsed ) )
698 {
699 java.util.List<ContainerDescriptorHandlerConfig> containerDescriptorHandlers = new java.util.ArrayList<ContainerDescriptorHandlerConfig>();
700 assembly.setContainerDescriptorHandlers( containerDescriptorHandlers );
701 while ( parser.nextTag() == XmlPullParser.START_TAG )
702 {
703 if ( "containerDescriptorHandler".equals( parser.getName() ) )
704 {
705 containerDescriptorHandlers.add( parseContainerDescriptorHandlerConfig( parser, strict ) );
706 }
707 else
708 {
709 checkUnknownElement( parser, strict );
710 }
711 }
712 }
713 else if ( checkFieldWithDuplicate( parser, "moduleSets", null, parsed ) )
714 {
715 java.util.List<ModuleSet> moduleSets = new java.util.ArrayList<ModuleSet>();
716 assembly.setModuleSets( moduleSets );
717 while ( parser.nextTag() == XmlPullParser.START_TAG )
718 {
719 if ( "moduleSet".equals( parser.getName() ) )
720 {
721 moduleSets.add( parseModuleSet( parser, strict ) );
722 }
723 else
724 {
725 checkUnknownElement( parser, strict );
726 }
727 }
728 }
729 else if ( checkFieldWithDuplicate( parser, "fileSets", null, parsed ) )
730 {
731 java.util.List<FileSet> fileSets = new java.util.ArrayList<FileSet>();
732 assembly.setFileSets( fileSets );
733 while ( parser.nextTag() == XmlPullParser.START_TAG )
734 {
735 if ( "fileSet".equals( parser.getName() ) )
736 {
737 fileSets.add( parseFileSet( parser, strict ) );
738 }
739 else
740 {
741 checkUnknownElement( parser, strict );
742 }
743 }
744 }
745 else if ( checkFieldWithDuplicate( parser, "files", null, parsed ) )
746 {
747 java.util.List<FileItem> files = new java.util.ArrayList<FileItem>();
748 assembly.setFiles( files );
749 while ( parser.nextTag() == XmlPullParser.START_TAG )
750 {
751 if ( "file".equals( parser.getName() ) )
752 {
753 files.add( parseFileItem( parser, strict ) );
754 }
755 else
756 {
757 checkUnknownElement( parser, strict );
758 }
759 }
760 }
761 else if ( checkFieldWithDuplicate( parser, "dependencySets", null, parsed ) )
762 {
763 java.util.List<DependencySet> dependencySets = new java.util.ArrayList<DependencySet>();
764 assembly.setDependencySets( dependencySets );
765 while ( parser.nextTag() == XmlPullParser.START_TAG )
766 {
767 if ( "dependencySet".equals( parser.getName() ) )
768 {
769 dependencySets.add( parseDependencySet( parser, strict ) );
770 }
771 else
772 {
773 checkUnknownElement( parser, strict );
774 }
775 }
776 }
777 else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) )
778 {
779 java.util.List<Repository> repositories = new java.util.ArrayList<Repository>();
780 assembly.setRepositories( repositories );
781 while ( parser.nextTag() == XmlPullParser.START_TAG )
782 {
783 if ( "repository".equals( parser.getName() ) )
784 {
785 repositories.add( parseRepository( parser, strict ) );
786 }
787 else
788 {
789 checkUnknownElement( parser, strict );
790 }
791 }
792 }
793 else if ( checkFieldWithDuplicate( parser, "componentDescriptors", null, parsed ) )
794 {
795 java.util.List<String> componentDescriptors = new java.util.ArrayList<String>();
796 assembly.setComponentDescriptors( componentDescriptors );
797 while ( parser.nextTag() == XmlPullParser.START_TAG )
798 {
799 if ( "componentDescriptor".equals( parser.getName() ) )
800 {
801 componentDescriptors.add( interpolatedTrimmed( parser.nextText(), "componentDescriptors" ) );
802 }
803 else
804 {
805 checkUnknownElement( parser, strict );
806 }
807 }
808 }
809 else
810 {
811 checkUnknownElement( parser, strict );
812 }
813 }
814 return assembly;
815 }
816
817
818
819
820
821
822
823
824
825
826
827 private ContainerDescriptorHandlerConfig parseContainerDescriptorHandlerConfig( XmlPullParser parser, boolean strict )
828 throws IOException, XmlPullParserException
829 {
830 String tagName = parser.getName();
831 ContainerDescriptorHandlerConfig containerDescriptorHandlerConfig = new ContainerDescriptorHandlerConfig();
832 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
833 {
834 String name = parser.getAttributeName( i );
835 String value = parser.getAttributeValue( i );
836
837 if ( name.indexOf( ':' ) >= 0 )
838 {
839
840 }
841 else
842 {
843 checkUnknownAttribute( parser, name, tagName, strict );
844 }
845 }
846 java.util.Set parsed = new java.util.HashSet();
847 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
848 {
849 if ( checkFieldWithDuplicate( parser, "handlerName", null, parsed ) )
850 {
851 containerDescriptorHandlerConfig.setHandlerName( interpolatedTrimmed( parser.nextText(), "handlerName" ) );
852 }
853 else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
854 {
855 containerDescriptorHandlerConfig.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
856 }
857 else
858 {
859 checkUnknownElement( parser, strict );
860 }
861 }
862 return containerDescriptorHandlerConfig;
863 }
864
865
866
867
868
869
870
871
872
873
874
875 private DependencySet parseDependencySet( XmlPullParser parser, boolean strict )
876 throws IOException, XmlPullParserException
877 {
878 String tagName = parser.getName();
879 DependencySet dependencySet = new DependencySet();
880 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
881 {
882 String name = parser.getAttributeName( i );
883 String value = parser.getAttributeValue( i );
884
885 if ( name.indexOf( ':' ) >= 0 )
886 {
887
888 }
889 else
890 {
891 checkUnknownAttribute( parser, name, tagName, strict );
892 }
893 }
894 java.util.Set parsed = new java.util.HashSet();
895 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
896 {
897 if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
898 {
899 dependencySet.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
900 }
901 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
902 {
903 java.util.List<String> includes = new java.util.ArrayList<String>();
904 dependencySet.setIncludes( includes );
905 while ( parser.nextTag() == XmlPullParser.START_TAG )
906 {
907 if ( "include".equals( parser.getName() ) )
908 {
909 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
910 }
911 else
912 {
913 checkUnknownElement( parser, strict );
914 }
915 }
916 }
917 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
918 {
919 java.util.List<String> excludes = new java.util.ArrayList<String>();
920 dependencySet.setExcludes( excludes );
921 while ( parser.nextTag() == XmlPullParser.START_TAG )
922 {
923 if ( "exclude".equals( parser.getName() ) )
924 {
925 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
926 }
927 else
928 {
929 checkUnknownElement( parser, strict );
930 }
931 }
932 }
933 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
934 {
935 dependencySet.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
936 }
937 else if ( checkFieldWithDuplicate( parser, "directoryMode", null, parsed ) )
938 {
939 dependencySet.setDirectoryMode( interpolatedTrimmed( parser.nextText(), "directoryMode" ) );
940 }
941 else if ( checkFieldWithDuplicate( parser, "useStrictFiltering", null, parsed ) )
942 {
943 dependencySet.setUseStrictFiltering( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useStrictFiltering" ), "useStrictFiltering", parser, "false" ) );
944 }
945 else if ( checkFieldWithDuplicate( parser, "outputFileNameMapping", null, parsed ) )
946 {
947 dependencySet.setOutputFileNameMapping( interpolatedTrimmed( parser.nextText(), "outputFileNameMapping" ) );
948 }
949 else if ( checkFieldWithDuplicate( parser, "unpack", null, parsed ) )
950 {
951 dependencySet.setUnpack( getBooleanValue( interpolatedTrimmed( parser.nextText(), "unpack" ), "unpack", parser, "false" ) );
952 }
953 else if ( checkFieldWithDuplicate( parser, "unpackOptions", null, parsed ) )
954 {
955 dependencySet.setUnpackOptions( parseUnpackOptions( parser, strict ) );
956 }
957 else if ( checkFieldWithDuplicate( parser, "scope", null, parsed ) )
958 {
959 dependencySet.setScope( interpolatedTrimmed( parser.nextText(), "scope" ) );
960 }
961 else if ( checkFieldWithDuplicate( parser, "useProjectArtifact", null, parsed ) )
962 {
963 dependencySet.setUseProjectArtifact( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useProjectArtifact" ), "useProjectArtifact", parser, "true" ) );
964 }
965 else if ( checkFieldWithDuplicate( parser, "useProjectAttachments", null, parsed ) )
966 {
967 dependencySet.setUseProjectAttachments( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useProjectAttachments" ), "useProjectAttachments", parser, "false" ) );
968 }
969 else if ( checkFieldWithDuplicate( parser, "useTransitiveDependencies", null, parsed ) )
970 {
971 dependencySet.setUseTransitiveDependencies( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useTransitiveDependencies" ), "useTransitiveDependencies", parser, "true" ) );
972 }
973 else if ( checkFieldWithDuplicate( parser, "useTransitiveFiltering", null, parsed ) )
974 {
975 dependencySet.setUseTransitiveFiltering( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useTransitiveFiltering" ), "useTransitiveFiltering", parser, "false" ) );
976 }
977 else
978 {
979 checkUnknownElement( parser, strict );
980 }
981 }
982 return dependencySet;
983 }
984
985
986
987
988
989
990
991
992
993
994
995 private FileItem parseFileItem( XmlPullParser parser, boolean strict )
996 throws IOException, XmlPullParserException
997 {
998 String tagName = parser.getName();
999 FileItem fileItem = new FileItem();
1000 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1001 {
1002 String name = parser.getAttributeName( i );
1003 String value = parser.getAttributeValue( i );
1004
1005 if ( name.indexOf( ':' ) >= 0 )
1006 {
1007
1008 }
1009 else
1010 {
1011 checkUnknownAttribute( parser, name, tagName, strict );
1012 }
1013 }
1014 java.util.Set parsed = new java.util.HashSet();
1015 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1016 {
1017 if ( checkFieldWithDuplicate( parser, "source", null, parsed ) )
1018 {
1019 fileItem.setSource( interpolatedTrimmed( parser.nextText(), "source" ) );
1020 }
1021 else if ( checkFieldWithDuplicate( parser, "sources", null, parsed ) )
1022 {
1023 java.util.List<String> sources = new java.util.ArrayList<String>();
1024 fileItem.setSources( sources );
1025 while ( parser.nextTag() == XmlPullParser.START_TAG )
1026 {
1027 if ( "source".equals( parser.getName() ) )
1028 {
1029 sources.add( interpolatedTrimmed( parser.nextText(), "sources" ) );
1030 }
1031 else
1032 {
1033 checkUnknownElement( parser, strict );
1034 }
1035 }
1036 }
1037 else if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
1038 {
1039 fileItem.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
1040 }
1041 else if ( checkFieldWithDuplicate( parser, "destName", null, parsed ) )
1042 {
1043 fileItem.setDestName( interpolatedTrimmed( parser.nextText(), "destName" ) );
1044 }
1045 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
1046 {
1047 fileItem.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
1048 }
1049 else if ( checkFieldWithDuplicate( parser, "lineEnding", null, parsed ) )
1050 {
1051 fileItem.setLineEnding( interpolatedTrimmed( parser.nextText(), "lineEnding" ) );
1052 }
1053 else if ( checkFieldWithDuplicate( parser, "filtered", null, parsed ) )
1054 {
1055 fileItem.setFiltered( getBooleanValue( interpolatedTrimmed( parser.nextText(), "filtered" ), "filtered", parser, "false" ) );
1056 }
1057 else
1058 {
1059 checkUnknownElement( parser, strict );
1060 }
1061 }
1062 return fileItem;
1063 }
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075 private FileSet parseFileSet( XmlPullParser parser, boolean strict )
1076 throws IOException, XmlPullParserException
1077 {
1078 String tagName = parser.getName();
1079 FileSet fileSet = new FileSet();
1080 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1081 {
1082 String name = parser.getAttributeName( i );
1083 String value = parser.getAttributeValue( i );
1084
1085 if ( name.indexOf( ':' ) >= 0 )
1086 {
1087
1088 }
1089 else
1090 {
1091 checkUnknownAttribute( parser, name, tagName, strict );
1092 }
1093 }
1094 java.util.Set parsed = new java.util.HashSet();
1095 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1096 {
1097 if ( checkFieldWithDuplicate( parser, "useDefaultExcludes", null, parsed ) )
1098 {
1099 fileSet.setUseDefaultExcludes( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useDefaultExcludes" ), "useDefaultExcludes", parser, "true" ) );
1100 }
1101 else if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
1102 {
1103 fileSet.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
1104 }
1105 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1106 {
1107 java.util.List<String> includes = new java.util.ArrayList<String>();
1108 fileSet.setIncludes( includes );
1109 while ( parser.nextTag() == XmlPullParser.START_TAG )
1110 {
1111 if ( "include".equals( parser.getName() ) )
1112 {
1113 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1114 }
1115 else
1116 {
1117 checkUnknownElement( parser, strict );
1118 }
1119 }
1120 }
1121 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1122 {
1123 java.util.List<String> excludes = new java.util.ArrayList<String>();
1124 fileSet.setExcludes( excludes );
1125 while ( parser.nextTag() == XmlPullParser.START_TAG )
1126 {
1127 if ( "exclude".equals( parser.getName() ) )
1128 {
1129 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1130 }
1131 else
1132 {
1133 checkUnknownElement( parser, strict );
1134 }
1135 }
1136 }
1137 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
1138 {
1139 fileSet.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
1140 }
1141 else if ( checkFieldWithDuplicate( parser, "directoryMode", null, parsed ) )
1142 {
1143 fileSet.setDirectoryMode( interpolatedTrimmed( parser.nextText(), "directoryMode" ) );
1144 }
1145 else if ( checkFieldWithDuplicate( parser, "directory", null, parsed ) )
1146 {
1147 fileSet.setDirectory( interpolatedTrimmed( parser.nextText(), "directory" ) );
1148 }
1149 else if ( checkFieldWithDuplicate( parser, "lineEnding", null, parsed ) )
1150 {
1151 fileSet.setLineEnding( interpolatedTrimmed( parser.nextText(), "lineEnding" ) );
1152 }
1153 else if ( checkFieldWithDuplicate( parser, "filtered", null, parsed ) )
1154 {
1155 fileSet.setFiltered( getBooleanValue( interpolatedTrimmed( parser.nextText(), "filtered" ), "filtered", parser, "false" ) );
1156 }
1157 else if ( checkFieldWithDuplicate( parser, "nonFilteredFileExtensions", null, parsed ) )
1158 {
1159 java.util.List<String> nonFilteredFileExtensions = new java.util.ArrayList<String>();
1160 fileSet.setNonFilteredFileExtensions( nonFilteredFileExtensions );
1161 while ( parser.nextTag() == XmlPullParser.START_TAG )
1162 {
1163 if ( "nonFilteredFileExtension".equals( parser.getName() ) )
1164 {
1165 nonFilteredFileExtensions.add( interpolatedTrimmed( parser.nextText(), "nonFilteredFileExtensions" ) );
1166 }
1167 else
1168 {
1169 checkUnknownElement( parser, strict );
1170 }
1171 }
1172 }
1173 else
1174 {
1175 checkUnknownElement( parser, strict );
1176 }
1177 }
1178 return fileSet;
1179 }
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191 private GroupVersionAlignment parseGroupVersionAlignment( XmlPullParser parser, boolean strict )
1192 throws IOException, XmlPullParserException
1193 {
1194 String tagName = parser.getName();
1195 GroupVersionAlignment groupVersionAlignment = new GroupVersionAlignment();
1196 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1197 {
1198 String name = parser.getAttributeName( i );
1199 String value = parser.getAttributeValue( i );
1200
1201 if ( name.indexOf( ':' ) >= 0 )
1202 {
1203
1204 }
1205 else
1206 {
1207 checkUnknownAttribute( parser, name, tagName, strict );
1208 }
1209 }
1210 java.util.Set parsed = new java.util.HashSet();
1211 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1212 {
1213 if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1214 {
1215 groupVersionAlignment.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1216 }
1217 else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
1218 {
1219 groupVersionAlignment.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
1220 }
1221 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1222 {
1223 java.util.List<String> excludes = new java.util.ArrayList<String>();
1224 groupVersionAlignment.setExcludes( excludes );
1225 while ( parser.nextTag() == XmlPullParser.START_TAG )
1226 {
1227 if ( "exclude".equals( parser.getName() ) )
1228 {
1229 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1230 }
1231 else
1232 {
1233 checkUnknownElement( parser, strict );
1234 }
1235 }
1236 }
1237 else
1238 {
1239 checkUnknownElement( parser, strict );
1240 }
1241 }
1242 return groupVersionAlignment;
1243 }
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255 private ModuleBinaries parseModuleBinaries( XmlPullParser parser, boolean strict )
1256 throws IOException, XmlPullParserException
1257 {
1258 String tagName = parser.getName();
1259 ModuleBinaries moduleBinaries = new ModuleBinaries();
1260 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1261 {
1262 String name = parser.getAttributeName( i );
1263 String value = parser.getAttributeValue( i );
1264
1265 if ( name.indexOf( ':' ) >= 0 )
1266 {
1267
1268 }
1269 else
1270 {
1271 checkUnknownAttribute( parser, name, tagName, strict );
1272 }
1273 }
1274 java.util.Set parsed = new java.util.HashSet();
1275 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1276 {
1277 if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
1278 {
1279 moduleBinaries.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
1280 }
1281 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1282 {
1283 java.util.List<String> includes = new java.util.ArrayList<String>();
1284 moduleBinaries.setIncludes( includes );
1285 while ( parser.nextTag() == XmlPullParser.START_TAG )
1286 {
1287 if ( "include".equals( parser.getName() ) )
1288 {
1289 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1290 }
1291 else
1292 {
1293 checkUnknownElement( parser, strict );
1294 }
1295 }
1296 }
1297 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1298 {
1299 java.util.List<String> excludes = new java.util.ArrayList<String>();
1300 moduleBinaries.setExcludes( excludes );
1301 while ( parser.nextTag() == XmlPullParser.START_TAG )
1302 {
1303 if ( "exclude".equals( parser.getName() ) )
1304 {
1305 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1306 }
1307 else
1308 {
1309 checkUnknownElement( parser, strict );
1310 }
1311 }
1312 }
1313 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
1314 {
1315 moduleBinaries.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
1316 }
1317 else if ( checkFieldWithDuplicate( parser, "directoryMode", null, parsed ) )
1318 {
1319 moduleBinaries.setDirectoryMode( interpolatedTrimmed( parser.nextText(), "directoryMode" ) );
1320 }
1321 else if ( checkFieldWithDuplicate( parser, "attachmentClassifier", null, parsed ) )
1322 {
1323 moduleBinaries.setAttachmentClassifier( interpolatedTrimmed( parser.nextText(), "attachmentClassifier" ) );
1324 }
1325 else if ( checkFieldWithDuplicate( parser, "includeDependencies", null, parsed ) )
1326 {
1327 moduleBinaries.setIncludeDependencies( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeDependencies" ), "includeDependencies", parser, "true" ) );
1328 }
1329 else if ( checkFieldWithDuplicate( parser, "dependencySets", null, parsed ) )
1330 {
1331 java.util.List<DependencySet> dependencySets = new java.util.ArrayList<DependencySet>();
1332 moduleBinaries.setDependencySets( dependencySets );
1333 while ( parser.nextTag() == XmlPullParser.START_TAG )
1334 {
1335 if ( "dependencySet".equals( parser.getName() ) )
1336 {
1337 dependencySets.add( parseDependencySet( parser, strict ) );
1338 }
1339 else
1340 {
1341 checkUnknownElement( parser, strict );
1342 }
1343 }
1344 }
1345 else if ( checkFieldWithDuplicate( parser, "unpack", null, parsed ) )
1346 {
1347 moduleBinaries.setUnpack( getBooleanValue( interpolatedTrimmed( parser.nextText(), "unpack" ), "unpack", parser, "true" ) );
1348 }
1349 else if ( checkFieldWithDuplicate( parser, "unpackOptions", null, parsed ) )
1350 {
1351 moduleBinaries.setUnpackOptions( parseUnpackOptions( parser, strict ) );
1352 }
1353 else if ( checkFieldWithDuplicate( parser, "outputFileNameMapping", null, parsed ) )
1354 {
1355 moduleBinaries.setOutputFileNameMapping( interpolatedTrimmed( parser.nextText(), "outputFileNameMapping" ) );
1356 }
1357 else
1358 {
1359 checkUnknownElement( parser, strict );
1360 }
1361 }
1362 return moduleBinaries;
1363 }
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375 private ModuleSet parseModuleSet( XmlPullParser parser, boolean strict )
1376 throws IOException, XmlPullParserException
1377 {
1378 String tagName = parser.getName();
1379 ModuleSet moduleSet = new ModuleSet();
1380 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1381 {
1382 String name = parser.getAttributeName( i );
1383 String value = parser.getAttributeValue( i );
1384
1385 if ( name.indexOf( ':' ) >= 0 )
1386 {
1387
1388 }
1389 else
1390 {
1391 checkUnknownAttribute( parser, name, tagName, strict );
1392 }
1393 }
1394 java.util.Set parsed = new java.util.HashSet();
1395 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1396 {
1397 if ( checkFieldWithDuplicate( parser, "useAllReactorProjects", null, parsed ) )
1398 {
1399 moduleSet.setUseAllReactorProjects( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useAllReactorProjects" ), "useAllReactorProjects", parser, "false" ) );
1400 }
1401 else if ( checkFieldWithDuplicate( parser, "includeSubModules", null, parsed ) )
1402 {
1403 moduleSet.setIncludeSubModules( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeSubModules" ), "includeSubModules", parser, "true" ) );
1404 }
1405 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1406 {
1407 java.util.List<String> includes = new java.util.ArrayList<String>();
1408 moduleSet.setIncludes( includes );
1409 while ( parser.nextTag() == XmlPullParser.START_TAG )
1410 {
1411 if ( "include".equals( parser.getName() ) )
1412 {
1413 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1414 }
1415 else
1416 {
1417 checkUnknownElement( parser, strict );
1418 }
1419 }
1420 }
1421 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1422 {
1423 java.util.List<String> excludes = new java.util.ArrayList<String>();
1424 moduleSet.setExcludes( excludes );
1425 while ( parser.nextTag() == XmlPullParser.START_TAG )
1426 {
1427 if ( "exclude".equals( parser.getName() ) )
1428 {
1429 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1430 }
1431 else
1432 {
1433 checkUnknownElement( parser, strict );
1434 }
1435 }
1436 }
1437 else if ( checkFieldWithDuplicate( parser, "sources", null, parsed ) )
1438 {
1439 moduleSet.setSources( parseModuleSources( parser, strict ) );
1440 }
1441 else if ( checkFieldWithDuplicate( parser, "binaries", null, parsed ) )
1442 {
1443 moduleSet.setBinaries( parseModuleBinaries( parser, strict ) );
1444 }
1445 else
1446 {
1447 checkUnknownElement( parser, strict );
1448 }
1449 }
1450 return moduleSet;
1451 }
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463 private ModuleSources parseModuleSources( XmlPullParser parser, boolean strict )
1464 throws IOException, XmlPullParserException
1465 {
1466 String tagName = parser.getName();
1467 ModuleSources moduleSources = new ModuleSources();
1468 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1469 {
1470 String name = parser.getAttributeName( i );
1471 String value = parser.getAttributeValue( i );
1472
1473 if ( name.indexOf( ':' ) >= 0 )
1474 {
1475
1476 }
1477 else
1478 {
1479 checkUnknownAttribute( parser, name, tagName, strict );
1480 }
1481 }
1482 java.util.Set parsed = new java.util.HashSet();
1483 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1484 {
1485 if ( checkFieldWithDuplicate( parser, "useDefaultExcludes", null, parsed ) )
1486 {
1487 moduleSources.setUseDefaultExcludes( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useDefaultExcludes" ), "useDefaultExcludes", parser, "true" ) );
1488 }
1489 else if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
1490 {
1491 moduleSources.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
1492 }
1493 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1494 {
1495 java.util.List<String> includes = new java.util.ArrayList<String>();
1496 moduleSources.setIncludes( includes );
1497 while ( parser.nextTag() == XmlPullParser.START_TAG )
1498 {
1499 if ( "include".equals( parser.getName() ) )
1500 {
1501 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1502 }
1503 else
1504 {
1505 checkUnknownElement( parser, strict );
1506 }
1507 }
1508 }
1509 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1510 {
1511 java.util.List<String> excludes = new java.util.ArrayList<String>();
1512 moduleSources.setExcludes( excludes );
1513 while ( parser.nextTag() == XmlPullParser.START_TAG )
1514 {
1515 if ( "exclude".equals( parser.getName() ) )
1516 {
1517 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1518 }
1519 else
1520 {
1521 checkUnknownElement( parser, strict );
1522 }
1523 }
1524 }
1525 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
1526 {
1527 moduleSources.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
1528 }
1529 else if ( checkFieldWithDuplicate( parser, "directoryMode", null, parsed ) )
1530 {
1531 moduleSources.setDirectoryMode( interpolatedTrimmed( parser.nextText(), "directoryMode" ) );
1532 }
1533 else if ( checkFieldWithDuplicate( parser, "fileSets", null, parsed ) )
1534 {
1535 java.util.List<FileSet> fileSets = new java.util.ArrayList<FileSet>();
1536 moduleSources.setFileSets( fileSets );
1537 while ( parser.nextTag() == XmlPullParser.START_TAG )
1538 {
1539 if ( "fileSet".equals( parser.getName() ) )
1540 {
1541 fileSets.add( parseFileSet( parser, strict ) );
1542 }
1543 else
1544 {
1545 checkUnknownElement( parser, strict );
1546 }
1547 }
1548 }
1549 else if ( checkFieldWithDuplicate( parser, "includeModuleDirectory", null, parsed ) )
1550 {
1551 moduleSources.setIncludeModuleDirectory( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeModuleDirectory" ), "includeModuleDirectory", parser, "true" ) );
1552 }
1553 else if ( checkFieldWithDuplicate( parser, "excludeSubModuleDirectories", null, parsed ) )
1554 {
1555 moduleSources.setExcludeSubModuleDirectories( getBooleanValue( interpolatedTrimmed( parser.nextText(), "excludeSubModuleDirectories" ), "excludeSubModuleDirectories", parser, "true" ) );
1556 }
1557 else if ( checkFieldWithDuplicate( parser, "outputDirectoryMapping", null, parsed ) )
1558 {
1559 moduleSources.setOutputDirectoryMapping( interpolatedTrimmed( parser.nextText(), "outputDirectoryMapping" ) );
1560 }
1561 else
1562 {
1563 checkUnknownElement( parser, strict );
1564 }
1565 }
1566 return moduleSources;
1567 }
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579 private Repository parseRepository( XmlPullParser parser, boolean strict )
1580 throws IOException, XmlPullParserException
1581 {
1582 String tagName = parser.getName();
1583 Repository repository = new Repository();
1584 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1585 {
1586 String name = parser.getAttributeName( i );
1587 String value = parser.getAttributeValue( i );
1588
1589 if ( name.indexOf( ':' ) >= 0 )
1590 {
1591
1592 }
1593 else
1594 {
1595 checkUnknownAttribute( parser, name, tagName, strict );
1596 }
1597 }
1598 java.util.Set parsed = new java.util.HashSet();
1599 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1600 {
1601 if ( checkFieldWithDuplicate( parser, "outputDirectory", null, parsed ) )
1602 {
1603 repository.setOutputDirectory( interpolatedTrimmed( parser.nextText(), "outputDirectory" ) );
1604 }
1605 else if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1606 {
1607 java.util.List<String> includes = new java.util.ArrayList<String>();
1608 repository.setIncludes( includes );
1609 while ( parser.nextTag() == XmlPullParser.START_TAG )
1610 {
1611 if ( "include".equals( parser.getName() ) )
1612 {
1613 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1614 }
1615 else
1616 {
1617 checkUnknownElement( parser, strict );
1618 }
1619 }
1620 }
1621 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1622 {
1623 java.util.List<String> excludes = new java.util.ArrayList<String>();
1624 repository.setExcludes( excludes );
1625 while ( parser.nextTag() == XmlPullParser.START_TAG )
1626 {
1627 if ( "exclude".equals( parser.getName() ) )
1628 {
1629 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1630 }
1631 else
1632 {
1633 checkUnknownElement( parser, strict );
1634 }
1635 }
1636 }
1637 else if ( checkFieldWithDuplicate( parser, "fileMode", null, parsed ) )
1638 {
1639 repository.setFileMode( interpolatedTrimmed( parser.nextText(), "fileMode" ) );
1640 }
1641 else if ( checkFieldWithDuplicate( parser, "directoryMode", null, parsed ) )
1642 {
1643 repository.setDirectoryMode( interpolatedTrimmed( parser.nextText(), "directoryMode" ) );
1644 }
1645 else if ( checkFieldWithDuplicate( parser, "includeMetadata", null, parsed ) )
1646 {
1647 repository.setIncludeMetadata( getBooleanValue( interpolatedTrimmed( parser.nextText(), "includeMetadata" ), "includeMetadata", parser, "false" ) );
1648 }
1649 else if ( checkFieldWithDuplicate( parser, "groupVersionAlignments", null, parsed ) )
1650 {
1651 java.util.List<GroupVersionAlignment> groupVersionAlignments = new java.util.ArrayList<GroupVersionAlignment>();
1652 repository.setGroupVersionAlignments( groupVersionAlignments );
1653 while ( parser.nextTag() == XmlPullParser.START_TAG )
1654 {
1655 if ( "groupVersionAlignment".equals( parser.getName() ) )
1656 {
1657 groupVersionAlignments.add( parseGroupVersionAlignment( parser, strict ) );
1658 }
1659 else
1660 {
1661 checkUnknownElement( parser, strict );
1662 }
1663 }
1664 }
1665 else if ( checkFieldWithDuplicate( parser, "scope", null, parsed ) )
1666 {
1667 repository.setScope( interpolatedTrimmed( parser.nextText(), "scope" ) );
1668 }
1669 else
1670 {
1671 checkUnknownElement( parser, strict );
1672 }
1673 }
1674 return repository;
1675 }
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687 private UnpackOptions parseUnpackOptions( XmlPullParser parser, boolean strict )
1688 throws IOException, XmlPullParserException
1689 {
1690 String tagName = parser.getName();
1691 UnpackOptions unpackOptions = new UnpackOptions();
1692 for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1693 {
1694 String name = parser.getAttributeName( i );
1695 String value = parser.getAttributeValue( i );
1696
1697 if ( name.indexOf( ':' ) >= 0 )
1698 {
1699
1700 }
1701 else
1702 {
1703 checkUnknownAttribute( parser, name, tagName, strict );
1704 }
1705 }
1706 java.util.Set parsed = new java.util.HashSet();
1707 while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1708 {
1709 if ( checkFieldWithDuplicate( parser, "includes", null, parsed ) )
1710 {
1711 java.util.List<String> includes = new java.util.ArrayList<String>();
1712 unpackOptions.setIncludes( includes );
1713 while ( parser.nextTag() == XmlPullParser.START_TAG )
1714 {
1715 if ( "include".equals( parser.getName() ) )
1716 {
1717 includes.add( interpolatedTrimmed( parser.nextText(), "includes" ) );
1718 }
1719 else
1720 {
1721 checkUnknownElement( parser, strict );
1722 }
1723 }
1724 }
1725 else if ( checkFieldWithDuplicate( parser, "excludes", null, parsed ) )
1726 {
1727 java.util.List<String> excludes = new java.util.ArrayList<String>();
1728 unpackOptions.setExcludes( excludes );
1729 while ( parser.nextTag() == XmlPullParser.START_TAG )
1730 {
1731 if ( "exclude".equals( parser.getName() ) )
1732 {
1733 excludes.add( interpolatedTrimmed( parser.nextText(), "excludes" ) );
1734 }
1735 else
1736 {
1737 checkUnknownElement( parser, strict );
1738 }
1739 }
1740 }
1741 else if ( checkFieldWithDuplicate( parser, "filtered", null, parsed ) )
1742 {
1743 unpackOptions.setFiltered( getBooleanValue( interpolatedTrimmed( parser.nextText(), "filtered" ), "filtered", parser, "false" ) );
1744 }
1745 else if ( checkFieldWithDuplicate( parser, "nonFilteredFileExtensions", null, parsed ) )
1746 {
1747 java.util.List<String> nonFilteredFileExtensions = new java.util.ArrayList<String>();
1748 unpackOptions.setNonFilteredFileExtensions( nonFilteredFileExtensions );
1749 while ( parser.nextTag() == XmlPullParser.START_TAG )
1750 {
1751 if ( "nonFilteredFileExtension".equals( parser.getName() ) )
1752 {
1753 nonFilteredFileExtensions.add( interpolatedTrimmed( parser.nextText(), "nonFilteredFileExtensions" ) );
1754 }
1755 else
1756 {
1757 checkUnknownElement( parser, strict );
1758 }
1759 }
1760 }
1761 else if ( checkFieldWithDuplicate( parser, "lineEnding", null, parsed ) )
1762 {
1763 unpackOptions.setLineEnding( interpolatedTrimmed( parser.nextText(), "lineEnding" ) );
1764 }
1765 else if ( checkFieldWithDuplicate( parser, "useDefaultExcludes", null, parsed ) )
1766 {
1767 unpackOptions.setUseDefaultExcludes( getBooleanValue( interpolatedTrimmed( parser.nextText(), "useDefaultExcludes" ), "useDefaultExcludes", parser, "true" ) );
1768 }
1769 else if ( checkFieldWithDuplicate( parser, "encoding", null, parsed ) )
1770 {
1771 unpackOptions.setEncoding( interpolatedTrimmed( parser.nextText(), "encoding" ) );
1772 }
1773 else
1774 {
1775 checkUnknownElement( parser, strict );
1776 }
1777 }
1778 return unpackOptions;
1779 }
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791 private Assembly read( XmlPullParser parser, boolean strict )
1792 throws IOException, XmlPullParserException
1793 {
1794 Assembly assembly = null;
1795 int eventType = parser.getEventType();
1796 boolean parsed = false;
1797 while ( eventType != XmlPullParser.END_DOCUMENT )
1798 {
1799 if ( eventType == XmlPullParser.START_TAG )
1800 {
1801 if ( strict && ! "assembly".equals( parser.getName() ) )
1802 {
1803 throw new XmlPullParserException( "Expected root element 'assembly' but found '" + parser.getName() + "'", parser, null );
1804 }
1805 else if ( parsed )
1806 {
1807
1808 throw new XmlPullParserException( "Duplicated tag: 'assembly'", parser, null );
1809 }
1810 assembly = parseAssembly( parser, strict );
1811 assembly.setModelEncoding( parser.getInputEncoding() );
1812 parsed = true;
1813 }
1814 eventType = parser.next();
1815 }
1816 if ( parsed )
1817 {
1818 return assembly;
1819 }
1820 throw new XmlPullParserException( "Expected root element 'assembly' but found no element at all: invalid XML document", parser, null );
1821 }
1822
1823
1824
1825
1826
1827
1828 public void setAddDefaultEntities( boolean addDefaultEntities )
1829 {
1830 this.addDefaultEntities = addDefaultEntities;
1831 }
1832
1833 public static interface ContentTransformer
1834 {
1835
1836
1837
1838
1839
1840
1841
1842 String transform( String source, String fieldName );
1843 }
1844
1845 }