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