View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 2.0.0,
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      * @see ReaderFactory#newXmlReader
567      * 
568      * @param reader a reader 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( Reader reader, boolean strict )
576         throws IOException, XmlPullParserException
577     {
578         XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
579 
580         parser.setInput( reader );
581 
582 
583         return read( parser, strict );
584     } //-- Settings read( Reader, boolean )
585 
586     /**
587      * @see ReaderFactory#newXmlReader
588      * 
589      * @param reader a reader object.
590      * @throws IOException IOException if any.
591      * @throws XmlPullParserException XmlPullParserException if
592      * any.
593      * @return Settings
594      */
595     public Settings read( Reader reader )
596         throws IOException, XmlPullParserException
597     {
598         return read( reader, true );
599     } //-- Settings read( Reader )
600 
601     /**
602      * Method read.
603      * 
604      * @param in a in object.
605      * @param strict a strict object.
606      * @throws IOException IOException if any.
607      * @throws XmlPullParserException XmlPullParserException if
608      * any.
609      * @return Settings
610      */
611     public Settings read( InputStream in, boolean strict )
612         throws IOException, XmlPullParserException
613     {
614         return read( ReaderFactory.newXmlReader( in ), strict );
615     } //-- Settings read( InputStream, boolean )
616 
617     /**
618      * Method read.
619      * 
620      * @param in a in object.
621      * @throws IOException IOException if any.
622      * @throws XmlPullParserException XmlPullParserException if
623      * any.
624      * @return Settings
625      */
626     public Settings read( InputStream in )
627         throws IOException, XmlPullParserException
628     {
629         return read( ReaderFactory.newXmlReader( in ) );
630     } //-- Settings read( InputStream )
631 
632     /**
633      * Method parseActivation.
634      * 
635      * @param parser a parser object.
636      * @param strict a strict object.
637      * @throws IOException IOException if any.
638      * @throws XmlPullParserException XmlPullParserException if
639      * any.
640      * @return Activation
641      */
642     private Activation parseActivation( XmlPullParser parser, boolean strict )
643         throws IOException, XmlPullParserException
644     {
645         String tagName = parser.getName();
646         Activation activation = new Activation();
647         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
648         {
649             String name = parser.getAttributeName( i );
650             String value = parser.getAttributeValue( i );
651 
652             if ( name.indexOf( ':' ) >= 0 )
653             {
654                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
655             }
656             else
657             {
658                 checkUnknownAttribute( parser, name, tagName, strict );
659             }
660         }
661         java.util.Set parsed = new java.util.HashSet();
662         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
663         {
664             if ( checkFieldWithDuplicate( parser, "activeByDefault", null, parsed ) )
665             {
666                 activation.setActiveByDefault( getBooleanValue( interpolatedTrimmed( parser.nextText(), "activeByDefault" ), "activeByDefault", parser, "false" ) );
667             }
668             else if ( checkFieldWithDuplicate( parser, "jdk", null, parsed ) )
669             {
670                 activation.setJdk( interpolatedTrimmed( parser.nextText(), "jdk" ) );
671             }
672             else if ( checkFieldWithDuplicate( parser, "os", null, parsed ) )
673             {
674                 activation.setOs( parseActivationOS( parser, strict ) );
675             }
676             else if ( checkFieldWithDuplicate( parser, "property", null, parsed ) )
677             {
678                 activation.setProperty( parseActivationProperty( parser, strict ) );
679             }
680             else if ( checkFieldWithDuplicate( parser, "file", null, parsed ) )
681             {
682                 activation.setFile( parseActivationFile( parser, strict ) );
683             }
684             else
685             {
686                 checkUnknownElement( parser, strict );
687             }
688         }
689         return activation;
690     } //-- Activation parseActivation( XmlPullParser, boolean )
691 
692     /**
693      * Method parseActivationFile.
694      * 
695      * @param parser a parser object.
696      * @param strict a strict object.
697      * @throws IOException IOException if any.
698      * @throws XmlPullParserException XmlPullParserException if
699      * any.
700      * @return ActivationFile
701      */
702     private ActivationFile parseActivationFile( XmlPullParser parser, boolean strict )
703         throws IOException, XmlPullParserException
704     {
705         String tagName = parser.getName();
706         ActivationFile activationFile = new ActivationFile();
707         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
708         {
709             String name = parser.getAttributeName( i );
710             String value = parser.getAttributeValue( i );
711 
712             if ( name.indexOf( ':' ) >= 0 )
713             {
714                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
715             }
716             else
717             {
718                 checkUnknownAttribute( parser, name, tagName, strict );
719             }
720         }
721         java.util.Set parsed = new java.util.HashSet();
722         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
723         {
724             if ( checkFieldWithDuplicate( parser, "missing", null, parsed ) )
725             {
726                 activationFile.setMissing( interpolatedTrimmed( parser.nextText(), "missing" ) );
727             }
728             else if ( checkFieldWithDuplicate( parser, "exists", null, parsed ) )
729             {
730                 activationFile.setExists( interpolatedTrimmed( parser.nextText(), "exists" ) );
731             }
732             else
733             {
734                 checkUnknownElement( parser, strict );
735             }
736         }
737         return activationFile;
738     } //-- ActivationFile parseActivationFile( XmlPullParser, boolean )
739 
740     /**
741      * Method parseActivationOS.
742      * 
743      * @param parser a parser object.
744      * @param strict a strict object.
745      * @throws IOException IOException if any.
746      * @throws XmlPullParserException XmlPullParserException if
747      * any.
748      * @return ActivationOS
749      */
750     private ActivationOS parseActivationOS( XmlPullParser parser, boolean strict )
751         throws IOException, XmlPullParserException
752     {
753         String tagName = parser.getName();
754         ActivationOS activationOS = new ActivationOS();
755         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
756         {
757             String name = parser.getAttributeName( i );
758             String value = parser.getAttributeValue( i );
759 
760             if ( name.indexOf( ':' ) >= 0 )
761             {
762                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
763             }
764             else
765             {
766                 checkUnknownAttribute( parser, name, tagName, strict );
767             }
768         }
769         java.util.Set parsed = new java.util.HashSet();
770         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
771         {
772             if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
773             {
774                 activationOS.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
775             }
776             else if ( checkFieldWithDuplicate( parser, "family", null, parsed ) )
777             {
778                 activationOS.setFamily( interpolatedTrimmed( parser.nextText(), "family" ) );
779             }
780             else if ( checkFieldWithDuplicate( parser, "arch", null, parsed ) )
781             {
782                 activationOS.setArch( interpolatedTrimmed( parser.nextText(), "arch" ) );
783             }
784             else if ( checkFieldWithDuplicate( parser, "version", null, parsed ) )
785             {
786                 activationOS.setVersion( interpolatedTrimmed( parser.nextText(), "version" ) );
787             }
788             else
789             {
790                 checkUnknownElement( parser, strict );
791             }
792         }
793         return activationOS;
794     } //-- ActivationOS parseActivationOS( XmlPullParser, boolean )
795 
796     /**
797      * Method parseActivationProperty.
798      * 
799      * @param parser a parser object.
800      * @param strict a strict object.
801      * @throws IOException IOException if any.
802      * @throws XmlPullParserException XmlPullParserException if
803      * any.
804      * @return ActivationProperty
805      */
806     private ActivationProperty parseActivationProperty( XmlPullParser parser, boolean strict )
807         throws IOException, XmlPullParserException
808     {
809         String tagName = parser.getName();
810         ActivationProperty activationProperty = new ActivationProperty();
811         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
812         {
813             String name = parser.getAttributeName( i );
814             String value = parser.getAttributeValue( i );
815 
816             if ( name.indexOf( ':' ) >= 0 )
817             {
818                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
819             }
820             else
821             {
822                 checkUnknownAttribute( parser, name, tagName, strict );
823             }
824         }
825         java.util.Set parsed = new java.util.HashSet();
826         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
827         {
828             if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
829             {
830                 activationProperty.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
831             }
832             else if ( checkFieldWithDuplicate( parser, "value", null, parsed ) )
833             {
834                 activationProperty.setValue( interpolatedTrimmed( parser.nextText(), "value" ) );
835             }
836             else
837             {
838                 checkUnknownElement( parser, strict );
839             }
840         }
841         return activationProperty;
842     } //-- ActivationProperty parseActivationProperty( XmlPullParser, boolean )
843 
844     /**
845      * Method parseIdentifiableBase.
846      * 
847      * @param parser a parser object.
848      * @param strict a strict object.
849      * @throws IOException IOException if any.
850      * @throws XmlPullParserException XmlPullParserException if
851      * any.
852      * @return IdentifiableBase
853      */
854     private IdentifiableBase parseIdentifiableBase( XmlPullParser parser, boolean strict )
855         throws IOException, XmlPullParserException
856     {
857         String tagName = parser.getName();
858         IdentifiableBase identifiableBase = new IdentifiableBase();
859         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
860         {
861             String name = parser.getAttributeName( i );
862             String value = parser.getAttributeValue( i );
863 
864             if ( name.indexOf( ':' ) >= 0 )
865             {
866                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
867             }
868             else
869             {
870                 checkUnknownAttribute( parser, name, tagName, strict );
871             }
872         }
873         java.util.Set parsed = new java.util.HashSet();
874         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
875         {
876             if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
877             {
878                 identifiableBase.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
879             }
880             else
881             {
882                 checkUnknownElement( parser, strict );
883             }
884         }
885         return identifiableBase;
886     } //-- IdentifiableBase parseIdentifiableBase( XmlPullParser, boolean )
887 
888     /**
889      * Method parseMirror.
890      * 
891      * @param parser a parser object.
892      * @param strict a strict object.
893      * @throws IOException IOException if any.
894      * @throws XmlPullParserException XmlPullParserException if
895      * any.
896      * @return Mirror
897      */
898     private Mirror parseMirror( XmlPullParser parser, boolean strict )
899         throws IOException, XmlPullParserException
900     {
901         String tagName = parser.getName();
902         Mirror mirror = new Mirror();
903         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
904         {
905             String name = parser.getAttributeName( i );
906             String value = parser.getAttributeValue( i );
907 
908             if ( name.indexOf( ':' ) >= 0 )
909             {
910                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
911             }
912             else
913             {
914                 checkUnknownAttribute( parser, name, tagName, strict );
915             }
916         }
917         java.util.Set parsed = new java.util.HashSet();
918         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
919         {
920             if ( checkFieldWithDuplicate( parser, "mirrorOf", null, parsed ) )
921             {
922                 mirror.setMirrorOf( interpolatedTrimmed( parser.nextText(), "mirrorOf" ) );
923             }
924             else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
925             {
926                 mirror.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
927             }
928             else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
929             {
930                 mirror.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
931             }
932             else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) )
933             {
934                 mirror.setLayout( interpolatedTrimmed( parser.nextText(), "layout" ) );
935             }
936             else if ( checkFieldWithDuplicate( parser, "mirrorOfLayouts", null, parsed ) )
937             {
938                 mirror.setMirrorOfLayouts( interpolatedTrimmed( parser.nextText(), "mirrorOfLayouts" ) );
939             }
940             else if ( checkFieldWithDuplicate( parser, "blocked", null, parsed ) )
941             {
942                 mirror.setBlocked( getBooleanValue( interpolatedTrimmed( parser.nextText(), "blocked" ), "blocked", parser, "false" ) );
943             }
944             else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
945             {
946                 mirror.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
947             }
948             else
949             {
950                 checkUnknownElement( parser, strict );
951             }
952         }
953         return mirror;
954     } //-- Mirror parseMirror( XmlPullParser, boolean )
955 
956     /**
957      * Method parseProfile.
958      * 
959      * @param parser a parser object.
960      * @param strict a strict object.
961      * @throws IOException IOException if any.
962      * @throws XmlPullParserException XmlPullParserException if
963      * any.
964      * @return Profile
965      */
966     private Profile parseProfile( XmlPullParser parser, boolean strict )
967         throws IOException, XmlPullParserException
968     {
969         String tagName = parser.getName();
970         Profile profile = new Profile();
971         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
972         {
973             String name = parser.getAttributeName( i );
974             String value = parser.getAttributeValue( i );
975 
976             if ( name.indexOf( ':' ) >= 0 )
977             {
978                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
979             }
980             else
981             {
982                 checkUnknownAttribute( parser, name, tagName, strict );
983             }
984         }
985         java.util.Set parsed = new java.util.HashSet();
986         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
987         {
988             if ( checkFieldWithDuplicate( parser, "activation", null, parsed ) )
989             {
990                 profile.setActivation( parseActivation( parser, strict ) );
991             }
992             else if ( checkFieldWithDuplicate( parser, "properties", null, parsed ) )
993             {
994                 while ( parser.nextTag() == XmlPullParser.START_TAG )
995                 {
996                     String key = parser.getName();
997                     String value = parser.nextText().trim();
998                     profile.addProperty( key, value );
999                 }
1000             }
1001             else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) )
1002             {
1003                 java.util.List<Repository> repositories = new java.util.ArrayList<Repository>();
1004                 profile.setRepositories( repositories );
1005                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1006                 {
1007                     if ( "repository".equals( parser.getName() ) )
1008                     {
1009                         repositories.add( parseRepository( parser, strict ) );
1010                     }
1011                     else
1012                     {
1013                         checkUnknownElement( parser, strict );
1014                     }
1015                 }
1016             }
1017             else if ( checkFieldWithDuplicate( parser, "pluginRepositories", null, parsed ) )
1018             {
1019                 java.util.List<Repository> pluginRepositories = new java.util.ArrayList<Repository>();
1020                 profile.setPluginRepositories( pluginRepositories );
1021                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1022                 {
1023                     if ( "pluginRepository".equals( parser.getName() ) )
1024                     {
1025                         pluginRepositories.add( parseRepository( parser, strict ) );
1026                     }
1027                     else
1028                     {
1029                         checkUnknownElement( parser, strict );
1030                     }
1031                 }
1032             }
1033             else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1034             {
1035                 profile.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1036             }
1037             else
1038             {
1039                 checkUnknownElement( parser, strict );
1040             }
1041         }
1042         return profile;
1043     } //-- Profile parseProfile( XmlPullParser, boolean )
1044 
1045     /**
1046      * Method parseProxy.
1047      * 
1048      * @param parser a parser object.
1049      * @param strict a strict object.
1050      * @throws IOException IOException if any.
1051      * @throws XmlPullParserException XmlPullParserException if
1052      * any.
1053      * @return Proxy
1054      */
1055     private Proxy parseProxy( XmlPullParser parser, boolean strict )
1056         throws IOException, XmlPullParserException
1057     {
1058         String tagName = parser.getName();
1059         Proxy proxy = new Proxy();
1060         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1061         {
1062             String name = parser.getAttributeName( i );
1063             String value = parser.getAttributeValue( i );
1064 
1065             if ( name.indexOf( ':' ) >= 0 )
1066             {
1067                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1068             }
1069             else
1070             {
1071                 checkUnknownAttribute( parser, name, tagName, strict );
1072             }
1073         }
1074         java.util.Set parsed = new java.util.HashSet();
1075         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1076         {
1077             if ( checkFieldWithDuplicate( parser, "active", null, parsed ) )
1078             {
1079                 proxy.setActive( getBooleanValue( interpolatedTrimmed( parser.nextText(), "active" ), "active", parser, "true" ) );
1080             }
1081             else if ( checkFieldWithDuplicate( parser, "protocol", null, parsed ) )
1082             {
1083                 proxy.setProtocol( interpolatedTrimmed( parser.nextText(), "protocol" ) );
1084             }
1085             else if ( checkFieldWithDuplicate( parser, "username", null, parsed ) )
1086             {
1087                 proxy.setUsername( interpolatedTrimmed( parser.nextText(), "username" ) );
1088             }
1089             else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) )
1090             {
1091                 proxy.setPassword( interpolatedTrimmed( parser.nextText(), "password" ) );
1092             }
1093             else if ( checkFieldWithDuplicate( parser, "port", null, parsed ) )
1094             {
1095                 proxy.setPort( getIntegerValue( interpolatedTrimmed( parser.nextText(), "port" ), "port", parser, strict ) );
1096             }
1097             else if ( checkFieldWithDuplicate( parser, "host", null, parsed ) )
1098             {
1099                 proxy.setHost( interpolatedTrimmed( parser.nextText(), "host" ) );
1100             }
1101             else if ( checkFieldWithDuplicate( parser, "nonProxyHosts", null, parsed ) )
1102             {
1103                 proxy.setNonProxyHosts( interpolatedTrimmed( parser.nextText(), "nonProxyHosts" ) );
1104             }
1105             else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1106             {
1107                 proxy.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1108             }
1109             else
1110             {
1111                 checkUnknownElement( parser, strict );
1112             }
1113         }
1114         return proxy;
1115     } //-- Proxy parseProxy( XmlPullParser, boolean )
1116 
1117     /**
1118      * Method parseRepository.
1119      * 
1120      * @param parser a parser object.
1121      * @param strict a strict object.
1122      * @throws IOException IOException if any.
1123      * @throws XmlPullParserException XmlPullParserException if
1124      * any.
1125      * @return Repository
1126      */
1127     private Repository parseRepository( XmlPullParser parser, boolean strict )
1128         throws IOException, XmlPullParserException
1129     {
1130         String tagName = parser.getName();
1131         Repository repository = new Repository();
1132         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1133         {
1134             String name = parser.getAttributeName( i );
1135             String value = parser.getAttributeValue( i );
1136 
1137             if ( name.indexOf( ':' ) >= 0 )
1138             {
1139                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1140             }
1141             else
1142             {
1143                 checkUnknownAttribute( parser, name, tagName, strict );
1144             }
1145         }
1146         java.util.Set parsed = new java.util.HashSet();
1147         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1148         {
1149             if ( checkFieldWithDuplicate( parser, "releases", null, parsed ) )
1150             {
1151                 repository.setReleases( parseRepositoryPolicy( parser, strict ) );
1152             }
1153             else if ( checkFieldWithDuplicate( parser, "snapshots", null, parsed ) )
1154             {
1155                 repository.setSnapshots( parseRepositoryPolicy( parser, strict ) );
1156             }
1157             else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1158             {
1159                 repository.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1160             }
1161             else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1162             {
1163                 repository.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
1164             }
1165             else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
1166             {
1167                 repository.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
1168             }
1169             else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) )
1170             {
1171                 repository.setLayout( interpolatedTrimmed( parser.nextText(), "layout" ) );
1172             }
1173             else
1174             {
1175                 checkUnknownElement( parser, strict );
1176             }
1177         }
1178         return repository;
1179     } //-- Repository parseRepository( XmlPullParser, boolean )
1180 
1181     /**
1182      * Method parseRepositoryBase.
1183      * 
1184      * @param parser a parser object.
1185      * @param strict a strict object.
1186      * @throws IOException IOException if any.
1187      * @throws XmlPullParserException XmlPullParserException if
1188      * any.
1189      * @return RepositoryBase
1190      */
1191     private RepositoryBase parseRepositoryBase( XmlPullParser parser, boolean strict )
1192         throws IOException, XmlPullParserException
1193     {
1194         String tagName = parser.getName();
1195         RepositoryBase repositoryBase = new RepositoryBase();
1196         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1197         {
1198             String name = parser.getAttributeName( i );
1199             String value = parser.getAttributeValue( i );
1200 
1201             if ( name.indexOf( ':' ) >= 0 )
1202             {
1203                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1204             }
1205             else
1206             {
1207                 checkUnknownAttribute( parser, name, tagName, strict );
1208             }
1209         }
1210         java.util.Set parsed = new java.util.HashSet();
1211         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1212         {
1213             if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1214             {
1215                 repositoryBase.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1216             }
1217             else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1218             {
1219                 repositoryBase.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
1220             }
1221             else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
1222             {
1223                 repositoryBase.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
1224             }
1225             else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) )
1226             {
1227                 repositoryBase.setLayout( interpolatedTrimmed( parser.nextText(), "layout" ) );
1228             }
1229             else
1230             {
1231                 checkUnknownElement( parser, strict );
1232             }
1233         }
1234         return repositoryBase;
1235     } //-- RepositoryBase parseRepositoryBase( XmlPullParser, boolean )
1236 
1237     /**
1238      * Method parseRepositoryPolicy.
1239      * 
1240      * @param parser a parser object.
1241      * @param strict a strict object.
1242      * @throws IOException IOException if any.
1243      * @throws XmlPullParserException XmlPullParserException if
1244      * any.
1245      * @return RepositoryPolicy
1246      */
1247     private RepositoryPolicy parseRepositoryPolicy( XmlPullParser parser, boolean strict )
1248         throws IOException, XmlPullParserException
1249     {
1250         String tagName = parser.getName();
1251         RepositoryPolicy repositoryPolicy = new RepositoryPolicy();
1252         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1253         {
1254             String name = parser.getAttributeName( i );
1255             String value = parser.getAttributeValue( i );
1256 
1257             if ( name.indexOf( ':' ) >= 0 )
1258             {
1259                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1260             }
1261             else
1262             {
1263                 checkUnknownAttribute( parser, name, tagName, strict );
1264             }
1265         }
1266         java.util.Set parsed = new java.util.HashSet();
1267         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1268         {
1269             if ( checkFieldWithDuplicate( parser, "enabled", null, parsed ) )
1270             {
1271                 repositoryPolicy.setEnabled( getBooleanValue( interpolatedTrimmed( parser.nextText(), "enabled" ), "enabled", parser, "true" ) );
1272             }
1273             else if ( checkFieldWithDuplicate( parser, "updatePolicy", null, parsed ) )
1274             {
1275                 repositoryPolicy.setUpdatePolicy( interpolatedTrimmed( parser.nextText(), "updatePolicy" ) );
1276             }
1277             else if ( checkFieldWithDuplicate( parser, "checksumPolicy", null, parsed ) )
1278             {
1279                 repositoryPolicy.setChecksumPolicy( interpolatedTrimmed( parser.nextText(), "checksumPolicy" ) );
1280             }
1281             else
1282             {
1283                 checkUnknownElement( parser, strict );
1284             }
1285         }
1286         return repositoryPolicy;
1287     } //-- RepositoryPolicy parseRepositoryPolicy( XmlPullParser, boolean )
1288 
1289     /**
1290      * Method parseServer.
1291      * 
1292      * @param parser a parser object.
1293      * @param strict a strict object.
1294      * @throws IOException IOException if any.
1295      * @throws XmlPullParserException XmlPullParserException if
1296      * any.
1297      * @return Server
1298      */
1299     private Server parseServer( XmlPullParser parser, boolean strict )
1300         throws IOException, XmlPullParserException
1301     {
1302         String tagName = parser.getName();
1303         Server server = new Server();
1304         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1305         {
1306             String name = parser.getAttributeName( i );
1307             String value = parser.getAttributeValue( i );
1308 
1309             if ( name.indexOf( ':' ) >= 0 )
1310             {
1311                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1312             }
1313             else
1314             {
1315                 checkUnknownAttribute( parser, name, tagName, strict );
1316             }
1317         }
1318         java.util.Set parsed = new java.util.HashSet();
1319         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1320         {
1321             if ( checkFieldWithDuplicate( parser, "username", null, parsed ) )
1322             {
1323                 server.setUsername( interpolatedTrimmed( parser.nextText(), "username" ) );
1324             }
1325             else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) )
1326             {
1327                 server.setPassword( interpolatedTrimmed( parser.nextText(), "password" ) );
1328             }
1329             else if ( checkFieldWithDuplicate( parser, "privateKey", null, parsed ) )
1330             {
1331                 server.setPrivateKey( interpolatedTrimmed( parser.nextText(), "privateKey" ) );
1332             }
1333             else if ( checkFieldWithDuplicate( parser, "passphrase", null, parsed ) )
1334             {
1335                 server.setPassphrase( interpolatedTrimmed( parser.nextText(), "passphrase" ) );
1336             }
1337             else if ( checkFieldWithDuplicate( parser, "filePermissions", null, parsed ) )
1338             {
1339                 server.setFilePermissions( interpolatedTrimmed( parser.nextText(), "filePermissions" ) );
1340             }
1341             else if ( checkFieldWithDuplicate( parser, "directoryPermissions", null, parsed ) )
1342             {
1343                 server.setDirectoryPermissions( interpolatedTrimmed( parser.nextText(), "directoryPermissions" ) );
1344             }
1345             else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
1346             {
1347                 server.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
1348             }
1349             else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1350             {
1351                 server.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1352             }
1353             else
1354             {
1355                 checkUnknownElement( parser, strict );
1356             }
1357         }
1358         return server;
1359     } //-- Server parseServer( XmlPullParser, boolean )
1360 
1361     /**
1362      * Method parseSettings.
1363      * 
1364      * @param parser a parser object.
1365      * @param strict a strict object.
1366      * @throws IOException IOException if any.
1367      * @throws XmlPullParserException XmlPullParserException if
1368      * any.
1369      * @return Settings
1370      */
1371     private Settings parseSettings( XmlPullParser parser, boolean strict )
1372         throws IOException, XmlPullParserException
1373     {
1374         String tagName = parser.getName();
1375         Settings settings = new Settings();
1376         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1377         {
1378             String name = parser.getAttributeName( i );
1379             String value = parser.getAttributeValue( i );
1380 
1381             if ( name.indexOf( ':' ) >= 0 )
1382             {
1383                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1384             }
1385             else if ( "xmlns".equals( name ) )
1386             {
1387                 // ignore xmlns attribute in root class, which is a reserved attribute name
1388             }
1389             else
1390             {
1391                 checkUnknownAttribute( parser, name, tagName, strict );
1392             }
1393         }
1394         java.util.Set parsed = new java.util.HashSet();
1395         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1396         {
1397             if ( checkFieldWithDuplicate( parser, "localRepository", null, parsed ) )
1398             {
1399                 settings.setLocalRepository( interpolatedTrimmed( parser.nextText(), "localRepository" ) );
1400             }
1401             else if ( checkFieldWithDuplicate( parser, "interactiveMode", null, parsed ) )
1402             {
1403                 settings.setInteractiveMode( getBooleanValue( interpolatedTrimmed( parser.nextText(), "interactiveMode" ), "interactiveMode", parser, "true" ) );
1404             }
1405             else if ( checkFieldWithDuplicate( parser, "usePluginRegistry", null, parsed ) )
1406             {
1407                 settings.setUsePluginRegistry( getBooleanValue( interpolatedTrimmed( parser.nextText(), "usePluginRegistry" ), "usePluginRegistry", parser, "false" ) );
1408             }
1409             else if ( checkFieldWithDuplicate( parser, "offline", null, parsed ) )
1410             {
1411                 settings.setOffline( getBooleanValue( interpolatedTrimmed( parser.nextText(), "offline" ), "offline", parser, "false" ) );
1412             }
1413             else if ( checkFieldWithDuplicate( parser, "proxies", null, parsed ) )
1414             {
1415                 java.util.List<Proxy> proxies = new java.util.ArrayList<Proxy>();
1416                 settings.setProxies( proxies );
1417                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1418                 {
1419                     if ( "proxy".equals( parser.getName() ) )
1420                     {
1421                         proxies.add( parseProxy( parser, strict ) );
1422                     }
1423                     else
1424                     {
1425                         checkUnknownElement( parser, strict );
1426                     }
1427                 }
1428             }
1429             else if ( checkFieldWithDuplicate( parser, "servers", null, parsed ) )
1430             {
1431                 java.util.List<Server> servers = new java.util.ArrayList<Server>();
1432                 settings.setServers( servers );
1433                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1434                 {
1435                     if ( "server".equals( parser.getName() ) )
1436                     {
1437                         servers.add( parseServer( parser, strict ) );
1438                     }
1439                     else
1440                     {
1441                         checkUnknownElement( parser, strict );
1442                     }
1443                 }
1444             }
1445             else if ( checkFieldWithDuplicate( parser, "mirrors", null, parsed ) )
1446             {
1447                 java.util.List<Mirror> mirrors = new java.util.ArrayList<Mirror>();
1448                 settings.setMirrors( mirrors );
1449                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1450                 {
1451                     if ( "mirror".equals( parser.getName() ) )
1452                     {
1453                         mirrors.add( parseMirror( parser, strict ) );
1454                     }
1455                     else
1456                     {
1457                         checkUnknownElement( parser, strict );
1458                     }
1459                 }
1460             }
1461             else if ( checkFieldWithDuplicate( parser, "profiles", null, parsed ) )
1462             {
1463                 java.util.List<Profile> profiles = new java.util.ArrayList<Profile>();
1464                 settings.setProfiles( profiles );
1465                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1466                 {
1467                     if ( "profile".equals( parser.getName() ) )
1468                     {
1469                         profiles.add( parseProfile( parser, strict ) );
1470                     }
1471                     else
1472                     {
1473                         checkUnknownElement( parser, strict );
1474                     }
1475                 }
1476             }
1477             else if ( checkFieldWithDuplicate( parser, "activeProfiles", null, parsed ) )
1478             {
1479                 java.util.List<String> activeProfiles = new java.util.ArrayList<String>();
1480                 settings.setActiveProfiles( activeProfiles );
1481                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1482                 {
1483                     if ( "activeProfile".equals( parser.getName() ) )
1484                     {
1485                         activeProfiles.add( interpolatedTrimmed( parser.nextText(), "activeProfiles" ) );
1486                     }
1487                     else
1488                     {
1489                         checkUnknownElement( parser, strict );
1490                     }
1491                 }
1492             }
1493             else if ( checkFieldWithDuplicate( parser, "pluginGroups", null, parsed ) )
1494             {
1495                 java.util.List<String> pluginGroups = new java.util.ArrayList<String>();
1496                 settings.setPluginGroups( pluginGroups );
1497                 while ( parser.nextTag() == XmlPullParser.START_TAG )
1498                 {
1499                     if ( "pluginGroup".equals( parser.getName() ) )
1500                     {
1501                         pluginGroups.add( interpolatedTrimmed( parser.nextText(), "pluginGroups" ) );
1502                     }
1503                     else
1504                     {
1505                         checkUnknownElement( parser, strict );
1506                     }
1507                 }
1508             }
1509             else
1510             {
1511                 checkUnknownElement( parser, strict );
1512             }
1513         }
1514         return settings;
1515     } //-- Settings parseSettings( XmlPullParser, boolean )
1516 
1517     /**
1518      * Method parseTrackableBase.
1519      * 
1520      * @param parser a parser object.
1521      * @param strict a strict object.
1522      * @throws IOException IOException if any.
1523      * @throws XmlPullParserException XmlPullParserException if
1524      * any.
1525      * @return TrackableBase
1526      */
1527     private TrackableBase parseTrackableBase( XmlPullParser parser, boolean strict )
1528         throws IOException, XmlPullParserException
1529     {
1530         String tagName = parser.getName();
1531         TrackableBase trackableBase = new TrackableBase();
1532         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1533         {
1534             String name = parser.getAttributeName( i );
1535             String value = parser.getAttributeValue( i );
1536 
1537             if ( name.indexOf( ':' ) >= 0 )
1538             {
1539                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1540             }
1541             else
1542             {
1543                 checkUnknownAttribute( parser, name, tagName, strict );
1544             }
1545         }
1546         java.util.Set parsed = new java.util.HashSet();
1547         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1548         {
1549             checkUnknownElement( parser, strict );
1550         }
1551         return trackableBase;
1552     } //-- TrackableBase parseTrackableBase( XmlPullParser, boolean )
1553 
1554     /**
1555      * Method read.
1556      * 
1557      * @param parser a parser object.
1558      * @param strict a strict object.
1559      * @throws IOException IOException if any.
1560      * @throws XmlPullParserException XmlPullParserException if
1561      * any.
1562      * @return Settings
1563      */
1564     private Settings read( XmlPullParser parser, boolean strict )
1565         throws IOException, XmlPullParserException
1566     {
1567         Settings settings = null;
1568         int eventType = parser.getEventType();
1569         boolean parsed = false;
1570         while ( eventType != XmlPullParser.END_DOCUMENT )
1571         {
1572             if ( eventType == XmlPullParser.START_TAG )
1573             {
1574                 if ( strict && ! "settings".equals( parser.getName() ) )
1575                 {
1576                     throw new XmlPullParserException( "Expected root element 'settings' but found '" + parser.getName() + "'", parser, null );
1577                 }
1578                 else if ( parsed )
1579                 {
1580                     // fallback, already expected a XmlPullParserException due to invalid XML
1581                     throw new XmlPullParserException( "Duplicated tag: 'settings'", parser, null );
1582                 }
1583                 settings = parseSettings( parser, strict );
1584                 settings.setModelEncoding( parser.getInputEncoding() );
1585                 parsed = true;
1586             }
1587             eventType = parser.next();
1588         }
1589         if ( parsed )
1590         {
1591             return settings;
1592         }
1593         throw new XmlPullParserException( "Expected root element 'settings' but found no element at all: invalid XML document", parser, null );
1594     } //-- Settings read( 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 }