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