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.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.plugin.lifecycle.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.plugin.lifecycle.Execution;
35  import org.apache.maven.plugin.lifecycle.Lifecycle;
36  import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
37  import org.apache.maven.plugin.lifecycle.Phase;
38  import org.codehaus.plexus.util.xml.XmlStreamReader;
39  import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
40  import org.codehaus.plexus.util.xml.pull.MXParser;
41  import org.codehaus.plexus.util.xml.pull.XmlPullParser;
42  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
43  
44  /**
45   * Class LifecycleMappingsXpp3Reader.
46   * 
47   * @version $Revision$ $Date$
48   */
49  @SuppressWarnings( "all" )
50  public class LifecycleMappingsXpp3Reader
51  {
52  
53        //--------------------------/
54       //- Class/Member Variables -/
55      //--------------------------/
56  
57      /**
58       * If set the parser will be loaded with all single characters
59       * from the XHTML specification.
60       * The entities used:
61       * <ul>
62       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
63       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
64       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
65       * </ul>
66       */
67      private boolean addDefaultEntities = true;
68  
69      /**
70       * Field contentTransformer.
71       */
72      public final ContentTransformer contentTransformer;
73  
74  
75        //----------------/
76       //- Constructors -/
77      //----------------/
78  
79      public LifecycleMappingsXpp3Reader()
80      {
81          this( new ContentTransformer()
82          {
83              public String transform( String source, String fieldName )
84              {
85                  return source;
86              }
87          } );
88      } //-- org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader()
89  
90      public LifecycleMappingsXpp3Reader(ContentTransformer contentTransformer)
91      {
92          this.contentTransformer = contentTransformer;
93      } //-- org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader(ContentTransformer)
94  
95  
96        //-----------/
97       //- Methods -/
98      //-----------/
99  
100     /**
101      * Method checkFieldWithDuplicate.
102      * 
103      * @param parser a parser object.
104      * @param parsed a parsed object.
105      * @param alias a alias object.
106      * @param tagName a tagName object.
107      * @throws XmlPullParserException XmlPullParserException if
108      * any.
109      * @return boolean
110      */
111     private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set<String> parsed )
112         throws XmlPullParserException
113     {
114         if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
115         {
116             return false;
117         }
118         if ( !parsed.add( tagName ) )
119         {
120             throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
121         }
122         return true;
123     } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set )
124 
125     /**
126      * Method checkUnknownAttribute.
127      * 
128      * @param parser a parser object.
129      * @param strict a strict object.
130      * @param tagName a tagName object.
131      * @param attribute a attribute object.
132      * @throws XmlPullParserException XmlPullParserException if
133      * any.
134      * @throws IOException IOException if any.
135      */
136     private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
137         throws XmlPullParserException, IOException
138     {
139         // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
140         if ( strict )
141         {
142             throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
143         }
144     } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean )
145 
146     /**
147      * Method checkUnknownElement.
148      * 
149      * @param parser a parser object.
150      * @param strict a strict object.
151      * @throws XmlPullParserException XmlPullParserException if
152      * any.
153      * @throws IOException IOException if any.
154      */
155     private void checkUnknownElement( XmlPullParser parser, boolean strict )
156         throws XmlPullParserException, IOException
157     {
158         if ( strict )
159         {
160             throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
161         }
162 
163         for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
164         {
165             int eventType = parser.next();
166             if ( eventType == XmlPullParser.START_TAG )
167             {
168                 unrecognizedTagCount++;
169             }
170             else if ( eventType == XmlPullParser.END_TAG )
171             {
172                 unrecognizedTagCount--;
173             }
174         }
175     } //-- void checkUnknownElement( XmlPullParser, boolean )
176 
177     /**
178      * Returns the state of the "add default entities" flag.
179      * 
180      * @return boolean
181      */
182     public boolean getAddDefaultEntities()
183     {
184         return addDefaultEntities;
185     } //-- boolean getAddDefaultEntities()
186 
187     /**
188      * Method getBooleanValue.
189      * 
190      * @param s a s object.
191      * @param parser a parser object.
192      * @param attribute a attribute object.
193      * @throws XmlPullParserException XmlPullParserException if
194      * any.
195      * @return boolean
196      */
197     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
198         throws XmlPullParserException
199     {
200         return getBooleanValue( s, attribute, parser, null );
201     } //-- boolean getBooleanValue( String, String, XmlPullParser )
202 
203     /**
204      * Method getBooleanValue.
205      * 
206      * @param s a s object.
207      * @param defaultValue a defaultValue object.
208      * @param parser a parser object.
209      * @param attribute a attribute object.
210      * @throws XmlPullParserException XmlPullParserException if
211      * any.
212      * @return boolean
213      */
214     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
215         throws XmlPullParserException
216     {
217         if ( s != null && s.length() != 0 )
218         {
219             return Boolean.valueOf( s ).booleanValue();
220         }
221         if ( defaultValue != null )
222         {
223             return Boolean.valueOf( defaultValue ).booleanValue();
224         }
225         return false;
226     } //-- boolean getBooleanValue( String, String, XmlPullParser, String )
227 
228     /**
229      * Method getByteValue.
230      * 
231      * @param s a s object.
232      * @param strict a strict object.
233      * @param parser a parser object.
234      * @param attribute a attribute object.
235      * @throws XmlPullParserException XmlPullParserException if
236      * any.
237      * @return byte
238      */
239     private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
240         throws XmlPullParserException
241     {
242         if ( s != null )
243         {
244             try
245             {
246                 return Byte.valueOf( s ).byteValue();
247             }
248             catch ( NumberFormatException nfe )
249             {
250                 if ( strict )
251                 {
252                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
253                 }
254             }
255         }
256         return 0;
257     } //-- byte getByteValue( String, String, XmlPullParser, boolean )
258 
259     /**
260      * Method getCharacterValue.
261      * 
262      * @param s a s object.
263      * @param parser a parser object.
264      * @param attribute a attribute object.
265      * @throws XmlPullParserException XmlPullParserException if
266      * any.
267      * @return char
268      */
269     private char getCharacterValue( String s, String attribute, XmlPullParser parser )
270         throws XmlPullParserException
271     {
272         if ( s != null )
273         {
274             return s.charAt( 0 );
275         }
276         return 0;
277     } //-- char getCharacterValue( String, String, XmlPullParser )
278 
279     /**
280      * Method getDateValue.
281      * 
282      * @param s a s object.
283      * @param parser a parser object.
284      * @param attribute a attribute object.
285      * @throws XmlPullParserException XmlPullParserException if
286      * any.
287      * @return Date
288      */
289     private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
290         throws XmlPullParserException
291     {
292         return getDateValue( s, attribute, null, parser );
293     } //-- java.util.Date getDateValue( String, String, XmlPullParser )
294 
295     /**
296      * Method getDateValue.
297      * 
298      * @param s a s object.
299      * @param parser a parser object.
300      * @param dateFormat a dateFormat object.
301      * @param attribute a attribute object.
302      * @throws XmlPullParserException XmlPullParserException if
303      * any.
304      * @return Date
305      */
306     private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
307         throws XmlPullParserException
308     {
309         if ( s != null )
310         {
311             String effectiveDateFormat = dateFormat;
312             if ( dateFormat == null )
313             {
314                 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
315             }
316             if ( "long".equals( effectiveDateFormat ) )
317             {
318                 try
319                 {
320                     return new java.util.Date( Long.parseLong( s ) );
321                 }
322                 catch ( NumberFormatException e )
323                 {
324                     throw new XmlPullParserException( e.getMessage(), parser, e );
325                 }
326             }
327             else
328             {
329                 try
330                 {
331                     DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
332                     return dateParser.parse( s );
333                 }
334                 catch ( java.text.ParseException e )
335                 {
336                     throw new XmlPullParserException( e.getMessage(), parser, e );
337                 }
338             }
339         }
340         return null;
341     } //-- java.util.Date getDateValue( String, String, String, XmlPullParser )
342 
343     /**
344      * Method getDoubleValue.
345      * 
346      * @param s a s object.
347      * @param strict a strict object.
348      * @param parser a parser object.
349      * @param attribute a attribute object.
350      * @throws XmlPullParserException XmlPullParserException if
351      * any.
352      * @return double
353      */
354     private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
355         throws XmlPullParserException
356     {
357         if ( s != null )
358         {
359             try
360             {
361                 return Double.valueOf( s ).doubleValue();
362             }
363             catch ( NumberFormatException nfe )
364             {
365                 if ( strict )
366                 {
367                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
368                 }
369             }
370         }
371         return 0;
372     } //-- double getDoubleValue( String, String, XmlPullParser, boolean )
373 
374     /**
375      * Method getFloatValue.
376      * 
377      * @param s a s object.
378      * @param strict a strict object.
379      * @param parser a parser object.
380      * @param attribute a attribute object.
381      * @throws XmlPullParserException XmlPullParserException if
382      * any.
383      * @return float
384      */
385     private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
386         throws XmlPullParserException
387     {
388         if ( s != null )
389         {
390             try
391             {
392                 return Float.valueOf( s ).floatValue();
393             }
394             catch ( NumberFormatException nfe )
395             {
396                 if ( strict )
397                 {
398                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
399                 }
400             }
401         }
402         return 0;
403     } //-- float getFloatValue( String, String, XmlPullParser, boolean )
404 
405     /**
406      * Method getIntegerValue.
407      * 
408      * @param s a s object.
409      * @param strict a strict object.
410      * @param parser a parser object.
411      * @param attribute a attribute object.
412      * @throws XmlPullParserException XmlPullParserException if
413      * any.
414      * @return int
415      */
416     private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
417         throws XmlPullParserException
418     {
419         if ( s != null )
420         {
421             try
422             {
423                 return Integer.valueOf( s ).intValue();
424             }
425             catch ( NumberFormatException nfe )
426             {
427                 if ( strict )
428                 {
429                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
430                 }
431             }
432         }
433         return 0;
434     } //-- int getIntegerValue( String, String, XmlPullParser, boolean )
435 
436     /**
437      * Method getLongValue.
438      * 
439      * @param s a s object.
440      * @param strict a strict object.
441      * @param parser a parser object.
442      * @param attribute a attribute object.
443      * @throws XmlPullParserException XmlPullParserException if
444      * any.
445      * @return long
446      */
447     private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
448         throws XmlPullParserException
449     {
450         if ( s != null )
451         {
452             try
453             {
454                 return Long.valueOf( s ).longValue();
455             }
456             catch ( NumberFormatException nfe )
457             {
458                 if ( strict )
459                 {
460                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
461                 }
462             }
463         }
464         return 0;
465     } //-- long getLongValue( String, String, XmlPullParser, boolean )
466 
467     /**
468      * Method getRequiredAttributeValue.
469      * 
470      * @param s a s object.
471      * @param strict a strict object.
472      * @param parser a parser object.
473      * @param attribute a attribute object.
474      * @throws XmlPullParserException XmlPullParserException if
475      * any.
476      * @return String
477      */
478     private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
479         throws XmlPullParserException
480     {
481         if ( s == null )
482         {
483             if ( strict )
484             {
485                 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
486             }
487         }
488         return s;
489     } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean )
490 
491     /**
492      * Method getShortValue.
493      * 
494      * @param s a s object.
495      * @param strict a strict object.
496      * @param parser a parser object.
497      * @param attribute a attribute object.
498      * @throws XmlPullParserException XmlPullParserException if
499      * any.
500      * @return short
501      */
502     private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
503         throws XmlPullParserException
504     {
505         if ( s != null )
506         {
507             try
508             {
509                 return Short.valueOf( s ).shortValue();
510             }
511             catch ( NumberFormatException nfe )
512             {
513                 if ( strict )
514                 {
515                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
516                 }
517             }
518         }
519         return 0;
520     } //-- short getShortValue( String, String, XmlPullParser, boolean )
521 
522     /**
523      * Method getTrimmedValue.
524      * 
525      * @param s a s object.
526      * @return String
527      */
528     private String getTrimmedValue( String s )
529     {
530         if ( s != null )
531         {
532             s = s.trim();
533         }
534         return s;
535     } //-- String getTrimmedValue( String )
536 
537     /**
538      * Method interpolatedTrimmed.
539      * 
540      * @param value a value object.
541      * @param context a context object.
542      * @return String
543      */
544     private String interpolatedTrimmed( String value, String context )
545     {
546         return getTrimmedValue( contentTransformer.transform( value, context ) );
547     } //-- String interpolatedTrimmed( String, String )
548 
549     /**
550      * Method nextTag.
551      * 
552      * @param parser a parser object.
553      * @throws IOException IOException if any.
554      * @throws XmlPullParserException XmlPullParserException if
555      * any.
556      * @return int
557      */
558     private int nextTag( XmlPullParser parser )
559         throws IOException, XmlPullParserException
560     {
561         int eventType = parser.next();
562         if ( eventType == XmlPullParser.TEXT )
563         {
564             eventType = parser.next();
565         }
566         if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
567         {
568             throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
569         }
570         return eventType;
571     } //-- int nextTag( XmlPullParser )
572 
573     /**
574      * Method read.
575      * 
576      * @param parser a parser object.
577      * @param strict a strict object.
578      * @throws IOException IOException if any.
579      * @throws XmlPullParserException XmlPullParserException if
580      * any.
581      * @return LifecycleConfiguration
582      */
583     public LifecycleConfiguration read( XmlPullParser parser, boolean strict )
584         throws IOException, XmlPullParserException
585     {
586         LifecycleConfiguration lifecycleConfiguration = null;
587         int eventType = parser.getEventType();
588         boolean parsed = false;
589         while ( eventType != XmlPullParser.END_DOCUMENT )
590         {
591             if ( eventType == XmlPullParser.START_TAG )
592             {
593                 if ( strict && ! "lifecycles".equals( parser.getName() ) )
594                 {
595                     throw new XmlPullParserException( "Expected root element 'lifecycles' but found '" + parser.getName() + "'", parser, null );
596                 }
597                 else if ( parsed )
598                 {
599                     // fallback, already expected a XmlPullParserException due to invalid XML
600                     throw new XmlPullParserException( "Duplicated tag: 'lifecycles'", parser, null );
601                 }
602                 lifecycleConfiguration = parseLifecycleConfiguration( parser, strict );
603                 lifecycleConfiguration.setModelEncoding( parser.getInputEncoding() );
604                 parsed = true;
605             }
606             eventType = parser.next();
607         }
608         if ( parsed )
609         {
610             return lifecycleConfiguration;
611         }
612         throw new XmlPullParserException( "Expected root element 'lifecycles' but found no element at all: invalid XML document", parser, null );
613     } //-- LifecycleConfiguration read( XmlPullParser, boolean )
614 
615     /**
616      * @see XmlStreamReader
617      * 
618      * @param reader a reader object.
619      * @param strict a strict object.
620      * @throws IOException IOException if any.
621      * @throws XmlPullParserException XmlPullParserException if
622      * any.
623      * @return LifecycleConfiguration
624      */
625     public LifecycleConfiguration read( Reader reader, boolean strict )
626         throws IOException, XmlPullParserException
627     {
628         XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
629 
630         parser.setInput( reader );
631 
632 
633         return read( parser, strict );
634     } //-- LifecycleConfiguration read( Reader, boolean )
635 
636     /**
637      * @see XmlStreamReader
638      * 
639      * @param reader a reader object.
640      * @throws IOException IOException if any.
641      * @throws XmlPullParserException XmlPullParserException if
642      * any.
643      * @return LifecycleConfiguration
644      */
645     public LifecycleConfiguration read( Reader reader )
646         throws IOException, XmlPullParserException
647     {
648         return read( reader, true );
649     } //-- LifecycleConfiguration read( Reader )
650 
651     /**
652      * Method read.
653      * 
654      * @param in a in object.
655      * @param strict a strict object.
656      * @throws IOException IOException if any.
657      * @throws XmlPullParserException XmlPullParserException if
658      * any.
659      * @return LifecycleConfiguration
660      */
661     public LifecycleConfiguration read( InputStream in, boolean strict )
662         throws IOException, XmlPullParserException
663     {
664         return read( new XmlStreamReader( in ), strict );
665     } //-- LifecycleConfiguration read( InputStream, boolean )
666 
667     /**
668      * Method read.
669      * 
670      * @param in a in object.
671      * @throws IOException IOException if any.
672      * @throws XmlPullParserException XmlPullParserException if
673      * any.
674      * @return LifecycleConfiguration
675      */
676     public LifecycleConfiguration read( InputStream in )
677         throws IOException, XmlPullParserException
678     {
679         return read( new XmlStreamReader( in ) );
680     } //-- LifecycleConfiguration read( InputStream )
681 
682     /**
683      * Method parseExecution.
684      * 
685      * @param parser a parser object.
686      * @param strict a strict object.
687      * @throws IOException IOException if any.
688      * @throws XmlPullParserException XmlPullParserException if
689      * any.
690      * @return Execution
691      */
692     private Execution parseExecution( XmlPullParser parser, boolean strict )
693         throws IOException, XmlPullParserException
694     {
695         String tagName = parser.getName();
696         Execution execution = new Execution();
697         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
698         {
699             String name = parser.getAttributeName( i );
700             String value = parser.getAttributeValue( i );
701 
702             if ( name.indexOf( ':' ) >= 0 )
703             {
704                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
705             }
706             else
707             {
708                 checkUnknownAttribute( parser, name, tagName, strict );
709             }
710         }
711         java.util.Set<String> parsed = new java.util.HashSet<String>();
712         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
713         {
714             if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
715             {
716                 execution.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
717             }
718             else if ( checkFieldWithDuplicate( parser, "goals", null, parsed ) )
719             {
720                 java.util.List<String> goals = new java.util.ArrayList<String>();
721                 while ( parser.nextTag() == XmlPullParser.START_TAG )
722                 {
723                     if ( "goal".equals( parser.getName() ) )
724                     {
725                         goals.add( interpolatedTrimmed( parser.nextText(), "goals" ) );
726                     }
727                     else
728                     {
729                         checkUnknownElement( parser, strict );
730                     }
731                 }
732                 execution.setGoals( goals );
733             }
734             else
735             {
736                 checkUnknownElement( parser, strict );
737             }
738         }
739         return execution;
740     } //-- Execution parseExecution( XmlPullParser, boolean )
741 
742     /**
743      * Method parseLifecycle.
744      * 
745      * @param parser a parser object.
746      * @param strict a strict object.
747      * @throws IOException IOException if any.
748      * @throws XmlPullParserException XmlPullParserException if
749      * any.
750      * @return Lifecycle
751      */
752     private Lifecycle parseLifecycle( XmlPullParser parser, boolean strict )
753         throws IOException, XmlPullParserException
754     {
755         String tagName = parser.getName();
756         Lifecycle lifecycle = new Lifecycle();
757         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
758         {
759             String name = parser.getAttributeName( i );
760             String value = parser.getAttributeValue( i );
761 
762             if ( name.indexOf( ':' ) >= 0 )
763             {
764                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
765             }
766             else
767             {
768                 checkUnknownAttribute( parser, name, tagName, strict );
769             }
770         }
771         java.util.Set<String> parsed = new java.util.HashSet<String>();
772         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
773         {
774             if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
775             {
776                 lifecycle.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
777             }
778             else if ( checkFieldWithDuplicate( parser, "phases", null, parsed ) )
779             {
780                 java.util.List<Phase> phases = new java.util.ArrayList<Phase>();
781                 while ( parser.nextTag() == XmlPullParser.START_TAG )
782                 {
783                     if ( "phase".equals( parser.getName() ) )
784                     {
785                         phases.add( parsePhase( parser, strict ) );
786                     }
787                     else
788                     {
789                         checkUnknownElement( parser, strict );
790                     }
791                 }
792                 lifecycle.setPhases( phases );
793             }
794             else
795             {
796                 checkUnknownElement( parser, strict );
797             }
798         }
799         return lifecycle;
800     } //-- Lifecycle parseLifecycle( XmlPullParser, boolean )
801 
802     /**
803      * Method parseLifecycleConfiguration.
804      * 
805      * @param parser a parser object.
806      * @param strict a strict object.
807      * @throws IOException IOException if any.
808      * @throws XmlPullParserException XmlPullParserException if
809      * any.
810      * @return LifecycleConfiguration
811      */
812     private LifecycleConfiguration parseLifecycleConfiguration( XmlPullParser parser, boolean strict )
813         throws IOException, XmlPullParserException
814     {
815         String tagName = parser.getName();
816         LifecycleConfiguration lifecycleConfiguration = new LifecycleConfiguration();
817         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
818         {
819             String name = parser.getAttributeName( i );
820             String value = parser.getAttributeValue( i );
821 
822             if ( name.indexOf( ':' ) >= 0 )
823             {
824                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
825             }
826             else if ( "xmlns".equals( name ) )
827             {
828                 // ignore xmlns attribute in root class, which is a reserved attribute name
829             }
830             else
831             {
832                 checkUnknownAttribute( parser, name, tagName, strict );
833             }
834         }
835         java.util.Set<String> parsed = new java.util.HashSet<String>();
836         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
837         {
838             if ( "lifecycle".equals( parser.getName() ) )
839             {
840                 java.util.List<Lifecycle> lifecycles = lifecycleConfiguration.getLifecycles();
841                 if ( lifecycles == null )
842                 {
843                     lifecycles = new java.util.ArrayList<Lifecycle>();
844                 }
845                 lifecycles.add( parseLifecycle( parser, strict ) );
846                 lifecycleConfiguration.setLifecycles( lifecycles );
847             }
848             else
849             {
850                 checkUnknownElement( parser, strict );
851             }
852         }
853         return lifecycleConfiguration;
854     } //-- LifecycleConfiguration parseLifecycleConfiguration( XmlPullParser, boolean )
855 
856     /**
857      * Method parsePhase.
858      * 
859      * @param parser a parser object.
860      * @param strict a strict object.
861      * @throws IOException IOException if any.
862      * @throws XmlPullParserException XmlPullParserException if
863      * any.
864      * @return Phase
865      */
866     private Phase parsePhase( XmlPullParser parser, boolean strict )
867         throws IOException, XmlPullParserException
868     {
869         String tagName = parser.getName();
870         Phase phase = new Phase();
871         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
872         {
873             String name = parser.getAttributeName( i );
874             String value = parser.getAttributeValue( i );
875 
876             if ( name.indexOf( ':' ) >= 0 )
877             {
878                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
879             }
880             else
881             {
882                 checkUnknownAttribute( parser, name, tagName, strict );
883             }
884         }
885         java.util.Set<String> parsed = new java.util.HashSet<String>();
886         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
887         {
888             if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
889             {
890                 phase.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
891             }
892             else if ( checkFieldWithDuplicate( parser, "executions", null, parsed ) )
893             {
894                 java.util.List<Execution> executions = new java.util.ArrayList<Execution>();
895                 while ( parser.nextTag() == XmlPullParser.START_TAG )
896                 {
897                     if ( "execution".equals( parser.getName() ) )
898                     {
899                         executions.add( parseExecution( parser, strict ) );
900                     }
901                     else
902                     {
903                         checkUnknownElement( parser, strict );
904                     }
905                 }
906                 phase.setExecutions( executions );
907             }
908             else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
909             {
910                 phase.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
911             }
912             else
913             {
914                 checkUnknownElement( parser, strict );
915             }
916         }
917         return phase;
918     } //-- Phase parsePhase( XmlPullParser, boolean )
919 
920     /**
921      * Sets the state of the "add default entities" flag.
922      * 
923      * @param addDefaultEntities a addDefaultEntities object.
924      */
925     public void setAddDefaultEntities( boolean addDefaultEntities )
926     {
927         this.addDefaultEntities = addDefaultEntities;
928     } //-- void setAddDefaultEntities( boolean )
929 
930     public static interface ContentTransformer
931 {
932     /**
933      * Interpolate the value read from the xpp3 document
934      * @param source The source value
935      * @param fieldName A description of the field being interpolated. The implementation may use this to
936      *                           log stuff.
937      * @return The interpolated value.
938      */
939     String transform( String source, String fieldName );
940 }
941 
942 }