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