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