View Javadoc

1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.8.1,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.plugin.descriptor.model.io.xpp3;
7   
8     //---------------------------------/
9    //- Imported classes and packages -/
10  //---------------------------------/
11  
12  import java.io.IOException;
13  import java.io.InputStream;
14  import java.io.Reader;
15  import java.text.DateFormat;
16  import org.apache.maven.plugin.descriptor.model.Configuration;
17  import org.apache.maven.plugin.descriptor.model.Dependency;
18  import org.apache.maven.plugin.descriptor.model.MojoDescriptor;
19  import org.apache.maven.plugin.descriptor.model.Parameter;
20  import org.apache.maven.plugin.descriptor.model.PluginDescriptor;
21  import org.apache.maven.plugin.descriptor.model.Requirement;
22  import org.codehaus.plexus.util.ReaderFactory;
23  import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
24  import org.codehaus.plexus.util.xml.pull.MXParser;
25  import org.codehaus.plexus.util.xml.pull.XmlPullParser;
26  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
27  
28  /**
29   * Class PluginDescriptorXpp3Reader.
30   * 
31   * @version $Revision: 877610 $ $Date: 2013-09-07 15:25:53 +0000 (Sat, 07 Sep 2013) $
32   */
33  @SuppressWarnings( "all" )
34  public class PluginDescriptorXpp3Reader
35  {
36  
37        //--------------------------/
38       //- Class/Member Variables -/
39      //--------------------------/
40  
41      /**
42       * If set the parser will be loaded with all single characters
43       * from the XHTML specification.
44       * The entities used:
45       * <ul>
46       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
47       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
48       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
49       * </ul>
50       */
51      private boolean addDefaultEntities = true;
52  
53  
54        //-----------/
55       //- Methods -/
56      //-----------/
57  
58      /**
59       * Method checkFieldWithDuplicate.
60       * 
61       * @param parser
62       * @param parsed
63       * @param alias
64       * @param tagName
65       * @throws XmlPullParserException
66       * @return boolean
67       */
68      private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed )
69          throws XmlPullParserException
70      {
71          if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
72          {
73              return false;
74          }
75          if ( !parsed.add( tagName ) )
76          {
77              throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
78          }
79          return true;
80      } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set )
81  
82      /**
83       * Method checkUnknownAttribute.
84       * 
85       * @param parser
86       * @param strict
87       * @param tagName
88       * @param attribute
89       * @throws XmlPullParserException
90       * @throws IOException
91       */
92      private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
93          throws XmlPullParserException, IOException
94      {
95          // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
96          if ( strict )
97          {
98              throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
99          }
100     } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean )
101 
102     /**
103      * Method checkUnknownElement.
104      * 
105      * @param parser
106      * @param strict
107      * @throws XmlPullParserException
108      * @throws IOException
109      */
110     private void checkUnknownElement( XmlPullParser parser, boolean strict )
111         throws XmlPullParserException, IOException
112     {
113         if ( strict )
114         {
115             throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
116         }
117 
118         for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
119         {
120             int eventType = parser.next();
121             if ( eventType == XmlPullParser.START_TAG )
122             {
123                 unrecognizedTagCount++;
124             }
125             else if ( eventType == XmlPullParser.END_TAG )
126             {
127                 unrecognizedTagCount--;
128             }
129         }
130     } //-- void checkUnknownElement( XmlPullParser, boolean )
131 
132     /**
133      * Returns the state of the "add default entities" flag.
134      * 
135      * @return boolean
136      */
137     public boolean getAddDefaultEntities()
138     {
139         return addDefaultEntities;
140     } //-- boolean getAddDefaultEntities()
141 
142     /**
143      * Method getBooleanValue.
144      * 
145      * @param s
146      * @param parser
147      * @param attribute
148      * @throws XmlPullParserException
149      * @return boolean
150      */
151     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
152         throws XmlPullParserException
153     {
154         return getBooleanValue( s, attribute, parser, null );
155     } //-- boolean getBooleanValue( String, String, XmlPullParser )
156 
157     /**
158      * Method getBooleanValue.
159      * 
160      * @param s
161      * @param defaultValue
162      * @param parser
163      * @param attribute
164      * @throws XmlPullParserException
165      * @return boolean
166      */
167     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
168         throws XmlPullParserException
169     {
170         if ( s != null && s.length() != 0 )
171         {
172             return Boolean.valueOf( s ).booleanValue();
173         }
174         if ( defaultValue != null )
175         {
176             return Boolean.valueOf( defaultValue ).booleanValue();
177         }
178         return false;
179     } //-- boolean getBooleanValue( String, String, XmlPullParser, String )
180 
181     /**
182      * Method getByteValue.
183      * 
184      * @param s
185      * @param strict
186      * @param parser
187      * @param attribute
188      * @throws XmlPullParserException
189      * @return byte
190      */
191     private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
192         throws XmlPullParserException
193     {
194         if ( s != null )
195         {
196             try
197             {
198                 return Byte.valueOf( s ).byteValue();
199             }
200             catch ( NumberFormatException nfe )
201             {
202                 if ( strict )
203                 {
204                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
205                 }
206             }
207         }
208         return 0;
209     } //-- byte getByteValue( String, String, XmlPullParser, boolean )
210 
211     /**
212      * Method getCharacterValue.
213      * 
214      * @param s
215      * @param parser
216      * @param attribute
217      * @throws XmlPullParserException
218      * @return char
219      */
220     private char getCharacterValue( String s, String attribute, XmlPullParser parser )
221         throws XmlPullParserException
222     {
223         if ( s != null )
224         {
225             return s.charAt( 0 );
226         }
227         return 0;
228     } //-- char getCharacterValue( String, String, XmlPullParser )
229 
230     /**
231      * Method getDateValue.
232      * 
233      * @param s
234      * @param parser
235      * @param attribute
236      * @throws XmlPullParserException
237      * @return Date
238      */
239     private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
240         throws XmlPullParserException
241     {
242         return getDateValue( s, attribute, null, parser );
243     } //-- java.util.Date getDateValue( String, String, XmlPullParser )
244 
245     /**
246      * Method getDateValue.
247      * 
248      * @param s
249      * @param parser
250      * @param dateFormat
251      * @param attribute
252      * @throws XmlPullParserException
253      * @return Date
254      */
255     private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
256         throws XmlPullParserException
257     {
258         if ( s != null )
259         {
260             String effectiveDateFormat = dateFormat;
261             if ( dateFormat == null )
262             {
263                 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
264             }
265             if ( "long".equals( effectiveDateFormat ) )
266             {
267                 try
268                 {
269                     return new java.util.Date( Long.parseLong( s ) );
270                 }
271                 catch ( NumberFormatException e )
272                 {
273                     throw new XmlPullParserException( e.getMessage(), parser, e );
274                 }
275             }
276             else
277             {
278                 try
279                 {
280                     DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
281                     return dateParser.parse( s );
282                 }
283                 catch ( java.text.ParseException e )
284                 {
285                     throw new XmlPullParserException( e.getMessage(), parser, e );
286                 }
287             }
288         }
289         return null;
290     } //-- java.util.Date getDateValue( String, String, String, XmlPullParser )
291 
292     /**
293      * Method getDoubleValue.
294      * 
295      * @param s
296      * @param strict
297      * @param parser
298      * @param attribute
299      * @throws XmlPullParserException
300      * @return double
301      */
302     private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
303         throws XmlPullParserException
304     {
305         if ( s != null )
306         {
307             try
308             {
309                 return Double.valueOf( s ).doubleValue();
310             }
311             catch ( NumberFormatException nfe )
312             {
313                 if ( strict )
314                 {
315                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
316                 }
317             }
318         }
319         return 0;
320     } //-- double getDoubleValue( String, String, XmlPullParser, boolean )
321 
322     /**
323      * Method getFloatValue.
324      * 
325      * @param s
326      * @param strict
327      * @param parser
328      * @param attribute
329      * @throws XmlPullParserException
330      * @return float
331      */
332     private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
333         throws XmlPullParserException
334     {
335         if ( s != null )
336         {
337             try
338             {
339                 return Float.valueOf( s ).floatValue();
340             }
341             catch ( NumberFormatException nfe )
342             {
343                 if ( strict )
344                 {
345                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
346                 }
347             }
348         }
349         return 0;
350     } //-- float getFloatValue( String, String, XmlPullParser, boolean )
351 
352     /**
353      * Method getIntegerValue.
354      * 
355      * @param s
356      * @param strict
357      * @param parser
358      * @param attribute
359      * @throws XmlPullParserException
360      * @return int
361      */
362     private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
363         throws XmlPullParserException
364     {
365         if ( s != null )
366         {
367             try
368             {
369                 return Integer.valueOf( s ).intValue();
370             }
371             catch ( NumberFormatException nfe )
372             {
373                 if ( strict )
374                 {
375                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
376                 }
377             }
378         }
379         return 0;
380     } //-- int getIntegerValue( String, String, XmlPullParser, boolean )
381 
382     /**
383      * Method getLongValue.
384      * 
385      * @param s
386      * @param strict
387      * @param parser
388      * @param attribute
389      * @throws XmlPullParserException
390      * @return long
391      */
392     private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
393         throws XmlPullParserException
394     {
395         if ( s != null )
396         {
397             try
398             {
399                 return Long.valueOf( s ).longValue();
400             }
401             catch ( NumberFormatException nfe )
402             {
403                 if ( strict )
404                 {
405                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
406                 }
407             }
408         }
409         return 0;
410     } //-- long getLongValue( String, String, XmlPullParser, boolean )
411 
412     /**
413      * Method getRequiredAttributeValue.
414      * 
415      * @param s
416      * @param strict
417      * @param parser
418      * @param attribute
419      * @throws XmlPullParserException
420      * @return String
421      */
422     private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
423         throws XmlPullParserException
424     {
425         if ( s == null )
426         {
427             if ( strict )
428             {
429                 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
430             }
431         }
432         return s;
433     } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean )
434 
435     /**
436      * Method getShortValue.
437      * 
438      * @param s
439      * @param strict
440      * @param parser
441      * @param attribute
442      * @throws XmlPullParserException
443      * @return short
444      */
445     private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
446         throws XmlPullParserException
447     {
448         if ( s != null )
449         {
450             try
451             {
452                 return Short.valueOf( s ).shortValue();
453             }
454             catch ( NumberFormatException nfe )
455             {
456                 if ( strict )
457                 {
458                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
459                 }
460             }
461         }
462         return 0;
463     } //-- short getShortValue( String, String, XmlPullParser, boolean )
464 
465     /**
466      * Method getTrimmedValue.
467      * 
468      * @param s
469      * @return String
470      */
471     private String getTrimmedValue( String s )
472     {
473         if ( s != null )
474         {
475             s = s.trim();
476         }
477         return s;
478     } //-- String getTrimmedValue( String )
479 
480     /**
481      * Method nextTag.
482      * 
483      * @param parser
484      * @throws IOException
485      * @throws XmlPullParserException
486      * @return int
487      */
488     private int nextTag( XmlPullParser parser )
489         throws IOException, XmlPullParserException
490     {
491         int eventType = parser.next();
492         if ( eventType == XmlPullParser.TEXT )
493         {
494             eventType = parser.next();
495         }
496         if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
497         {
498             throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
499         }
500         return eventType;
501     } //-- int nextTag( XmlPullParser )
502 
503     /**
504      * @see ReaderFactory#newXmlReader
505      * 
506      * @param reader
507      * @param strict
508      * @throws IOException
509      * @throws XmlPullParserException
510      * @return PluginDescriptor
511      */
512     public PluginDescriptor read( Reader reader, boolean strict )
513         throws IOException, XmlPullParserException
514     {
515         XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
516 
517         parser.setInput( reader );
518 
519 
520         return read( parser, strict );
521     } //-- PluginDescriptor read( Reader, boolean )
522 
523     /**
524      * @see ReaderFactory#newXmlReader
525      * 
526      * @param reader
527      * @throws IOException
528      * @throws XmlPullParserException
529      * @return PluginDescriptor
530      */
531     public PluginDescriptor read( Reader reader )
532         throws IOException, XmlPullParserException
533     {
534         return read( reader, true );
535     } //-- PluginDescriptor read( Reader )
536 
537     /**
538      * Method read.
539      * 
540      * @param in
541      * @param strict
542      * @throws IOException
543      * @throws XmlPullParserException
544      * @return PluginDescriptor
545      */
546     public PluginDescriptor read( InputStream in, boolean strict )
547         throws IOException, XmlPullParserException
548     {
549         return read( ReaderFactory.newXmlReader( in ), strict );
550     } //-- PluginDescriptor read( InputStream, boolean )
551 
552     /**
553      * Method read.
554      * 
555      * @param in
556      * @throws IOException
557      * @throws XmlPullParserException
558      * @return PluginDescriptor
559      */
560     public PluginDescriptor read( InputStream in )
561         throws IOException, XmlPullParserException
562     {
563         return read( ReaderFactory.newXmlReader( in ) );
564     } //-- PluginDescriptor read( InputStream )
565 
566     /**
567      * Method parseConfiguration.
568      * 
569      * @param parser
570      * @param strict
571      * @throws IOException
572      * @throws XmlPullParserException
573      * @return Configuration
574      */
575     private Configuration parseConfiguration( XmlPullParser parser, boolean strict )
576         throws IOException, XmlPullParserException
577     {
578         String tagName = parser.getName();
579         Configuration configuration = new Configuration();
580         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
581         {
582             String name = parser.getAttributeName( i );
583             String value = parser.getAttributeValue( i );
584 
585             if ( name.indexOf( ':' ) >= 0 )
586             {
587                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
588             }
589             else if ( "implementation".equals( name ) )
590             {
591                 configuration.setImplementation( getTrimmedValue( value ) );
592             }
593             else if ( "default-value".equals( name ) )
594             {
595                 configuration.setDefaultValue( getTrimmedValue( value ) );
596             }
597             else
598             {
599                 checkUnknownAttribute( parser, name, tagName, strict );
600             }
601         }
602         configuration.setExpression( getTrimmedValue( parser.nextText() ) );
603         return configuration;
604     } //-- Configuration parseConfiguration( XmlPullParser, boolean )
605 
606     /**
607      * Method parseDependency.
608      * 
609      * @param parser
610      * @param strict
611      * @throws IOException
612      * @throws XmlPullParserException
613      * @return Dependency
614      */
615     private Dependency parseDependency( XmlPullParser parser, boolean strict )
616         throws IOException, XmlPullParserException
617     {
618         String tagName = parser.getName();
619         Dependency dependency = new Dependency();
620         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
621         {
622             String name = parser.getAttributeName( i );
623             String value = parser.getAttributeValue( i );
624 
625             if ( name.indexOf( ':' ) >= 0 )
626             {
627                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
628             }
629             else
630             {
631                 checkUnknownAttribute( parser, name, tagName, strict );
632             }
633         }
634         java.util.Set parsed = new java.util.HashSet();
635         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
636         {
637             if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
638             {
639                 dependency.setGroupId( getTrimmedValue( parser.nextText() ) );
640             }
641             else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
642             {
643                 dependency.setArtifactId( getTrimmedValue( parser.nextText() ) );
644             }
645             else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
646             {
647                 dependency.setVersion( getTrimmedValue( parser.nextText() ) );
648             }
649             else if ( checkFieldWithDuplicate( parser, "type", null, parsed ) )
650             {
651                 dependency.setType( getTrimmedValue( parser.nextText() ) );
652             }
653             else
654             {
655                 checkUnknownElement( parser, strict );
656             }
657         }
658         return dependency;
659     } //-- Dependency parseDependency( XmlPullParser, boolean )
660 
661     /**
662      * Method parseMojoDescriptor.
663      * 
664      * @param parser
665      * @param strict
666      * @throws IOException
667      * @throws XmlPullParserException
668      * @return MojoDescriptor
669      */
670     private MojoDescriptor parseMojoDescriptor( XmlPullParser parser, boolean strict )
671         throws IOException, XmlPullParserException
672     {
673         String tagName = parser.getName();
674         MojoDescriptor mojoDescriptor = new MojoDescriptor();
675         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
676         {
677             String name = parser.getAttributeName( i );
678             String value = parser.getAttributeValue( i );
679 
680             if ( name.indexOf( ':' ) >= 0 )
681             {
682                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
683             }
684             else
685             {
686                 checkUnknownAttribute( parser, name, tagName, strict );
687             }
688         }
689         java.util.Set parsed = new java.util.HashSet();
690         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
691         {
692             if ( checkFieldWithDuplicate( parser, "goal", null, parsed ) )
693             {
694                 mojoDescriptor.setGoal( getTrimmedValue( parser.nextText() ) );
695             }
696             else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
697             {
698                 mojoDescriptor.setDescription( getTrimmedValue( parser.nextText() ) );
699             }
700             else if ( checkFieldWithDuplicate( parser, "implementation", null, parsed ) )
701             {
702                 mojoDescriptor.setImplementation( getTrimmedValue( parser.nextText() ) );
703             }
704             else if ( checkFieldWithDuplicate( parser, "language", null, parsed ) )
705             {
706                 mojoDescriptor.setLanguage( getTrimmedValue( parser.nextText() ) );
707             }
708             else if ( checkFieldWithDuplicate( parser, "phase", null, parsed ) )
709             {
710                 mojoDescriptor.setPhase( getTrimmedValue( parser.nextText() ) );
711             }
712             else if ( checkFieldWithDuplicate( parser, "executePhase", null, parsed ) )
713             {
714                 mojoDescriptor.setExecutePhase( getTrimmedValue( parser.nextText() ) );
715             }
716             else if ( checkFieldWithDuplicate( parser, "executeGoal", null, parsed ) )
717             {
718                 mojoDescriptor.setExecuteGoal( getTrimmedValue( parser.nextText() ) );
719             }
720             else if ( checkFieldWithDuplicate( parser, "executeLifecycle", null, parsed ) )
721             {
722                 mojoDescriptor.setExecuteLifecycle( getTrimmedValue( parser.nextText() ) );
723             }
724             else if ( checkFieldWithDuplicate( parser, "requiresDependencyResolution", null, parsed ) )
725             {
726                 mojoDescriptor.setRequiresDependencyResolution( getTrimmedValue( parser.nextText() ) );
727             }
728             else if ( checkFieldWithDuplicate( parser, "requiresDependencyCollection", null, parsed ) )
729             {
730                 mojoDescriptor.setRequiresDependencyCollection( getTrimmedValue( parser.nextText() ) );
731             }
732             else if ( checkFieldWithDuplicate( parser, "requiresDirectInvocation", null, parsed ) )
733             {
734                 mojoDescriptor.setRequiresDirectInvocation( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresDirectInvocation", parser, "false" ) );
735             }
736             else if ( checkFieldWithDuplicate( parser, "requiresProject", null, parsed ) )
737             {
738                 mojoDescriptor.setRequiresProject( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresProject", parser, "true" ) );
739             }
740             else if ( checkFieldWithDuplicate( parser, "requiresReports", null, parsed ) )
741             {
742                 mojoDescriptor.setRequiresReports( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresReports", parser, "false" ) );
743             }
744             else if ( checkFieldWithDuplicate( parser, "requiresOnline", null, parsed ) )
745             {
746                 mojoDescriptor.setRequiresOnline( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresOnline", parser, "false" ) );
747             }
748             else if ( checkFieldWithDuplicate( parser, "aggregator", null, parsed ) )
749             {
750                 mojoDescriptor.setAggregator( getBooleanValue( getTrimmedValue( parser.nextText() ), "aggregator", parser, "false" ) );
751             }
752             else if ( checkFieldWithDuplicate( parser, "inheritedByDefault", null, parsed ) )
753             {
754                 mojoDescriptor.setInheritedByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "inheritedByDefault", parser, "true" ) );
755             }
756             else if ( checkFieldWithDuplicate( parser, "threadSafe", null, parsed ) )
757             {
758                 mojoDescriptor.setThreadSafe( getBooleanValue( getTrimmedValue( parser.nextText() ), "threadSafe", parser, "false" ) );
759             }
760             else if ( checkFieldWithDuplicate( parser, "instantiationStrategy", null, parsed ) )
761             {
762                 mojoDescriptor.setInstantiationStrategy( getTrimmedValue( parser.nextText() ) );
763             }
764             else if ( checkFieldWithDuplicate( parser, "executionStrategy", null, parsed ) )
765             {
766                 mojoDescriptor.setExecutionStrategy( getTrimmedValue( parser.nextText() ) );
767             }
768             else if ( checkFieldWithDuplicate( parser, "since", null, parsed ) )
769             {
770                 mojoDescriptor.setSince( getTrimmedValue( parser.nextText() ) );
771             }
772             else if ( checkFieldWithDuplicate( parser, "deprecated", null, parsed ) )
773             {
774                 mojoDescriptor.setDeprecated( getTrimmedValue( parser.nextText() ) );
775             }
776             else if ( checkFieldWithDuplicate( parser, "configurator", null, parsed ) )
777             {
778                 mojoDescriptor.setConfigurator( getTrimmedValue( parser.nextText() ) );
779             }
780             else if ( checkFieldWithDuplicate( parser, "composer", null, parsed ) )
781             {
782                 mojoDescriptor.setComposer( getTrimmedValue( parser.nextText() ) );
783             }
784             else if ( checkFieldWithDuplicate( parser, "parameters", null, parsed ) )
785             {
786                 java.util.List parameters = new java.util.ArrayList/*<Parameter>*/();
787                 mojoDescriptor.setParameters( parameters );
788                 while ( parser.nextTag() == XmlPullParser.START_TAG )
789                 {
790                     if ( "parameter".equals( parser.getName() ) )
791                     {
792                         parameters.add( parseParameter( parser, strict ) );
793                     }
794                     else
795                     {
796                         checkUnknownElement( parser, strict );
797                     }
798                 }
799             }
800             else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
801             {
802                 java.util.List configuration = new java.util.ArrayList/*<Configuration>*/();
803                 mojoDescriptor.setConfiguration( configuration );
804                 while ( parser.nextTag() == XmlPullParser.START_TAG )
805                 {
806                     if ( "paramName".equals( parser.getName() ) )
807                     {
808                         configuration.add( parseConfiguration( parser, strict ) );
809                     }
810                     else
811                     {
812                         checkUnknownElement( parser, strict );
813                     }
814                 }
815             }
816             else if ( checkFieldWithDuplicate( parser, "requirements", null, parsed ) )
817             {
818                 java.util.List requirements = new java.util.ArrayList/*<Requirement>*/();
819                 mojoDescriptor.setRequirements( requirements );
820                 while ( parser.nextTag() == XmlPullParser.START_TAG )
821                 {
822                     if ( "requirement".equals( parser.getName() ) )
823                     {
824                         requirements.add( parseRequirement( parser, strict ) );
825                     }
826                     else
827                     {
828                         checkUnknownElement( parser, strict );
829                     }
830                 }
831             }
832             else
833             {
834                 checkUnknownElement( parser, strict );
835             }
836         }
837         return mojoDescriptor;
838     } //-- MojoDescriptor parseMojoDescriptor( XmlPullParser, boolean )
839 
840     /**
841      * Method parseParameter.
842      * 
843      * @param parser
844      * @param strict
845      * @throws IOException
846      * @throws XmlPullParserException
847      * @return Parameter
848      */
849     private Parameter parseParameter( XmlPullParser parser, boolean strict )
850         throws IOException, XmlPullParserException
851     {
852         String tagName = parser.getName();
853         Parameter parameter = new Parameter();
854         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
855         {
856             String name = parser.getAttributeName( i );
857             String value = parser.getAttributeValue( i );
858 
859             if ( name.indexOf( ':' ) >= 0 )
860             {
861                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
862             }
863             else
864             {
865                 checkUnknownAttribute( parser, name, tagName, strict );
866             }
867         }
868         java.util.Set parsed = new java.util.HashSet();
869         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
870         {
871             if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
872             {
873                 parameter.setName( getTrimmedValue( parser.nextText() ) );
874             }
875             else if ( checkFieldWithDuplicate( parser, "alias", null, parsed ) )
876             {
877                 parameter.setAlias( getTrimmedValue( parser.nextText() ) );
878             }
879             else if ( checkFieldWithDuplicate( parser, "type", null, parsed ) )
880             {
881                 parameter.setType( getTrimmedValue( parser.nextText() ) );
882             }
883             else if ( checkFieldWithDuplicate( parser, "required", null, parsed ) )
884             {
885                 parameter.setRequired( getBooleanValue( getTrimmedValue( parser.nextText() ), "required", parser, "false" ) );
886             }
887             else if ( checkFieldWithDuplicate( parser, "editable", null, parsed ) )
888             {
889                 parameter.setEditable( getBooleanValue( getTrimmedValue( parser.nextText() ), "editable", parser, "true" ) );
890             }
891             else if ( checkFieldWithDuplicate( parser, "implementation", null, parsed ) )
892             {
893                 parameter.setImplementation( getTrimmedValue( parser.nextText() ) );
894             }
895             else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
896             {
897                 parameter.setDescription( getTrimmedValue( parser.nextText() ) );
898             }
899             else if ( checkFieldWithDuplicate( parser, "since", null, parsed ) )
900             {
901                 parameter.setSince( getTrimmedValue( parser.nextText() ) );
902             }
903             else if ( checkFieldWithDuplicate( parser, "deprecated", null, parsed ) )
904             {
905                 parameter.setDeprecated( getTrimmedValue( parser.nextText() ) );
906             }
907             else
908             {
909                 checkUnknownElement( parser, strict );
910             }
911         }
912         return parameter;
913     } //-- Parameter parseParameter( XmlPullParser, boolean )
914 
915     /**
916      * Method parsePluginDescriptor.
917      * 
918      * @param parser
919      * @param strict
920      * @throws IOException
921      * @throws XmlPullParserException
922      * @return PluginDescriptor
923      */
924     private PluginDescriptor parsePluginDescriptor( XmlPullParser parser, boolean strict )
925         throws IOException, XmlPullParserException
926     {
927         String tagName = parser.getName();
928         PluginDescriptor pluginDescriptor = new PluginDescriptor();
929         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
930         {
931             String name = parser.getAttributeName( i );
932             String value = parser.getAttributeValue( i );
933 
934             if ( name.indexOf( ':' ) >= 0 )
935             {
936                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
937             }
938             else if ( "xmlns".equals( name ) )
939             {
940                 // ignore xmlns attribute in root class, which is a reserved attribute name
941             }
942             else
943             {
944                 checkUnknownAttribute( parser, name, tagName, strict );
945             }
946         }
947         java.util.Set parsed = new java.util.HashSet();
948         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
949         {
950             if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
951             {
952                 pluginDescriptor.setDescription( getTrimmedValue( parser.nextText() ) );
953             }
954             else if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
955             {
956                 pluginDescriptor.setGroupId( getTrimmedValue( parser.nextText() ) );
957             }
958             else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
959             {
960                 pluginDescriptor.setArtifactId( getTrimmedValue( parser.nextText() ) );
961             }
962             else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
963             {
964                 pluginDescriptor.setVersion( getTrimmedValue( parser.nextText() ) );
965             }
966             else if ( checkFieldWithDuplicate( parser, "goalPrefix", null, parsed ) )
967             {
968                 pluginDescriptor.setGoalPrefix( getTrimmedValue( parser.nextText() ) );
969             }
970             else if ( checkFieldWithDuplicate( parser, "isolatedRealm", null, parsed ) )
971             {
972                 pluginDescriptor.setIsolatedRealm( getBooleanValue( getTrimmedValue( parser.nextText() ), "isolatedRealm", parser, "false" ) );
973             }
974             else if ( checkFieldWithDuplicate( parser, "inheritedByDefault", null, parsed ) )
975             {
976                 pluginDescriptor.setInheritedByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "inheritedByDefault", parser, "true" ) );
977             }
978             else if ( checkFieldWithDuplicate( parser, "mojos", null, parsed ) )
979             {
980                 java.util.List mojos = new java.util.ArrayList/*<MojoDescriptor>*/();
981                 pluginDescriptor.setMojos( mojos );
982                 while ( parser.nextTag() == XmlPullParser.START_TAG )
983                 {
984                     if ( "mojo".equals( parser.getName() ) )
985                     {
986                         mojos.add( parseMojoDescriptor( parser, strict ) );
987                     }
988                     else
989                     {
990                         checkUnknownElement( parser, strict );
991                     }
992                 }
993             }
994             else if ( checkFieldWithDuplicate( parser, "dependencies", null, parsed ) )
995             {
996                 java.util.List dependencies = new java.util.ArrayList/*<Dependency>*/();
997                 pluginDescriptor.setDependencies( dependencies );
998                 while ( parser.nextTag() == XmlPullParser.START_TAG )
999                 {
1000                     if ( "dependency".equals( parser.getName() ) )
1001                     {
1002                         dependencies.add( parseDependency( parser, strict ) );
1003                     }
1004                     else
1005                     {
1006                         checkUnknownElement( parser, strict );
1007                     }
1008                 }
1009             }
1010             else
1011             {
1012                 checkUnknownElement( parser, strict );
1013             }
1014         }
1015         return pluginDescriptor;
1016     } //-- PluginDescriptor parsePluginDescriptor( XmlPullParser, boolean )
1017 
1018     /**
1019      * Method parseRequirement.
1020      * 
1021      * @param parser
1022      * @param strict
1023      * @throws IOException
1024      * @throws XmlPullParserException
1025      * @return Requirement
1026      */
1027     private Requirement parseRequirement( XmlPullParser parser, boolean strict )
1028         throws IOException, XmlPullParserException
1029     {
1030         String tagName = parser.getName();
1031         Requirement requirement = new Requirement();
1032         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1033         {
1034             String name = parser.getAttributeName( i );
1035             String value = parser.getAttributeValue( i );
1036 
1037             if ( name.indexOf( ':' ) >= 0 )
1038             {
1039                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1040             }
1041             else
1042             {
1043                 checkUnknownAttribute( parser, name, tagName, strict );
1044             }
1045         }
1046         java.util.Set parsed = new java.util.HashSet();
1047         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1048         {
1049             if ( checkFieldWithDuplicate( parser, "role", null, parsed ) )
1050             {
1051                 requirement.setRole( getTrimmedValue( parser.nextText() ) );
1052             }
1053             else if ( checkFieldWithDuplicate( parser, "role-hint", null, parsed ) )
1054             {
1055                 requirement.setRoleHint( getTrimmedValue( parser.nextText() ) );
1056             }
1057             else if ( checkFieldWithDuplicate( parser, "field-name", null, parsed ) )
1058             {
1059                 requirement.setFieldName( getTrimmedValue( parser.nextText() ) );
1060             }
1061             else
1062             {
1063                 checkUnknownElement( parser, strict );
1064             }
1065         }
1066         return requirement;
1067     } //-- Requirement parseRequirement( XmlPullParser, boolean )
1068 
1069     /**
1070      * Method read.
1071      * 
1072      * @param parser
1073      * @param strict
1074      * @throws IOException
1075      * @throws XmlPullParserException
1076      * @return PluginDescriptor
1077      */
1078     private PluginDescriptor read( XmlPullParser parser, boolean strict )
1079         throws IOException, XmlPullParserException
1080     {
1081         int eventType = parser.getEventType();
1082         while ( eventType != XmlPullParser.END_DOCUMENT )
1083         {
1084             if ( eventType == XmlPullParser.START_TAG )
1085             {
1086                 if ( strict && ! "plugin".equals( parser.getName() ) )
1087                 {
1088                     throw new XmlPullParserException( "Expected root element 'plugin' but found '" + parser.getName() + "'", parser, null );
1089                 }
1090                 PluginDescriptor pluginDescriptor = parsePluginDescriptor( parser, strict );
1091                 pluginDescriptor.setModelEncoding( parser.getInputEncoding() );
1092                 return pluginDescriptor;
1093             }
1094             eventType = parser.next();
1095         }
1096         throw new XmlPullParserException( "Expected root element 'plugin' but found no element at all: invalid XML document", parser, null );
1097     } //-- PluginDescriptor read( XmlPullParser, boolean )
1098 
1099     /**
1100      * Sets the state of the "add default entities" flag.
1101      * 
1102      * @param addDefaultEntities
1103      */
1104     public void setAddDefaultEntities( boolean addDefaultEntities )
1105     {
1106         this.addDefaultEntities = addDefaultEntities;
1107     } //-- void setAddDefaultEntities( boolean )
1108 
1109 }