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