001// =================== DO NOT EDIT THIS FILE ====================
002// Generated by Modello 1.8.3,
003// any modifications will be overwritten.
004// ==============================================================
005
006package org.apache.maven.settings.io.xpp3;
007
008  //---------------------------------/
009 //- Imported classes and packages -/
010//---------------------------------/
011
012import java.io.IOException;
013import java.io.InputStream;
014import java.io.Reader;
015import java.text.DateFormat;
016import org.apache.maven.settings.Activation;
017import org.apache.maven.settings.ActivationFile;
018import org.apache.maven.settings.ActivationOS;
019import org.apache.maven.settings.ActivationProperty;
020import org.apache.maven.settings.IdentifiableBase;
021import org.apache.maven.settings.Mirror;
022import org.apache.maven.settings.Profile;
023import org.apache.maven.settings.Proxy;
024import org.apache.maven.settings.Repository;
025import org.apache.maven.settings.RepositoryBase;
026import org.apache.maven.settings.RepositoryPolicy;
027import org.apache.maven.settings.Server;
028import org.apache.maven.settings.Settings;
029import org.apache.maven.settings.TrackableBase;
030import org.codehaus.plexus.util.ReaderFactory;
031import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
032import org.codehaus.plexus.util.xml.pull.MXParser;
033import org.codehaus.plexus.util.xml.pull.XmlPullParser;
034import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
035
036/**
037 * Class SettingsXpp3Reader.
038 * 
039 * @version $Revision: 965443 $ $Date: 2015-09-14 22:18:52 +0000 (Mon, 14 Sep 2015) $
040 */
041@SuppressWarnings( "all" )
042public class SettingsXpp3Reader
043{
044
045      //--------------------------/
046     //- Class/Member Variables -/
047    //--------------------------/
048
049    /**
050     * If set the parser will be loaded with all single characters
051     * from the XHTML specification.
052     * The entities used:
053     * <ul>
054     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
055     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
056     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
057     * </ul>
058     */
059    private boolean addDefaultEntities = true;
060
061    /**
062     * Field contentTransformer.
063     */
064    public final ContentTransformer contentTransformer;
065
066
067      //----------------/
068     //- Constructors -/
069    //----------------/
070
071    public SettingsXpp3Reader()
072    {
073        this( new ContentTransformer()
074        {
075            public String transform( String source, String fieldName )
076            {
077                return source;
078            }
079        } );
080    } //-- org.apache.maven.settings.io.xpp3.SettingsXpp3Reader()
081
082    public SettingsXpp3Reader(ContentTransformer contentTransformer)
083    {
084        this.contentTransformer = contentTransformer;
085    } //-- org.apache.maven.settings.io.xpp3.SettingsXpp3Reader(ContentTransformer)
086
087
088      //-----------/
089     //- Methods -/
090    //-----------/
091
092    /**
093     * Method checkFieldWithDuplicate.
094     * 
095     * @param parser
096     * @param parsed
097     * @param alias
098     * @param tagName
099     * @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, "id", null, parsed ) )
915            {
916                mirror.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
917            }
918            else
919            {
920                checkUnknownElement( parser, strict );
921            }
922        }
923        return mirror;
924    } //-- Mirror parseMirror( XmlPullParser, boolean )
925
926    /**
927     * Method parseProfile.
928     * 
929     * @param parser
930     * @param strict
931     * @throws IOException
932     * @throws XmlPullParserException
933     * @return Profile
934     */
935    private Profile parseProfile( XmlPullParser parser, boolean strict )
936        throws IOException, XmlPullParserException
937    {
938        String tagName = parser.getName();
939        Profile profile = new Profile();
940        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
941        {
942            String name = parser.getAttributeName( i );
943            String value = parser.getAttributeValue( i );
944
945            if ( name.indexOf( ':' ) >= 0 )
946            {
947                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
948            }
949            else
950            {
951                checkUnknownAttribute( parser, name, tagName, strict );
952            }
953        }
954        java.util.Set parsed = new java.util.HashSet();
955        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
956        {
957            if ( checkFieldWithDuplicate( parser, "activation", null, parsed ) )
958            {
959                profile.setActivation( parseActivation( parser, strict ) );
960            }
961            else if ( checkFieldWithDuplicate( parser, "properties", null, parsed ) )
962            {
963                while ( parser.nextTag() == XmlPullParser.START_TAG )
964                {
965                    String key = parser.getName();
966                    String value = parser.nextText().trim();
967                    profile.addProperty( key, value );
968                }
969            }
970            else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) )
971            {
972                java.util.List repositories = new java.util.ArrayList/*<Repository>*/();
973                profile.setRepositories( repositories );
974                while ( parser.nextTag() == XmlPullParser.START_TAG )
975                {
976                    if ( "repository".equals( parser.getName() ) )
977                    {
978                        repositories.add( parseRepository( parser, strict ) );
979                    }
980                    else
981                    {
982                        checkUnknownElement( parser, strict );
983                    }
984                }
985            }
986            else if ( checkFieldWithDuplicate( parser, "pluginRepositories", null, parsed ) )
987            {
988                java.util.List pluginRepositories = new java.util.ArrayList/*<Repository>*/();
989                profile.setPluginRepositories( pluginRepositories );
990                while ( parser.nextTag() == XmlPullParser.START_TAG )
991                {
992                    if ( "pluginRepository".equals( parser.getName() ) )
993                    {
994                        pluginRepositories.add( parseRepository( parser, strict ) );
995                    }
996                    else
997                    {
998                        checkUnknownElement( parser, strict );
999                    }
1000                }
1001            }
1002            else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1003            {
1004                profile.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1005            }
1006            else
1007            {
1008                checkUnknownElement( parser, strict );
1009            }
1010        }
1011        return profile;
1012    } //-- Profile parseProfile( XmlPullParser, boolean )
1013
1014    /**
1015     * Method parseProxy.
1016     * 
1017     * @param parser
1018     * @param strict
1019     * @throws IOException
1020     * @throws XmlPullParserException
1021     * @return Proxy
1022     */
1023    private Proxy parseProxy( XmlPullParser parser, boolean strict )
1024        throws IOException, XmlPullParserException
1025    {
1026        String tagName = parser.getName();
1027        Proxy proxy = new Proxy();
1028        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1029        {
1030            String name = parser.getAttributeName( i );
1031            String value = parser.getAttributeValue( i );
1032
1033            if ( name.indexOf( ':' ) >= 0 )
1034            {
1035                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1036            }
1037            else
1038            {
1039                checkUnknownAttribute( parser, name, tagName, strict );
1040            }
1041        }
1042        java.util.Set parsed = new java.util.HashSet();
1043        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1044        {
1045            if ( checkFieldWithDuplicate( parser, "active", null, parsed ) )
1046            {
1047                proxy.setActive( getBooleanValue( interpolatedTrimmed( parser.nextText(), "active" ), "active", parser, "true" ) );
1048            }
1049            else if ( checkFieldWithDuplicate( parser, "protocol", null, parsed ) )
1050            {
1051                proxy.setProtocol( interpolatedTrimmed( parser.nextText(), "protocol" ) );
1052            }
1053            else if ( checkFieldWithDuplicate( parser, "username", null, parsed ) )
1054            {
1055                proxy.setUsername( interpolatedTrimmed( parser.nextText(), "username" ) );
1056            }
1057            else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) )
1058            {
1059                proxy.setPassword( interpolatedTrimmed( parser.nextText(), "password" ) );
1060            }
1061            else if ( checkFieldWithDuplicate( parser, "port", null, parsed ) )
1062            {
1063                proxy.setPort( getIntegerValue( interpolatedTrimmed( parser.nextText(), "port" ), "port", parser, strict ) );
1064            }
1065            else if ( checkFieldWithDuplicate( parser, "host", null, parsed ) )
1066            {
1067                proxy.setHost( interpolatedTrimmed( parser.nextText(), "host" ) );
1068            }
1069            else if ( checkFieldWithDuplicate( parser, "nonProxyHosts", null, parsed ) )
1070            {
1071                proxy.setNonProxyHosts( interpolatedTrimmed( parser.nextText(), "nonProxyHosts" ) );
1072            }
1073            else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1074            {
1075                proxy.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1076            }
1077            else
1078            {
1079                checkUnknownElement( parser, strict );
1080            }
1081        }
1082        return proxy;
1083    } //-- Proxy parseProxy( XmlPullParser, boolean )
1084
1085    /**
1086     * Method parseRepository.
1087     * 
1088     * @param parser
1089     * @param strict
1090     * @throws IOException
1091     * @throws XmlPullParserException
1092     * @return Repository
1093     */
1094    private Repository parseRepository( XmlPullParser parser, boolean strict )
1095        throws IOException, XmlPullParserException
1096    {
1097        String tagName = parser.getName();
1098        Repository repository = new Repository();
1099        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1100        {
1101            String name = parser.getAttributeName( i );
1102            String value = parser.getAttributeValue( i );
1103
1104            if ( name.indexOf( ':' ) >= 0 )
1105            {
1106                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1107            }
1108            else
1109            {
1110                checkUnknownAttribute( parser, name, tagName, strict );
1111            }
1112        }
1113        java.util.Set parsed = new java.util.HashSet();
1114        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1115        {
1116            if ( checkFieldWithDuplicate( parser, "releases", null, parsed ) )
1117            {
1118                repository.setReleases( parseRepositoryPolicy( parser, strict ) );
1119            }
1120            else if ( checkFieldWithDuplicate( parser, "snapshots", null, parsed ) )
1121            {
1122                repository.setSnapshots( parseRepositoryPolicy( parser, strict ) );
1123            }
1124            else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1125            {
1126                repository.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1127            }
1128            else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1129            {
1130                repository.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
1131            }
1132            else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
1133            {
1134                repository.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
1135            }
1136            else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) )
1137            {
1138                repository.setLayout( interpolatedTrimmed( parser.nextText(), "layout" ) );
1139            }
1140            else
1141            {
1142                checkUnknownElement( parser, strict );
1143            }
1144        }
1145        return repository;
1146    } //-- Repository parseRepository( XmlPullParser, boolean )
1147
1148    /**
1149     * Method parseRepositoryBase.
1150     * 
1151     * @param parser
1152     * @param strict
1153     * @throws IOException
1154     * @throws XmlPullParserException
1155     * @return RepositoryBase
1156     */
1157    private RepositoryBase parseRepositoryBase( XmlPullParser parser, boolean strict )
1158        throws IOException, XmlPullParserException
1159    {
1160        String tagName = parser.getName();
1161        RepositoryBase repositoryBase = new RepositoryBase();
1162        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1163        {
1164            String name = parser.getAttributeName( i );
1165            String value = parser.getAttributeValue( i );
1166
1167            if ( name.indexOf( ':' ) >= 0 )
1168            {
1169                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1170            }
1171            else
1172            {
1173                checkUnknownAttribute( parser, name, tagName, strict );
1174            }
1175        }
1176        java.util.Set parsed = new java.util.HashSet();
1177        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1178        {
1179            if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1180            {
1181                repositoryBase.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1182            }
1183            else if ( checkFieldWithDuplicate( parser, "name", null, parsed ) )
1184            {
1185                repositoryBase.setName( interpolatedTrimmed( parser.nextText(), "name" ) );
1186            }
1187            else if ( checkFieldWithDuplicate( parser, "url", null, parsed ) )
1188            {
1189                repositoryBase.setUrl( interpolatedTrimmed( parser.nextText(), "url" ) );
1190            }
1191            else if ( checkFieldWithDuplicate( parser, "layout", null, parsed ) )
1192            {
1193                repositoryBase.setLayout( interpolatedTrimmed( parser.nextText(), "layout" ) );
1194            }
1195            else
1196            {
1197                checkUnknownElement( parser, strict );
1198            }
1199        }
1200        return repositoryBase;
1201    } //-- RepositoryBase parseRepositoryBase( XmlPullParser, boolean )
1202
1203    /**
1204     * Method parseRepositoryPolicy.
1205     * 
1206     * @param parser
1207     * @param strict
1208     * @throws IOException
1209     * @throws XmlPullParserException
1210     * @return RepositoryPolicy
1211     */
1212    private RepositoryPolicy parseRepositoryPolicy( XmlPullParser parser, boolean strict )
1213        throws IOException, XmlPullParserException
1214    {
1215        String tagName = parser.getName();
1216        RepositoryPolicy repositoryPolicy = new RepositoryPolicy();
1217        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1218        {
1219            String name = parser.getAttributeName( i );
1220            String value = parser.getAttributeValue( i );
1221
1222            if ( name.indexOf( ':' ) >= 0 )
1223            {
1224                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1225            }
1226            else
1227            {
1228                checkUnknownAttribute( parser, name, tagName, strict );
1229            }
1230        }
1231        java.util.Set parsed = new java.util.HashSet();
1232        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1233        {
1234            if ( checkFieldWithDuplicate( parser, "enabled", null, parsed ) )
1235            {
1236                repositoryPolicy.setEnabled( getBooleanValue( interpolatedTrimmed( parser.nextText(), "enabled" ), "enabled", parser, "true" ) );
1237            }
1238            else if ( checkFieldWithDuplicate( parser, "updatePolicy", null, parsed ) )
1239            {
1240                repositoryPolicy.setUpdatePolicy( interpolatedTrimmed( parser.nextText(), "updatePolicy" ) );
1241            }
1242            else if ( checkFieldWithDuplicate( parser, "checksumPolicy", null, parsed ) )
1243            {
1244                repositoryPolicy.setChecksumPolicy( interpolatedTrimmed( parser.nextText(), "checksumPolicy" ) );
1245            }
1246            else
1247            {
1248                checkUnknownElement( parser, strict );
1249            }
1250        }
1251        return repositoryPolicy;
1252    } //-- RepositoryPolicy parseRepositoryPolicy( XmlPullParser, boolean )
1253
1254    /**
1255     * Method parseServer.
1256     * 
1257     * @param parser
1258     * @param strict
1259     * @throws IOException
1260     * @throws XmlPullParserException
1261     * @return Server
1262     */
1263    private Server parseServer( XmlPullParser parser, boolean strict )
1264        throws IOException, XmlPullParserException
1265    {
1266        String tagName = parser.getName();
1267        Server server = new Server();
1268        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1269        {
1270            String name = parser.getAttributeName( i );
1271            String value = parser.getAttributeValue( i );
1272
1273            if ( name.indexOf( ':' ) >= 0 )
1274            {
1275                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1276            }
1277            else
1278            {
1279                checkUnknownAttribute( parser, name, tagName, strict );
1280            }
1281        }
1282        java.util.Set parsed = new java.util.HashSet();
1283        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1284        {
1285            if ( checkFieldWithDuplicate( parser, "username", null, parsed ) )
1286            {
1287                server.setUsername( interpolatedTrimmed( parser.nextText(), "username" ) );
1288            }
1289            else if ( checkFieldWithDuplicate( parser, "password", null, parsed ) )
1290            {
1291                server.setPassword( interpolatedTrimmed( parser.nextText(), "password" ) );
1292            }
1293            else if ( checkFieldWithDuplicate( parser, "privateKey", null, parsed ) )
1294            {
1295                server.setPrivateKey( interpolatedTrimmed( parser.nextText(), "privateKey" ) );
1296            }
1297            else if ( checkFieldWithDuplicate( parser, "passphrase", null, parsed ) )
1298            {
1299                server.setPassphrase( interpolatedTrimmed( parser.nextText(), "passphrase" ) );
1300            }
1301            else if ( checkFieldWithDuplicate( parser, "filePermissions", null, parsed ) )
1302            {
1303                server.setFilePermissions( interpolatedTrimmed( parser.nextText(), "filePermissions" ) );
1304            }
1305            else if ( checkFieldWithDuplicate( parser, "directoryPermissions", null, parsed ) )
1306            {
1307                server.setDirectoryPermissions( interpolatedTrimmed( parser.nextText(), "directoryPermissions" ) );
1308            }
1309            else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
1310            {
1311                server.setConfiguration( org.codehaus.plexus.util.xml.Xpp3DomBuilder.build( parser, true ) );
1312            }
1313            else if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
1314            {
1315                server.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
1316            }
1317            else
1318            {
1319                checkUnknownElement( parser, strict );
1320            }
1321        }
1322        return server;
1323    } //-- Server parseServer( XmlPullParser, boolean )
1324
1325    /**
1326     * Method parseSettings.
1327     * 
1328     * @param parser
1329     * @param strict
1330     * @throws IOException
1331     * @throws XmlPullParserException
1332     * @return Settings
1333     */
1334    private Settings parseSettings( XmlPullParser parser, boolean strict )
1335        throws IOException, XmlPullParserException
1336    {
1337        String tagName = parser.getName();
1338        Settings settings = new Settings();
1339        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1340        {
1341            String name = parser.getAttributeName( i );
1342            String value = parser.getAttributeValue( i );
1343
1344            if ( name.indexOf( ':' ) >= 0 )
1345            {
1346                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1347            }
1348            else if ( "xmlns".equals( name ) )
1349            {
1350                // ignore xmlns attribute in root class, which is a reserved attribute name
1351            }
1352            else
1353            {
1354                checkUnknownAttribute( parser, name, tagName, strict );
1355            }
1356        }
1357        java.util.Set parsed = new java.util.HashSet();
1358        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1359        {
1360            if ( checkFieldWithDuplicate( parser, "localRepository", null, parsed ) )
1361            {
1362                settings.setLocalRepository( interpolatedTrimmed( parser.nextText(), "localRepository" ) );
1363            }
1364            else if ( checkFieldWithDuplicate( parser, "interactiveMode", null, parsed ) )
1365            {
1366                settings.setInteractiveMode( getBooleanValue( interpolatedTrimmed( parser.nextText(), "interactiveMode" ), "interactiveMode", parser, "true" ) );
1367            }
1368            else if ( checkFieldWithDuplicate( parser, "usePluginRegistry", null, parsed ) )
1369            {
1370                settings.setUsePluginRegistry( getBooleanValue( interpolatedTrimmed( parser.nextText(), "usePluginRegistry" ), "usePluginRegistry", parser, "false" ) );
1371            }
1372            else if ( checkFieldWithDuplicate( parser, "offline", null, parsed ) )
1373            {
1374                settings.setOffline( getBooleanValue( interpolatedTrimmed( parser.nextText(), "offline" ), "offline", parser, "false" ) );
1375            }
1376            else if ( checkFieldWithDuplicate( parser, "proxies", null, parsed ) )
1377            {
1378                java.util.List proxies = new java.util.ArrayList/*<Proxy>*/();
1379                settings.setProxies( proxies );
1380                while ( parser.nextTag() == XmlPullParser.START_TAG )
1381                {
1382                    if ( "proxy".equals( parser.getName() ) )
1383                    {
1384                        proxies.add( parseProxy( parser, strict ) );
1385                    }
1386                    else
1387                    {
1388                        checkUnknownElement( parser, strict );
1389                    }
1390                }
1391            }
1392            else if ( checkFieldWithDuplicate( parser, "servers", null, parsed ) )
1393            {
1394                java.util.List servers = new java.util.ArrayList/*<Server>*/();
1395                settings.setServers( servers );
1396                while ( parser.nextTag() == XmlPullParser.START_TAG )
1397                {
1398                    if ( "server".equals( parser.getName() ) )
1399                    {
1400                        servers.add( parseServer( parser, strict ) );
1401                    }
1402                    else
1403                    {
1404                        checkUnknownElement( parser, strict );
1405                    }
1406                }
1407            }
1408            else if ( checkFieldWithDuplicate( parser, "mirrors", null, parsed ) )
1409            {
1410                java.util.List mirrors = new java.util.ArrayList/*<Mirror>*/();
1411                settings.setMirrors( mirrors );
1412                while ( parser.nextTag() == XmlPullParser.START_TAG )
1413                {
1414                    if ( "mirror".equals( parser.getName() ) )
1415                    {
1416                        mirrors.add( parseMirror( parser, strict ) );
1417                    }
1418                    else
1419                    {
1420                        checkUnknownElement( parser, strict );
1421                    }
1422                }
1423            }
1424            else if ( checkFieldWithDuplicate( parser, "profiles", null, parsed ) )
1425            {
1426                java.util.List profiles = new java.util.ArrayList/*<Profile>*/();
1427                settings.setProfiles( profiles );
1428                while ( parser.nextTag() == XmlPullParser.START_TAG )
1429                {
1430                    if ( "profile".equals( parser.getName() ) )
1431                    {
1432                        profiles.add( parseProfile( parser, strict ) );
1433                    }
1434                    else
1435                    {
1436                        checkUnknownElement( parser, strict );
1437                    }
1438                }
1439            }
1440            else if ( checkFieldWithDuplicate( parser, "activeProfiles", null, parsed ) )
1441            {
1442                java.util.List activeProfiles = new java.util.ArrayList/*<String>*/();
1443                settings.setActiveProfiles( activeProfiles );
1444                while ( parser.nextTag() == XmlPullParser.START_TAG )
1445                {
1446                    if ( "activeProfile".equals( parser.getName() ) )
1447                    {
1448                        activeProfiles.add( interpolatedTrimmed( parser.nextText(), "activeProfiles" ) );
1449                    }
1450                    else
1451                    {
1452                        checkUnknownElement( parser, strict );
1453                    }
1454                }
1455            }
1456            else if ( checkFieldWithDuplicate( parser, "pluginGroups", null, parsed ) )
1457            {
1458                java.util.List pluginGroups = new java.util.ArrayList/*<String>*/();
1459                settings.setPluginGroups( pluginGroups );
1460                while ( parser.nextTag() == XmlPullParser.START_TAG )
1461                {
1462                    if ( "pluginGroup".equals( parser.getName() ) )
1463                    {
1464                        pluginGroups.add( interpolatedTrimmed( parser.nextText(), "pluginGroups" ) );
1465                    }
1466                    else
1467                    {
1468                        checkUnknownElement( parser, strict );
1469                    }
1470                }
1471            }
1472            else
1473            {
1474                checkUnknownElement( parser, strict );
1475            }
1476        }
1477        return settings;
1478    } //-- Settings parseSettings( XmlPullParser, boolean )
1479
1480    /**
1481     * Method parseTrackableBase.
1482     * 
1483     * @param parser
1484     * @param strict
1485     * @throws IOException
1486     * @throws XmlPullParserException
1487     * @return TrackableBase
1488     */
1489    private TrackableBase parseTrackableBase( XmlPullParser parser, boolean strict )
1490        throws IOException, XmlPullParserException
1491    {
1492        String tagName = parser.getName();
1493        TrackableBase trackableBase = new TrackableBase();
1494        for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
1495        {
1496            String name = parser.getAttributeName( i );
1497            String value = parser.getAttributeValue( i );
1498
1499            if ( name.indexOf( ':' ) >= 0 )
1500            {
1501                // just ignore attributes with non-default namespace (for example: xmlns:xsi)
1502            }
1503            else
1504            {
1505                checkUnknownAttribute( parser, name, tagName, strict );
1506            }
1507        }
1508        java.util.Set parsed = new java.util.HashSet();
1509        while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
1510        {
1511            checkUnknownElement( parser, strict );
1512        }
1513        return trackableBase;
1514    } //-- TrackableBase parseTrackableBase( XmlPullParser, boolean )
1515
1516    /**
1517     * Method read.
1518     * 
1519     * @param parser
1520     * @param strict
1521     * @throws IOException
1522     * @throws XmlPullParserException
1523     * @return Settings
1524     */
1525    private Settings read( XmlPullParser parser, boolean strict )
1526        throws IOException, XmlPullParserException
1527    {
1528        int eventType = parser.getEventType();
1529        while ( eventType != XmlPullParser.END_DOCUMENT )
1530        {
1531            if ( eventType == XmlPullParser.START_TAG )
1532            {
1533                if ( strict && ! "settings".equals( parser.getName() ) )
1534                {
1535                    throw new XmlPullParserException( "Expected root element 'settings' but found '" + parser.getName() + "'", parser, null );
1536                }
1537                Settings settings = parseSettings( parser, strict );
1538                settings.setModelEncoding( parser.getInputEncoding() );
1539                return settings;
1540            }
1541            eventType = parser.next();
1542        }
1543        throw new XmlPullParserException( "Expected root element 'settings' but found no element at all: invalid XML document", parser, null );
1544    } //-- Settings read( XmlPullParser, boolean )
1545
1546    /**
1547     * Sets the state of the "add default entities" flag.
1548     * 
1549     * @param addDefaultEntities
1550     */
1551    public void setAddDefaultEntities( boolean addDefaultEntities )
1552    {
1553        this.addDefaultEntities = addDefaultEntities;
1554    } //-- void setAddDefaultEntities( boolean )
1555
1556    public static interface ContentTransformer
1557{
1558    /**
1559     * Interpolate the value read from the xpp3 document
1560     * @param source The source value
1561     * @param fieldName A description of the field being interpolated. The implementation may use this to
1562     *                           log stuff.
1563     * @return The interpolated value.
1564     */
1565    String transform( String source, String fieldName );
1566}
1567
1568}