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