View Javadoc

1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.7,
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.MXParser;
24  import org.codehaus.plexus.util.xml.pull.XmlPullParser;
25  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
26  
27  /**
28   * Class PluginDescriptorXpp3Reader.
29   * 
30   * @version $Revision: 855142 $ $Date: 2013-03-20 01:55:13 +0100 (Wed, 20 Mar 2013) $
31   */
32  @SuppressWarnings( "all" )
33  public class PluginDescriptorXpp3Reader
34  {
35  
36        //--------------------------/
37       //- Class/Member Variables -/
38      //--------------------------/
39  
40      /**
41       * If set the parser will be loaded with all single characters
42       * from the XHTML specification.
43       * The entities used:
44       * <ul>
45       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
46       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
47       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
48       * </ul>
49       */
50      private boolean addDefaultEntities = true;
51  
52  
53        //-----------/
54       //- Methods -/
55      //-----------/
56  
57      /**
58       * Method checkFieldWithDuplicate.
59       * 
60       * @param parser
61       * @param parsed
62       * @param alias
63       * @param tagName
64       * @throws XmlPullParserException
65       * @return boolean
66       */
67      private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed )
68          throws XmlPullParserException
69      {
70          if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
71          {
72              return false;
73          }
74          if ( !parsed.add( tagName ) )
75          {
76              throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
77          }
78          return true;
79      } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set )
80  
81      /**
82       * Method checkUnknownAttribute.
83       * 
84       * @param parser
85       * @param strict
86       * @param tagName
87       * @param attribute
88       * @throws XmlPullParserException
89       * @throws IOException
90       */
91      private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
92          throws XmlPullParserException, IOException
93      {
94          // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
95          if ( strict )
96          {
97              throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
98          }
99      } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean )
100 
101     /**
102      * Method checkUnknownElement.
103      * 
104      * @param parser
105      * @param strict
106      * @throws XmlPullParserException
107      * @throws IOException
108      */
109     private void checkUnknownElement( XmlPullParser parser, boolean strict )
110         throws XmlPullParserException, IOException
111     {
112         if ( strict )
113         {
114             throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
115         }
116 
117         for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
118         {
119             int eventType = parser.next();
120             if ( eventType == XmlPullParser.START_TAG )
121             {
122                 unrecognizedTagCount++;
123             }
124             else if ( eventType == XmlPullParser.END_TAG )
125             {
126                 unrecognizedTagCount--;
127             }
128         }
129     } //-- void checkUnknownElement( XmlPullParser, boolean )
130 
131     /**
132      * Returns the state of the "add default entities" flag.
133      * 
134      * @return boolean
135      */
136     public boolean getAddDefaultEntities()
137     {
138         return addDefaultEntities;
139     } //-- boolean getAddDefaultEntities()
140 
141     /**
142      * Method getBooleanValue.
143      * 
144      * @param s
145      * @param parser
146      * @param attribute
147      * @throws XmlPullParserException
148      * @return boolean
149      */
150     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
151         throws XmlPullParserException
152     {
153         return getBooleanValue( s, attribute, parser, null );
154     } //-- boolean getBooleanValue( String, String, XmlPullParser )
155 
156     /**
157      * Method getBooleanValue.
158      * 
159      * @param s
160      * @param defaultValue
161      * @param parser
162      * @param attribute
163      * @throws XmlPullParserException
164      * @return boolean
165      */
166     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
167         throws XmlPullParserException
168     {
169         if ( s != null && s.length() != 0 )
170         {
171             return Boolean.valueOf( s ).booleanValue();
172         }
173         if ( defaultValue != null )
174         {
175             return Boolean.valueOf( defaultValue ).booleanValue();
176         }
177         return false;
178     } //-- boolean getBooleanValue( String, String, XmlPullParser, String )
179 
180     /**
181      * Method getByteValue.
182      * 
183      * @param s
184      * @param strict
185      * @param parser
186      * @param attribute
187      * @throws XmlPullParserException
188      * @return byte
189      */
190     private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
191         throws XmlPullParserException
192     {
193         if ( s != null )
194         {
195             try
196             {
197                 return Byte.valueOf( s ).byteValue();
198             }
199             catch ( NumberFormatException nfe )
200             {
201                 if ( strict )
202                 {
203                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
204                 }
205             }
206         }
207         return 0;
208     } //-- byte getByteValue( String, String, XmlPullParser, boolean )
209 
210     /**
211      * Method getCharacterValue.
212      * 
213      * @param s
214      * @param parser
215      * @param attribute
216      * @throws XmlPullParserException
217      * @return char
218      */
219     private char getCharacterValue( String s, String attribute, XmlPullParser parser )
220         throws XmlPullParserException
221     {
222         if ( s != null )
223         {
224             return s.charAt( 0 );
225         }
226         return 0;
227     } //-- char getCharacterValue( String, String, XmlPullParser )
228 
229     /**
230      * Method getDateValue.
231      * 
232      * @param s
233      * @param parser
234      * @param attribute
235      * @throws XmlPullParserException
236      * @return Date
237      */
238     private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
239         throws XmlPullParserException
240     {
241         return getDateValue( s, attribute, null, parser );
242     } //-- java.util.Date getDateValue( String, String, XmlPullParser )
243 
244     /**
245      * Method getDateValue.
246      * 
247      * @param s
248      * @param parser
249      * @param dateFormat
250      * @param attribute
251      * @throws XmlPullParserException
252      * @return Date
253      */
254     private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
255         throws XmlPullParserException
256     {
257         if ( s != null )
258         {
259             String effectiveDateFormat = dateFormat;
260             if ( dateFormat == null )
261             {
262                 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
263             }
264             if ( "long".equals( effectiveDateFormat ) )
265             {
266                 try
267                 {
268                     return new java.util.Date( Long.parseLong( s ) );
269                 }
270                 catch ( NumberFormatException e )
271                 {
272                     throw new XmlPullParserException( e.getMessage(), parser, e );
273                 }
274             }
275             else
276             {
277                 try
278                 {
279                     DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
280                     return dateParser.parse( s );
281                 }
282                 catch ( java.text.ParseException e )
283                 {
284                     throw new XmlPullParserException( e.getMessage(), parser, e );
285                 }
286             }
287         }
288         return null;
289     } //-- java.util.Date getDateValue( String, String, String, XmlPullParser )
290 
291     /**
292      * Method getDoubleValue.
293      * 
294      * @param s
295      * @param strict
296      * @param parser
297      * @param attribute
298      * @throws XmlPullParserException
299      * @return double
300      */
301     private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
302         throws XmlPullParserException
303     {
304         if ( s != null )
305         {
306             try
307             {
308                 return Double.valueOf( s ).doubleValue();
309             }
310             catch ( NumberFormatException nfe )
311             {
312                 if ( strict )
313                 {
314                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
315                 }
316             }
317         }
318         return 0;
319     } //-- double getDoubleValue( String, String, XmlPullParser, boolean )
320 
321     /**
322      * Method getFloatValue.
323      * 
324      * @param s
325      * @param strict
326      * @param parser
327      * @param attribute
328      * @throws XmlPullParserException
329      * @return float
330      */
331     private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
332         throws XmlPullParserException
333     {
334         if ( s != null )
335         {
336             try
337             {
338                 return Float.valueOf( s ).floatValue();
339             }
340             catch ( NumberFormatException nfe )
341             {
342                 if ( strict )
343                 {
344                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
345                 }
346             }
347         }
348         return 0;
349     } //-- float getFloatValue( String, String, XmlPullParser, boolean )
350 
351     /**
352      * Method getIntegerValue.
353      * 
354      * @param s
355      * @param strict
356      * @param parser
357      * @param attribute
358      * @throws XmlPullParserException
359      * @return int
360      */
361     private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
362         throws XmlPullParserException
363     {
364         if ( s != null )
365         {
366             try
367             {
368                 return Integer.valueOf( s ).intValue();
369             }
370             catch ( NumberFormatException nfe )
371             {
372                 if ( strict )
373                 {
374                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
375                 }
376             }
377         }
378         return 0;
379     } //-- int getIntegerValue( String, String, XmlPullParser, boolean )
380 
381     /**
382      * Method getLongValue.
383      * 
384      * @param s
385      * @param strict
386      * @param parser
387      * @param attribute
388      * @throws XmlPullParserException
389      * @return long
390      */
391     private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
392         throws XmlPullParserException
393     {
394         if ( s != null )
395         {
396             try
397             {
398                 return Long.valueOf( s ).longValue();
399             }
400             catch ( NumberFormatException nfe )
401             {
402                 if ( strict )
403                 {
404                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
405                 }
406             }
407         }
408         return 0;
409     } //-- long getLongValue( String, String, XmlPullParser, boolean )
410 
411     /**
412      * Method getRequiredAttributeValue.
413      * 
414      * @param s
415      * @param strict
416      * @param parser
417      * @param attribute
418      * @throws XmlPullParserException
419      * @return String
420      */
421     private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
422         throws XmlPullParserException
423     {
424         if ( s == null )
425         {
426             if ( strict )
427             {
428                 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
429             }
430         }
431         return s;
432     } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean )
433 
434     /**
435      * Method getShortValue.
436      * 
437      * @param s
438      * @param strict
439      * @param parser
440      * @param attribute
441      * @throws XmlPullParserException
442      * @return short
443      */
444     private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
445         throws XmlPullParserException
446     {
447         if ( s != null )
448         {
449             try
450             {
451                 return Short.valueOf( s ).shortValue();
452             }
453             catch ( NumberFormatException nfe )
454             {
455                 if ( strict )
456                 {
457                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
458                 }
459             }
460         }
461         return 0;
462     } //-- short getShortValue( String, String, XmlPullParser, boolean )
463 
464     /**
465      * Method getTrimmedValue.
466      * 
467      * @param s
468      * @return String
469      */
470     private String getTrimmedValue( String s )
471     {
472         if ( s != null )
473         {
474             s = s.trim();
475         }
476         return s;
477     } //-- String getTrimmedValue( String )
478 
479     /**
480      * Method initParser.
481      * 
482      * @param parser
483      * @throws XmlPullParserException
484      */
485     private void initParser( XmlPullParser parser )
486         throws XmlPullParserException
487     {
488         if ( addDefaultEntities )
489         {
490             // ----------------------------------------------------------------------
491             // Latin 1 entities
492             // ----------------------------------------------------------------------
493 
494             parser.defineEntityReplacementText( "nbsp", "\u00a0" );
495             parser.defineEntityReplacementText( "iexcl", "\u00a1" );
496             parser.defineEntityReplacementText( "cent", "\u00a2" );
497             parser.defineEntityReplacementText( "pound", "\u00a3" );
498             parser.defineEntityReplacementText( "curren", "\u00a4" );
499             parser.defineEntityReplacementText( "yen", "\u00a5" );
500             parser.defineEntityReplacementText( "brvbar", "\u00a6" );
501             parser.defineEntityReplacementText( "sect", "\u00a7" );
502             parser.defineEntityReplacementText( "uml", "\u00a8" );
503             parser.defineEntityReplacementText( "copy", "\u00a9" );
504             parser.defineEntityReplacementText( "ordf", "\u00aa" );
505             parser.defineEntityReplacementText( "laquo", "\u00ab" );
506             parser.defineEntityReplacementText( "not", "\u00ac" );
507             parser.defineEntityReplacementText( "shy", "\u00ad" );
508             parser.defineEntityReplacementText( "reg", "\u00ae" );
509             parser.defineEntityReplacementText( "macr", "\u00af" );
510             parser.defineEntityReplacementText( "deg", "\u00b0" );
511             parser.defineEntityReplacementText( "plusmn", "\u00b1" );
512             parser.defineEntityReplacementText( "sup2", "\u00b2" );
513             parser.defineEntityReplacementText( "sup3", "\u00b3" );
514             parser.defineEntityReplacementText( "acute", "\u00b4" );
515             parser.defineEntityReplacementText( "micro", "\u00b5" );
516             parser.defineEntityReplacementText( "para", "\u00b6" );
517             parser.defineEntityReplacementText( "middot", "\u00b7" );
518             parser.defineEntityReplacementText( "cedil", "\u00b8" );
519             parser.defineEntityReplacementText( "sup1", "\u00b9" );
520             parser.defineEntityReplacementText( "ordm", "\u00ba" );
521             parser.defineEntityReplacementText( "raquo", "\u00bb" );
522             parser.defineEntityReplacementText( "frac14", "\u00bc" );
523             parser.defineEntityReplacementText( "frac12", "\u00bd" );
524             parser.defineEntityReplacementText( "frac34", "\u00be" );
525             parser.defineEntityReplacementText( "iquest", "\u00bf" );
526             parser.defineEntityReplacementText( "Agrave", "\u00c0" );
527             parser.defineEntityReplacementText( "Aacute", "\u00c1" );
528             parser.defineEntityReplacementText( "Acirc", "\u00c2" );
529             parser.defineEntityReplacementText( "Atilde", "\u00c3" );
530             parser.defineEntityReplacementText( "Auml", "\u00c4" );
531             parser.defineEntityReplacementText( "Aring", "\u00c5" );
532             parser.defineEntityReplacementText( "AElig", "\u00c6" );
533             parser.defineEntityReplacementText( "Ccedil", "\u00c7" );
534             parser.defineEntityReplacementText( "Egrave", "\u00c8" );
535             parser.defineEntityReplacementText( "Eacute", "\u00c9" );
536             parser.defineEntityReplacementText( "Ecirc", "\u00ca" );
537             parser.defineEntityReplacementText( "Euml", "\u00cb" );
538             parser.defineEntityReplacementText( "Igrave", "\u00cc" );
539             parser.defineEntityReplacementText( "Iacute", "\u00cd" );
540             parser.defineEntityReplacementText( "Icirc", "\u00ce" );
541             parser.defineEntityReplacementText( "Iuml", "\u00cf" );
542             parser.defineEntityReplacementText( "ETH", "\u00d0" );
543             parser.defineEntityReplacementText( "Ntilde", "\u00d1" );
544             parser.defineEntityReplacementText( "Ograve", "\u00d2" );
545             parser.defineEntityReplacementText( "Oacute", "\u00d3" );
546             parser.defineEntityReplacementText( "Ocirc", "\u00d4" );
547             parser.defineEntityReplacementText( "Otilde", "\u00d5" );
548             parser.defineEntityReplacementText( "Ouml", "\u00d6" );
549             parser.defineEntityReplacementText( "times", "\u00d7" );
550             parser.defineEntityReplacementText( "Oslash", "\u00d8" );
551             parser.defineEntityReplacementText( "Ugrave", "\u00d9" );
552             parser.defineEntityReplacementText( "Uacute", "\u00da" );
553             parser.defineEntityReplacementText( "Ucirc", "\u00db" );
554             parser.defineEntityReplacementText( "Uuml", "\u00dc" );
555             parser.defineEntityReplacementText( "Yacute", "\u00dd" );
556             parser.defineEntityReplacementText( "THORN", "\u00de" );
557             parser.defineEntityReplacementText( "szlig", "\u00df" );
558             parser.defineEntityReplacementText( "agrave", "\u00e0" );
559             parser.defineEntityReplacementText( "aacute", "\u00e1" );
560             parser.defineEntityReplacementText( "acirc", "\u00e2" );
561             parser.defineEntityReplacementText( "atilde", "\u00e3" );
562             parser.defineEntityReplacementText( "auml", "\u00e4" );
563             parser.defineEntityReplacementText( "aring", "\u00e5" );
564             parser.defineEntityReplacementText( "aelig", "\u00e6" );
565             parser.defineEntityReplacementText( "ccedil", "\u00e7" );
566             parser.defineEntityReplacementText( "egrave", "\u00e8" );
567             parser.defineEntityReplacementText( "eacute", "\u00e9" );
568             parser.defineEntityReplacementText( "ecirc", "\u00ea" );
569             parser.defineEntityReplacementText( "euml", "\u00eb" );
570             parser.defineEntityReplacementText( "igrave", "\u00ec" );
571             parser.defineEntityReplacementText( "iacute", "\u00ed" );
572             parser.defineEntityReplacementText( "icirc", "\u00ee" );
573             parser.defineEntityReplacementText( "iuml", "\u00ef" );
574             parser.defineEntityReplacementText( "eth", "\u00f0" );
575             parser.defineEntityReplacementText( "ntilde", "\u00f1" );
576             parser.defineEntityReplacementText( "ograve", "\u00f2" );
577             parser.defineEntityReplacementText( "oacute", "\u00f3" );
578             parser.defineEntityReplacementText( "ocirc", "\u00f4" );
579             parser.defineEntityReplacementText( "otilde", "\u00f5" );
580             parser.defineEntityReplacementText( "ouml", "\u00f6" );
581             parser.defineEntityReplacementText( "divide", "\u00f7" );
582             parser.defineEntityReplacementText( "oslash", "\u00f8" );
583             parser.defineEntityReplacementText( "ugrave", "\u00f9" );
584             parser.defineEntityReplacementText( "uacute", "\u00fa" );
585             parser.defineEntityReplacementText( "ucirc", "\u00fb" );
586             parser.defineEntityReplacementText( "uuml", "\u00fc" );
587             parser.defineEntityReplacementText( "yacute", "\u00fd" );
588             parser.defineEntityReplacementText( "thorn", "\u00fe" );
589             parser.defineEntityReplacementText( "yuml", "\u00ff" );
590 
591             // ----------------------------------------------------------------------
592             // Special entities
593             // ----------------------------------------------------------------------
594 
595             parser.defineEntityReplacementText( "OElig", "\u0152" );
596             parser.defineEntityReplacementText( "oelig", "\u0153" );
597             parser.defineEntityReplacementText( "Scaron", "\u0160" );
598             parser.defineEntityReplacementText( "scaron", "\u0161" );
599             parser.defineEntityReplacementText( "Yuml", "\u0178" );
600             parser.defineEntityReplacementText( "circ", "\u02c6" );
601             parser.defineEntityReplacementText( "tilde", "\u02dc" );
602             parser.defineEntityReplacementText( "ensp", "\u2002" );
603             parser.defineEntityReplacementText( "emsp", "\u2003" );
604             parser.defineEntityReplacementText( "thinsp", "\u2009" );
605             parser.defineEntityReplacementText( "zwnj", "\u200c" );
606             parser.defineEntityReplacementText( "zwj", "\u200d" );
607             parser.defineEntityReplacementText( "lrm", "\u200e" );
608             parser.defineEntityReplacementText( "rlm", "\u200f" );
609             parser.defineEntityReplacementText( "ndash", "\u2013" );
610             parser.defineEntityReplacementText( "mdash", "\u2014" );
611             parser.defineEntityReplacementText( "lsquo", "\u2018" );
612             parser.defineEntityReplacementText( "rsquo", "\u2019" );
613             parser.defineEntityReplacementText( "sbquo", "\u201a" );
614             parser.defineEntityReplacementText( "ldquo", "\u201c" );
615             parser.defineEntityReplacementText( "rdquo", "\u201d" );
616             parser.defineEntityReplacementText( "bdquo", "\u201e" );
617             parser.defineEntityReplacementText( "dagger", "\u2020" );
618             parser.defineEntityReplacementText( "Dagger", "\u2021" );
619             parser.defineEntityReplacementText( "permil", "\u2030" );
620             parser.defineEntityReplacementText( "lsaquo", "\u2039" );
621             parser.defineEntityReplacementText( "rsaquo", "\u203a" );
622             parser.defineEntityReplacementText( "euro", "\u20ac" );
623 
624             // ----------------------------------------------------------------------
625             // Symbol entities
626             // ----------------------------------------------------------------------
627 
628             parser.defineEntityReplacementText( "fnof", "\u0192" );
629             parser.defineEntityReplacementText( "Alpha", "\u0391" );
630             parser.defineEntityReplacementText( "Beta", "\u0392" );
631             parser.defineEntityReplacementText( "Gamma", "\u0393" );
632             parser.defineEntityReplacementText( "Delta", "\u0394" );
633             parser.defineEntityReplacementText( "Epsilon", "\u0395" );
634             parser.defineEntityReplacementText( "Zeta", "\u0396" );
635             parser.defineEntityReplacementText( "Eta", "\u0397" );
636             parser.defineEntityReplacementText( "Theta", "\u0398" );
637             parser.defineEntityReplacementText( "Iota", "\u0399" );
638             parser.defineEntityReplacementText( "Kappa", "\u039a" );
639             parser.defineEntityReplacementText( "Lambda", "\u039b" );
640             parser.defineEntityReplacementText( "Mu", "\u039c" );
641             parser.defineEntityReplacementText( "Nu", "\u039d" );
642             parser.defineEntityReplacementText( "Xi", "\u039e" );
643             parser.defineEntityReplacementText( "Omicron", "\u039f" );
644             parser.defineEntityReplacementText( "Pi", "\u03a0" );
645             parser.defineEntityReplacementText( "Rho", "\u03a1" );
646             parser.defineEntityReplacementText( "Sigma", "\u03a3" );
647             parser.defineEntityReplacementText( "Tau", "\u03a4" );
648             parser.defineEntityReplacementText( "Upsilon", "\u03a5" );
649             parser.defineEntityReplacementText( "Phi", "\u03a6" );
650             parser.defineEntityReplacementText( "Chi", "\u03a7" );
651             parser.defineEntityReplacementText( "Psi", "\u03a8" );
652             parser.defineEntityReplacementText( "Omega", "\u03a9" );
653             parser.defineEntityReplacementText( "alpha", "\u03b1" );
654             parser.defineEntityReplacementText( "beta", "\u03b2" );
655             parser.defineEntityReplacementText( "gamma", "\u03b3" );
656             parser.defineEntityReplacementText( "delta", "\u03b4" );
657             parser.defineEntityReplacementText( "epsilon", "\u03b5" );
658             parser.defineEntityReplacementText( "zeta", "\u03b6" );
659             parser.defineEntityReplacementText( "eta", "\u03b7" );
660             parser.defineEntityReplacementText( "theta", "\u03b8" );
661             parser.defineEntityReplacementText( "iota", "\u03b9" );
662             parser.defineEntityReplacementText( "kappa", "\u03ba" );
663             parser.defineEntityReplacementText( "lambda", "\u03bb" );
664             parser.defineEntityReplacementText( "mu", "\u03bc" );
665             parser.defineEntityReplacementText( "nu", "\u03bd" );
666             parser.defineEntityReplacementText( "xi", "\u03be" );
667             parser.defineEntityReplacementText( "omicron", "\u03bf" );
668             parser.defineEntityReplacementText( "pi", "\u03c0" );
669             parser.defineEntityReplacementText( "rho", "\u03c1" );
670             parser.defineEntityReplacementText( "sigmaf", "\u03c2" );
671             parser.defineEntityReplacementText( "sigma", "\u03c3" );
672             parser.defineEntityReplacementText( "tau", "\u03c4" );
673             parser.defineEntityReplacementText( "upsilon", "\u03c5" );
674             parser.defineEntityReplacementText( "phi", "\u03c6" );
675             parser.defineEntityReplacementText( "chi", "\u03c7" );
676             parser.defineEntityReplacementText( "psi", "\u03c8" );
677             parser.defineEntityReplacementText( "omega", "\u03c9" );
678             parser.defineEntityReplacementText( "thetasym", "\u03d1" );
679             parser.defineEntityReplacementText( "upsih", "\u03d2" );
680             parser.defineEntityReplacementText( "piv", "\u03d6" );
681             parser.defineEntityReplacementText( "bull", "\u2022" );
682             parser.defineEntityReplacementText( "hellip", "\u2026" );
683             parser.defineEntityReplacementText( "prime", "\u2032" );
684             parser.defineEntityReplacementText( "Prime", "\u2033" );
685             parser.defineEntityReplacementText( "oline", "\u203e" );
686             parser.defineEntityReplacementText( "frasl", "\u2044" );
687             parser.defineEntityReplacementText( "weierp", "\u2118" );
688             parser.defineEntityReplacementText( "image", "\u2111" );
689             parser.defineEntityReplacementText( "real", "\u211c" );
690             parser.defineEntityReplacementText( "trade", "\u2122" );
691             parser.defineEntityReplacementText( "alefsym", "\u2135" );
692             parser.defineEntityReplacementText( "larr", "\u2190" );
693             parser.defineEntityReplacementText( "uarr", "\u2191" );
694             parser.defineEntityReplacementText( "rarr", "\u2192" );
695             parser.defineEntityReplacementText( "darr", "\u2193" );
696             parser.defineEntityReplacementText( "harr", "\u2194" );
697             parser.defineEntityReplacementText( "crarr", "\u21b5" );
698             parser.defineEntityReplacementText( "lArr", "\u21d0" );
699             parser.defineEntityReplacementText( "uArr", "\u21d1" );
700             parser.defineEntityReplacementText( "rArr", "\u21d2" );
701             parser.defineEntityReplacementText( "dArr", "\u21d3" );
702             parser.defineEntityReplacementText( "hArr", "\u21d4" );
703             parser.defineEntityReplacementText( "forall", "\u2200" );
704             parser.defineEntityReplacementText( "part", "\u2202" );
705             parser.defineEntityReplacementText( "exist", "\u2203" );
706             parser.defineEntityReplacementText( "empty", "\u2205" );
707             parser.defineEntityReplacementText( "nabla", "\u2207" );
708             parser.defineEntityReplacementText( "isin", "\u2208" );
709             parser.defineEntityReplacementText( "notin", "\u2209" );
710             parser.defineEntityReplacementText( "ni", "\u220b" );
711             parser.defineEntityReplacementText( "prod", "\u220f" );
712             parser.defineEntityReplacementText( "sum", "\u2211" );
713             parser.defineEntityReplacementText( "minus", "\u2212" );
714             parser.defineEntityReplacementText( "lowast", "\u2217" );
715             parser.defineEntityReplacementText( "radic", "\u221a" );
716             parser.defineEntityReplacementText( "prop", "\u221d" );
717             parser.defineEntityReplacementText( "infin", "\u221e" );
718             parser.defineEntityReplacementText( "ang", "\u2220" );
719             parser.defineEntityReplacementText( "and", "\u2227" );
720             parser.defineEntityReplacementText( "or", "\u2228" );
721             parser.defineEntityReplacementText( "cap", "\u2229" );
722             parser.defineEntityReplacementText( "cup", "\u222a" );
723             parser.defineEntityReplacementText( "int", "\u222b" );
724             parser.defineEntityReplacementText( "there4", "\u2234" );
725             parser.defineEntityReplacementText( "sim", "\u223c" );
726             parser.defineEntityReplacementText( "cong", "\u2245" );
727             parser.defineEntityReplacementText( "asymp", "\u2248" );
728             parser.defineEntityReplacementText( "ne", "\u2260" );
729             parser.defineEntityReplacementText( "equiv", "\u2261" );
730             parser.defineEntityReplacementText( "le", "\u2264" );
731             parser.defineEntityReplacementText( "ge", "\u2265" );
732             parser.defineEntityReplacementText( "sub", "\u2282" );
733             parser.defineEntityReplacementText( "sup", "\u2283" );
734             parser.defineEntityReplacementText( "nsub", "\u2284" );
735             parser.defineEntityReplacementText( "sube", "\u2286" );
736             parser.defineEntityReplacementText( "supe", "\u2287" );
737             parser.defineEntityReplacementText( "oplus", "\u2295" );
738             parser.defineEntityReplacementText( "otimes", "\u2297" );
739             parser.defineEntityReplacementText( "perp", "\u22a5" );
740             parser.defineEntityReplacementText( "sdot", "\u22c5" );
741             parser.defineEntityReplacementText( "lceil", "\u2308" );
742             parser.defineEntityReplacementText( "rceil", "\u2309" );
743             parser.defineEntityReplacementText( "lfloor", "\u230a" );
744             parser.defineEntityReplacementText( "rfloor", "\u230b" );
745             parser.defineEntityReplacementText( "lang", "\u2329" );
746             parser.defineEntityReplacementText( "rang", "\u232a" );
747             parser.defineEntityReplacementText( "loz", "\u25ca" );
748             parser.defineEntityReplacementText( "spades", "\u2660" );
749             parser.defineEntityReplacementText( "clubs", "\u2663" );
750             parser.defineEntityReplacementText( "hearts", "\u2665" );
751             parser.defineEntityReplacementText( "diams", "\u2666" );
752 
753         }
754     } //-- void initParser( XmlPullParser )
755 
756     /**
757      * Method nextTag.
758      * 
759      * @param parser
760      * @throws IOException
761      * @throws XmlPullParserException
762      * @return int
763      */
764     private int nextTag( XmlPullParser parser )
765         throws IOException, XmlPullParserException
766     {
767         int eventType = parser.next();
768         if ( eventType == XmlPullParser.TEXT )
769         {
770             eventType = parser.next();
771         }
772         if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
773         {
774             throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
775         }
776         return eventType;
777     } //-- int nextTag( XmlPullParser )
778 
779     /**
780      * @see ReaderFactory#newXmlReader
781      * 
782      * @param reader
783      * @param strict
784      * @throws IOException
785      * @throws XmlPullParserException
786      * @return PluginDescriptor
787      */
788     public PluginDescriptor read( Reader reader, boolean strict )
789         throws IOException, XmlPullParserException
790     {
791         XmlPullParser parser = new MXParser();
792 
793         parser.setInput( reader );
794 
795         initParser( parser );
796 
797         return read( parser, strict );
798     } //-- PluginDescriptor read( Reader, boolean )
799 
800     /**
801      * @see ReaderFactory#newXmlReader
802      * 
803      * @param reader
804      * @throws IOException
805      * @throws XmlPullParserException
806      * @return PluginDescriptor
807      */
808     public PluginDescriptor read( Reader reader )
809         throws IOException, XmlPullParserException
810     {
811         return read( reader, true );
812     } //-- PluginDescriptor read( Reader )
813 
814     /**
815      * Method read.
816      * 
817      * @param in
818      * @param strict
819      * @throws IOException
820      * @throws XmlPullParserException
821      * @return PluginDescriptor
822      */
823     public PluginDescriptor read( InputStream in, boolean strict )
824         throws IOException, XmlPullParserException
825     {
826         return read( ReaderFactory.newXmlReader( in ), strict );
827     } //-- PluginDescriptor read( InputStream, boolean )
828 
829     /**
830      * Method read.
831      * 
832      * @param in
833      * @throws IOException
834      * @throws XmlPullParserException
835      * @return PluginDescriptor
836      */
837     public PluginDescriptor read( InputStream in )
838         throws IOException, XmlPullParserException
839     {
840         return read( ReaderFactory.newXmlReader( in ) );
841     } //-- PluginDescriptor read( InputStream )
842 
843     /**
844      * Method parseConfiguration.
845      * 
846      * @param parser
847      * @param strict
848      * @throws IOException
849      * @throws XmlPullParserException
850      * @return Configuration
851      */
852     private Configuration parseConfiguration( XmlPullParser parser, boolean strict )
853         throws IOException, XmlPullParserException
854     {
855         String tagName = parser.getName();
856         Configuration configuration = new Configuration();
857         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
858         {
859             String name = parser.getAttributeName( i );
860             String value = parser.getAttributeValue( i );
861 
862             if ( name.indexOf( ':' ) >= 0 )
863             {
864                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
865             }
866             else if ( "implementation".equals( name ) )
867             {
868                 configuration.setImplementation( getTrimmedValue( value ) );
869             }
870             else if ( "default-value".equals( name ) )
871             {
872                 configuration.setDefaultValue( getTrimmedValue( value ) );
873             }
874             else
875             {
876                 checkUnknownAttribute( parser, name, tagName, strict );
877             }
878         }
879         configuration.setExpression( getTrimmedValue( parser.nextText() ) );
880         return configuration;
881     } //-- Configuration parseConfiguration( XmlPullParser, boolean )
882 
883     /**
884      * Method parseDependency.
885      * 
886      * @param parser
887      * @param strict
888      * @throws IOException
889      * @throws XmlPullParserException
890      * @return Dependency
891      */
892     private Dependency parseDependency( XmlPullParser parser, boolean strict )
893         throws IOException, XmlPullParserException
894     {
895         String tagName = parser.getName();
896         Dependency dependency = new Dependency();
897         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
898         {
899             String name = parser.getAttributeName( i );
900             String value = parser.getAttributeValue( i );
901 
902             if ( name.indexOf( ':' ) >= 0 )
903             {
904                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
905             }
906             else
907             {
908                 checkUnknownAttribute( parser, name, tagName, strict );
909             }
910         }
911         java.util.Set parsed = new java.util.HashSet();
912         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
913         {
914             if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
915             {
916                 dependency.setGroupId( getTrimmedValue( parser.nextText() ) );
917             }
918             else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
919             {
920                 dependency.setArtifactId( getTrimmedValue( parser.nextText() ) );
921             }
922             else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
923             {
924                 dependency.setVersion( getTrimmedValue( parser.nextText() ) );
925             }
926             else if ( checkFieldWithDuplicate( parser, "type", null, parsed ) )
927             {
928                 dependency.setType( getTrimmedValue( parser.nextText() ) );
929             }
930             else
931             {
932                 checkUnknownElement( parser, strict );
933             }
934         }
935         return dependency;
936     } //-- Dependency parseDependency( XmlPullParser, boolean )
937 
938     /**
939      * Method parseMojoDescriptor.
940      * 
941      * @param parser
942      * @param strict
943      * @throws IOException
944      * @throws XmlPullParserException
945      * @return MojoDescriptor
946      */
947     private MojoDescriptor parseMojoDescriptor( XmlPullParser parser, boolean strict )
948         throws IOException, XmlPullParserException
949     {
950         String tagName = parser.getName();
951         MojoDescriptor mojoDescriptor = new MojoDescriptor();
952         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
953         {
954             String name = parser.getAttributeName( i );
955             String value = parser.getAttributeValue( i );
956 
957             if ( name.indexOf( ':' ) >= 0 )
958             {
959                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
960             }
961             else
962             {
963                 checkUnknownAttribute( parser, name, tagName, strict );
964             }
965         }
966         java.util.Set parsed = new java.util.HashSet();
967         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
968         {
969             if ( checkFieldWithDuplicate( parser, "goal", null, parsed ) )
970             {
971                 mojoDescriptor.setGoal( getTrimmedValue( parser.nextText() ) );
972             }
973             else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
974             {
975                 mojoDescriptor.setDescription( getTrimmedValue( parser.nextText() ) );
976             }
977             else if ( checkFieldWithDuplicate( parser, "implementation", null, parsed ) )
978             {
979                 mojoDescriptor.setImplementation( getTrimmedValue( parser.nextText() ) );
980             }
981             else if ( checkFieldWithDuplicate( parser, "language", null, parsed ) )
982             {
983                 mojoDescriptor.setLanguage( getTrimmedValue( parser.nextText() ) );
984             }
985             else if ( checkFieldWithDuplicate( parser, "phase", null, parsed ) )
986             {
987                 mojoDescriptor.setPhase( getTrimmedValue( parser.nextText() ) );
988             }
989             else if ( checkFieldWithDuplicate( parser, "executePhase", null, parsed ) )
990             {
991                 mojoDescriptor.setExecutePhase( getTrimmedValue( parser.nextText() ) );
992             }
993             else if ( checkFieldWithDuplicate( parser, "executeGoal", null, parsed ) )
994             {
995                 mojoDescriptor.setExecuteGoal( getTrimmedValue( parser.nextText() ) );
996             }
997             else if ( checkFieldWithDuplicate( parser, "executeLifecycle", null, parsed ) )
998             {
999                 mojoDescriptor.setExecuteLifecycle( getTrimmedValue( parser.nextText() ) );
1000             }
1001             else if ( checkFieldWithDuplicate( parser, "requiresDependencyResolution", null, parsed ) )
1002             {
1003                 mojoDescriptor.setRequiresDependencyResolution( getTrimmedValue( parser.nextText() ) );
1004             }
1005             else if ( checkFieldWithDuplicate( parser, "requiresDependencyCollection", null, parsed ) )
1006             {
1007                 mojoDescriptor.setRequiresDependencyCollection( getTrimmedValue( parser.nextText() ) );
1008             }
1009             else if ( checkFieldWithDuplicate( parser, "requiresDirectInvocation", null, parsed ) )
1010             {
1011                 mojoDescriptor.setRequiresDirectInvocation( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresDirectInvocation", parser, "false" ) );
1012             }
1013             else if ( checkFieldWithDuplicate( parser, "requiresProject", null, parsed ) )
1014             {
1015                 mojoDescriptor.setRequiresProject( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresProject", parser, "true" ) );
1016             }
1017             else if ( checkFieldWithDuplicate( parser, "requiresReports", null, parsed ) )
1018             {
1019                 mojoDescriptor.setRequiresReports( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresReports", parser, "false" ) );
1020             }
1021             else if ( checkFieldWithDuplicate( parser, "requiresOnline", null, parsed ) )
1022             {
1023                 mojoDescriptor.setRequiresOnline( getBooleanValue( getTrimmedValue( parser.nextText() ), "requiresOnline", parser, "false" ) );
1024             }
1025             else if ( checkFieldWithDuplicate( parser, "aggregator", null, parsed ) )
1026             {
1027                 mojoDescriptor.setAggregator( getBooleanValue( getTrimmedValue( parser.nextText() ), "aggregator", parser, "false" ) );
1028             }
1029             else if ( checkFieldWithDuplicate( parser, "inheritedByDefault", null, parsed ) )
1030             {
1031                 mojoDescriptor.setInheritedByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "inheritedByDefault", parser, "true" ) );
1032             }
1033             else if ( checkFieldWithDuplicate( parser, "threadSafe", null, parsed ) )
1034             {
1035                 mojoDescriptor.setThreadSafe( getBooleanValue( getTrimmedValue( parser.nextText() ), "threadSafe", parser, "false" ) );
1036             }
1037             else if ( checkFieldWithDuplicate( parser, "instantiationStrategy", null, parsed ) )
1038             {
1039                 mojoDescriptor.setInstantiationStrategy( getTrimmedValue( parser.nextText() ) );
1040             }
1041             else if ( checkFieldWithDuplicate( parser, "executionStrategy", null, parsed ) )
1042             {
1043                 mojoDescriptor.setExecutionStrategy( getTrimmedValue( parser.nextText() ) );
1044             }
1045             else if ( checkFieldWithDuplicate( parser, "since", null, parsed ) )
1046             {
1047                 mojoDescriptor.setSince( getTrimmedValue( parser.nextText() ) );
1048             }
1049             else if ( checkFieldWithDuplicate( parser, "deprecated", null, parsed ) )
1050             {
1051                 mojoDescriptor.setDeprecated( getTrimmedValue( parser.nextText() ) );
1052             }
1053             else if ( checkFieldWithDuplicate( parser, "configurator", null, parsed ) )
1054             {
1055                 mojoDescriptor.setConfigurator( getTrimmedValue( parser.nextText() ) );
1056             }
1057             else if ( checkFieldWithDuplicate( parser, "composer", null, parsed ) )
1058             {
1059                 mojoDescriptor.setComposer( getTrimmedValue( parser.nextText() ) );
1060             }
1061             else if ( checkFieldWithDuplicate( parser, "parameters", null, parsed ) )
1062             {
1063                 java.util.List parameters = new java.util.ArrayList/*<Parameter>*/();
1064                 mojoDescriptor.setParameters( parameters );
1065                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1066                 {
1067                     if ( "parameter".equals( parser.getName() ) )
1068                     {
1069                         parameters.add( parseParameter( parser, strict ) );
1070                     }
1071                     else
1072                     {
1073                         checkUnknownElement( parser, strict );
1074                     }
1075                 }
1076             }
1077             else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
1078             {
1079                 java.util.List configuration = new java.util.ArrayList/*<Configuration>*/();
1080                 mojoDescriptor.setConfiguration( configuration );
1081                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1082                 {
1083                     if ( "paramName".equals( parser.getName() ) )
1084                     {
1085                         configuration.add( parseConfiguration( parser, strict ) );
1086                     }
1087                     else
1088                     {
1089                         checkUnknownElement( parser, strict );
1090                     }
1091                 }
1092             }
1093             else if ( checkFieldWithDuplicate( parser, "requirements", null, parsed ) )
1094             {
1095                 java.util.List requirements = new java.util.ArrayList/*<Requirement>*/();
1096                 mojoDescriptor.setRequirements( requirements );
1097                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1098                 {
1099                     if ( "requirement".equals( parser.getName() ) )
1100                     {
1101                         requirements.add( parseRequirement( parser, strict ) );
1102                     }
1103                     else
1104                     {
1105                         checkUnknownElement( parser, strict );
1106                     }
1107                 }
1108             }
1109             else
1110             {
1111                 checkUnknownElement( parser, strict );
1112             }
1113         }
1114         return mojoDescriptor;
1115     } //-- MojoDescriptor parseMojoDescriptor( XmlPullParser, boolean )
1116 
1117     /**
1118      * Method parseParameter.
1119      * 
1120      * @param parser
1121      * @param strict
1122      * @throws IOException
1123      * @throws XmlPullParserException
1124      * @return Parameter
1125      */
1126     private Parameter parseParameter( XmlPullParser parser, boolean strict )
1127         throws IOException, XmlPullParserException
1128     {
1129         String tagName = parser.getName();
1130         Parameter parameter = new Parameter();
1131         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1132         {
1133             String name = parser.getAttributeName( i );
1134             String value = parser.getAttributeValue( i );
1135 
1136             if ( name.indexOf( ':' ) >= 0 )
1137             {
1138                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1139             }
1140             else
1141             {
1142                 checkUnknownAttribute( parser, name, tagName, strict );
1143             }
1144         }
1145         java.util.Set parsed = new java.util.HashSet();
1146         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1147         {
1148             if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1149             {
1150                 parameter.setName( getTrimmedValue( parser.nextText() ) );
1151             }
1152             else if ( checkFieldWithDuplicate( parser, "alias", null, parsed ) )
1153             {
1154                 parameter.setAlias( getTrimmedValue( parser.nextText() ) );
1155             }
1156             else if ( checkFieldWithDuplicate( parser, "type", null, parsed ) )
1157             {
1158                 parameter.setType( getTrimmedValue( parser.nextText() ) );
1159             }
1160             else if ( checkFieldWithDuplicate( parser, "required", null, parsed ) )
1161             {
1162                 parameter.setRequired( getBooleanValue( getTrimmedValue( parser.nextText() ), "required", parser, "false" ) );
1163             }
1164             else if ( checkFieldWithDuplicate( parser, "editable", null, parsed ) )
1165             {
1166                 parameter.setEditable( getBooleanValue( getTrimmedValue( parser.nextText() ), "editable", parser, "true" ) );
1167             }
1168             else if ( checkFieldWithDuplicate( parser, "implementation", null, parsed ) )
1169             {
1170                 parameter.setImplementation( getTrimmedValue( parser.nextText() ) );
1171             }
1172             else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
1173             {
1174                 parameter.setDescription( getTrimmedValue( parser.nextText() ) );
1175             }
1176             else if ( checkFieldWithDuplicate( parser, "since", null, parsed ) )
1177             {
1178                 parameter.setSince( getTrimmedValue( parser.nextText() ) );
1179             }
1180             else if ( checkFieldWithDuplicate( parser, "deprecated", null, parsed ) )
1181             {
1182                 parameter.setDeprecated( getTrimmedValue( parser.nextText() ) );
1183             }
1184             else
1185             {
1186                 checkUnknownElement( parser, strict );
1187             }
1188         }
1189         return parameter;
1190     } //-- Parameter parseParameter( XmlPullParser, boolean )
1191 
1192     /**
1193      * Method parsePluginDescriptor.
1194      * 
1195      * @param parser
1196      * @param strict
1197      * @throws IOException
1198      * @throws XmlPullParserException
1199      * @return PluginDescriptor
1200      */
1201     private PluginDescriptor parsePluginDescriptor( XmlPullParser parser, boolean strict )
1202         throws IOException, XmlPullParserException
1203     {
1204         String tagName = parser.getName();
1205         PluginDescriptor pluginDescriptor = new PluginDescriptor();
1206         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1207         {
1208             String name = parser.getAttributeName( i );
1209             String value = parser.getAttributeValue( i );
1210 
1211             if ( name.indexOf( ':' ) >= 0 )
1212             {
1213                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1214             }
1215             else if ( "xmlns".equals( name ) )
1216             {
1217                 // ignore xmlns attribute in root class, which is a reserved attribute name
1218             }
1219             else
1220             {
1221                 checkUnknownAttribute( parser, name, tagName, strict );
1222             }
1223         }
1224         java.util.Set parsed = new java.util.HashSet();
1225         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1226         {
1227             if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
1228             {
1229                 pluginDescriptor.setDescription( getTrimmedValue( parser.nextText() ) );
1230             }
1231             else if ( checkFieldWithDuplicate( parser, "groupId", null, parsed ) )
1232             {
1233                 pluginDescriptor.setGroupId( getTrimmedValue( parser.nextText() ) );
1234             }
1235             else if ( checkFieldWithDuplicate( parser, "artifactId", null, parsed ) )
1236             {
1237                 pluginDescriptor.setArtifactId( getTrimmedValue( parser.nextText() ) );
1238             }
1239             else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
1240             {
1241                 pluginDescriptor.setVersion( getTrimmedValue( parser.nextText() ) );
1242             }
1243             else if ( checkFieldWithDuplicate( parser, "goalPrefix", null, parsed ) )
1244             {
1245                 pluginDescriptor.setGoalPrefix( getTrimmedValue( parser.nextText() ) );
1246             }
1247             else if ( checkFieldWithDuplicate( parser, "isolatedRealm", null, parsed ) )
1248             {
1249                 pluginDescriptor.setIsolatedRealm( getBooleanValue( getTrimmedValue( parser.nextText() ), "isolatedRealm", parser, "false" ) );
1250             }
1251             else if ( checkFieldWithDuplicate( parser, "inheritedByDefault", null, parsed ) )
1252             {
1253                 pluginDescriptor.setInheritedByDefault( getBooleanValue( getTrimmedValue( parser.nextText() ), "inheritedByDefault", parser, "true" ) );
1254             }
1255             else if ( checkFieldWithDuplicate( parser, "mojos", null, parsed ) )
1256             {
1257                 java.util.List mojos = new java.util.ArrayList/*<MojoDescriptor>*/();
1258                 pluginDescriptor.setMojos( mojos );
1259                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1260                 {
1261                     if ( "mojo".equals( parser.getName() ) )
1262                     {
1263                         mojos.add( parseMojoDescriptor( parser, strict ) );
1264                     }
1265                     else
1266                     {
1267                         checkUnknownElement( parser, strict );
1268                     }
1269                 }
1270             }
1271             else if ( checkFieldWithDuplicate( parser, "dependencies", null, parsed ) )
1272             {
1273                 java.util.List dependencies = new java.util.ArrayList/*<Dependency>*/();
1274                 pluginDescriptor.setDependencies( dependencies );
1275                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1276                 {
1277                     if ( "dependency".equals( parser.getName() ) )
1278                     {
1279                         dependencies.add( parseDependency( parser, strict ) );
1280                     }
1281                     else
1282                     {
1283                         checkUnknownElement( parser, strict );
1284                     }
1285                 }
1286             }
1287             else
1288             {
1289                 checkUnknownElement( parser, strict );
1290             }
1291         }
1292         return pluginDescriptor;
1293     } //-- PluginDescriptor parsePluginDescriptor( XmlPullParser, boolean )
1294 
1295     /**
1296      * Method parseRequirement.
1297      * 
1298      * @param parser
1299      * @param strict
1300      * @throws IOException
1301      * @throws XmlPullParserException
1302      * @return Requirement
1303      */
1304     private Requirement parseRequirement( XmlPullParser parser, boolean strict )
1305         throws IOException, XmlPullParserException
1306     {
1307         String tagName = parser.getName();
1308         Requirement requirement = new Requirement();
1309         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1310         {
1311             String name = parser.getAttributeName( i );
1312             String value = parser.getAttributeValue( i );
1313 
1314             if ( name.indexOf( ':' ) >= 0 )
1315             {
1316                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1317             }
1318             else
1319             {
1320                 checkUnknownAttribute( parser, name, tagName, strict );
1321             }
1322         }
1323         java.util.Set parsed = new java.util.HashSet();
1324         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1325         {
1326             if ( checkFieldWithDuplicate( parser, "role", null, parsed ) )
1327             {
1328                 requirement.setRole( getTrimmedValue( parser.nextText() ) );
1329             }
1330             else if ( checkFieldWithDuplicate( parser, "role-hint", null, parsed ) )
1331             {
1332                 requirement.setRoleHint( getTrimmedValue( parser.nextText() ) );
1333             }
1334             else if ( checkFieldWithDuplicate( parser, "field-name", null, parsed ) )
1335             {
1336                 requirement.setFieldName( getTrimmedValue( parser.nextText() ) );
1337             }
1338             else
1339             {
1340                 checkUnknownElement( parser, strict );
1341             }
1342         }
1343         return requirement;
1344     } //-- Requirement parseRequirement( XmlPullParser, boolean )
1345 
1346     /**
1347      * Method read.
1348      * 
1349      * @param parser
1350      * @param strict
1351      * @throws IOException
1352      * @throws XmlPullParserException
1353      * @return PluginDescriptor
1354      */
1355     private PluginDescriptor read( XmlPullParser parser, boolean strict )
1356         throws IOException, XmlPullParserException
1357     {
1358         int eventType = parser.getEventType();
1359         while ( eventType != XmlPullParser.END_DOCUMENT )
1360         {
1361             if ( eventType == XmlPullParser.START_TAG )
1362             {
1363                 if ( strict && ! "plugin".equals( parser.getName() ) )
1364                 {
1365                     throw new XmlPullParserException( "Expected root element 'plugin' but found '" + parser.getName() + "'", parser, null );
1366                 }
1367                 PluginDescriptor pluginDescriptor = parsePluginDescriptor( parser, strict );
1368                 pluginDescriptor.setModelEncoding( parser.getInputEncoding() );
1369                 return pluginDescriptor;
1370             }
1371             eventType = parser.next();
1372         }
1373         throw new XmlPullParserException( "Expected root element 'plugin' but found no element at all: invalid XML document", parser, null );
1374     } //-- PluginDescriptor read( XmlPullParser, boolean )
1375 
1376     /**
1377      * Sets the state of the "add default entities" flag.
1378      * 
1379      * @param addDefaultEntities
1380      */
1381     public void setAddDefaultEntities( boolean addDefaultEntities )
1382     {
1383         this.addDefaultEntities = addDefaultEntities;
1384     } //-- void setAddDefaultEntities( boolean )
1385 
1386 }