001    /*
002     =================== DO NOT EDIT THIS FILE ====================
003     Generated by Modello 1.4.1 on 2013-02-24 03:31:05,
004     any modifications will be overwritten.
005     ==============================================================
006     */
007    
008    package org.apache.maven.toolchain.model.io.xpp3;
009    
010      //---------------------------------/
011     //- Imported classes and packages -/
012    //---------------------------------/
013    
014    import java.io.IOException;
015    import java.io.InputStream;
016    import java.io.Reader;
017    import java.text.DateFormat;
018    import java.util.Locale;
019    import org.apache.maven.toolchain.model.PersistedToolchains;
020    import org.apache.maven.toolchain.model.ToolchainModel;
021    import org.codehaus.plexus.util.ReaderFactory;
022    import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
023    import org.codehaus.plexus.util.xml.pull.MXParser;
024    import org.codehaus.plexus.util.xml.pull.XmlPullParser;
025    import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
026    
027    /**
028     * Class MavenToolchainsXpp3Reader.
029     * 
030     * @version $Revision$ $Date$
031     */
032    @SuppressWarnings( "all" )
033    public class MavenToolchainsXpp3Reader
034    {
035    
036          //--------------------------/
037         //- Class/Member Variables -/
038        //--------------------------/
039    
040        /**
041         * If set the parser will be loaded with all single characters
042         * from the XHTML specification.
043         * The entities used:
044         * <ul>
045         * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
046         * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
047         * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
048         * </ul>
049         */
050        private boolean addDefaultEntities = true;
051    
052    
053          //-----------/
054         //- Methods -/
055        //-----------/
056    
057        /**
058         * Method checkFieldWithDuplicate.
059         * 
060         * @param parser
061         * @param parsed
062         * @param alias
063         * @param tagName
064         * @throws XmlPullParserException
065         * @return boolean
066         */
067        private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set parsed )
068            throws XmlPullParserException
069        {
070            if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
071            {
072                return false;
073            }
074            if ( !parsed.add( tagName ) )
075            {
076                throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
077            }
078            return true;
079        } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set )
080    
081        /**
082         * Method checkUnknownAttribute.
083         * 
084         * @param parser
085         * @param strict
086         * @param tagName
087         * @param attribute
088         * @throws XmlPullParserException
089         * @throws IOException
090         */
091        private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
092            throws XmlPullParserException, IOException
093        {
094            // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
095            if ( strict )
096            {
097                throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
098            }
099        } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean )
100    
101        /**
102         * Method checkUnknownElement.
103         * 
104         * @param parser
105         * @param strict
106         * @throws XmlPullParserException
107         * @throws IOException
108         */
109        private void checkUnknownElement( XmlPullParser parser, boolean strict )
110            throws XmlPullParserException, IOException
111        {
112            if ( strict )
113            {
114                throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
115            }
116    
117            for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
118            {
119                int eventType = parser.next();
120                if ( eventType == XmlPullParser.START_TAG )
121                {
122                    unrecognizedTagCount++;
123                }
124                else if ( eventType == XmlPullParser.END_TAG )
125                {
126                    unrecognizedTagCount--;
127                }
128            }
129        } //-- void checkUnknownElement( XmlPullParser, boolean )
130    
131        /**
132         * Returns the state of the "add default entities" flag.
133         * 
134         * @return boolean
135         */
136        public boolean getAddDefaultEntities()
137        {
138            return addDefaultEntities;
139        } //-- boolean getAddDefaultEntities()
140    
141        /**
142         * Method getBooleanValue.
143         * 
144         * @param s
145         * @param parser
146         * @param attribute
147         * @throws XmlPullParserException
148         * @return boolean
149         */
150        private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
151            throws XmlPullParserException
152        {
153            return getBooleanValue( s, attribute, parser, null );
154        } //-- boolean getBooleanValue( String, String, XmlPullParser )
155    
156        /**
157         * Method getBooleanValue.
158         * 
159         * @param s
160         * @param defaultValue
161         * @param parser
162         * @param attribute
163         * @throws XmlPullParserException
164         * @return boolean
165         */
166        private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
167            throws XmlPullParserException
168        {
169            if ( s != null && s.length() != 0 )
170            {
171                return Boolean.valueOf( s ).booleanValue();
172            }
173            if ( defaultValue != null )
174            {
175                return Boolean.valueOf( defaultValue ).booleanValue();
176            }
177            return false;
178        } //-- boolean getBooleanValue( String, String, XmlPullParser, String )
179    
180        /**
181         * Method getByteValue.
182         * 
183         * @param s
184         * @param strict
185         * @param parser
186         * @param attribute
187         * @throws XmlPullParserException
188         * @return byte
189         */
190        private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
191            throws XmlPullParserException
192        {
193            if ( s != null )
194            {
195                try
196                {
197                    return Byte.valueOf( s ).byteValue();
198                }
199                catch ( NumberFormatException nfe )
200                {
201                    if ( strict )
202                    {
203                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
204                    }
205                }
206            }
207            return 0;
208        } //-- byte getByteValue( String, String, XmlPullParser, boolean )
209    
210        /**
211         * Method getCharacterValue.
212         * 
213         * @param s
214         * @param parser
215         * @param attribute
216         * @throws XmlPullParserException
217         * @return char
218         */
219        private char getCharacterValue( String s, String attribute, XmlPullParser parser )
220            throws XmlPullParserException
221        {
222            if ( s != null )
223            {
224                return s.charAt( 0 );
225            }
226            return 0;
227        } //-- char getCharacterValue( String, String, XmlPullParser )
228    
229        /**
230         * Method getDateValue.
231         * 
232         * @param s
233         * @param parser
234         * @param attribute
235         * @throws XmlPullParserException
236         * @return Date
237         */
238        private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
239            throws XmlPullParserException
240        {
241            return getDateValue( s, attribute, null, parser );
242        } //-- java.util.Date getDateValue( String, String, XmlPullParser )
243    
244        /**
245         * Method getDateValue.
246         * 
247         * @param s
248         * @param parser
249         * @param dateFormat
250         * @param attribute
251         * @throws XmlPullParserException
252         * @return Date
253         */
254        private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
255            throws XmlPullParserException
256        {
257            if ( s != null )
258            {
259                String effectiveDateFormat = dateFormat;
260                if ( dateFormat == null )
261                {
262                    effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
263                }
264                if ( "long".equals( effectiveDateFormat ) )
265                {
266                    try
267                    {
268                        return new java.util.Date( Long.parseLong( s ) );
269                    }
270                    catch ( NumberFormatException e )
271                    {
272                        throw new XmlPullParserException( e.getMessage(), parser, e );
273                    }
274                }
275                else
276                {
277                    try
278                    {
279                        DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, Locale.US );
280                        return dateParser.parse( s );
281                    }
282                    catch ( java.text.ParseException e )
283                    {
284                        throw new XmlPullParserException( e.getMessage(), parser, e );
285                    }
286                }
287            }
288            return null;
289        } //-- java.util.Date getDateValue( String, String, String, XmlPullParser )
290    
291        /**
292         * Method getDoubleValue.
293         * 
294         * @param s
295         * @param strict
296         * @param parser
297         * @param attribute
298         * @throws XmlPullParserException
299         * @return double
300         */
301        private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
302            throws XmlPullParserException
303        {
304            if ( s != null )
305            {
306                try
307                {
308                    return Double.valueOf( s ).doubleValue();
309                }
310                catch ( NumberFormatException nfe )
311                {
312                    if ( strict )
313                    {
314                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
315                    }
316                }
317            }
318            return 0;
319        } //-- double getDoubleValue( String, String, XmlPullParser, boolean )
320    
321        /**
322         * Method getFloatValue.
323         * 
324         * @param s
325         * @param strict
326         * @param parser
327         * @param attribute
328         * @throws XmlPullParserException
329         * @return float
330         */
331        private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
332            throws XmlPullParserException
333        {
334            if ( s != null )
335            {
336                try
337                {
338                    return Float.valueOf( s ).floatValue();
339                }
340                catch ( NumberFormatException nfe )
341                {
342                    if ( strict )
343                    {
344                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
345                    }
346                }
347            }
348            return 0;
349        } //-- float getFloatValue( String, String, XmlPullParser, boolean )
350    
351        /**
352         * Method getIntegerValue.
353         * 
354         * @param s
355         * @param strict
356         * @param parser
357         * @param attribute
358         * @throws XmlPullParserException
359         * @return int
360         */
361        private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
362            throws XmlPullParserException
363        {
364            if ( s != null )
365            {
366                try
367                {
368                    return Integer.valueOf( s ).intValue();
369                }
370                catch ( NumberFormatException nfe )
371                {
372                    if ( strict )
373                    {
374                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
375                    }
376                }
377            }
378            return 0;
379        } //-- int getIntegerValue( String, String, XmlPullParser, boolean )
380    
381        /**
382         * Method getLongValue.
383         * 
384         * @param s
385         * @param strict
386         * @param parser
387         * @param attribute
388         * @throws XmlPullParserException
389         * @return long
390         */
391        private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
392            throws XmlPullParserException
393        {
394            if ( s != null )
395            {
396                try
397                {
398                    return Long.valueOf( s ).longValue();
399                }
400                catch ( NumberFormatException nfe )
401                {
402                    if ( strict )
403                    {
404                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
405                    }
406                }
407            }
408            return 0;
409        } //-- long getLongValue( String, String, XmlPullParser, boolean )
410    
411        /**
412         * Method getRequiredAttributeValue.
413         * 
414         * @param s
415         * @param strict
416         * @param parser
417         * @param attribute
418         * @throws XmlPullParserException
419         * @return String
420         */
421        private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
422            throws XmlPullParserException
423        {
424            if ( s == null )
425            {
426                if ( strict )
427                {
428                    throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
429                }
430            }
431            return s;
432        } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean )
433    
434        /**
435         * Method getShortValue.
436         * 
437         * @param s
438         * @param strict
439         * @param parser
440         * @param attribute
441         * @throws XmlPullParserException
442         * @return short
443         */
444        private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
445            throws XmlPullParserException
446        {
447            if ( s != null )
448            {
449                try
450                {
451                    return Short.valueOf( s ).shortValue();
452                }
453                catch ( NumberFormatException nfe )
454                {
455                    if ( strict )
456                    {
457                        throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
458                    }
459                }
460            }
461            return 0;
462        } //-- short getShortValue( String, String, XmlPullParser, boolean )
463    
464        /**
465         * Method getTrimmedValue.
466         * 
467         * @param s
468         * @return String
469         */
470        private String getTrimmedValue( String s )
471        {
472            if ( s != null )
473            {
474                s = s.trim();
475            }
476            return s;
477        } //-- String getTrimmedValue( String )
478    
479        /**
480         * Method initParser.
481         * 
482         * @param parser
483         * @throws XmlPullParserException
484         */
485        private void initParser( XmlPullParser parser )
486            throws XmlPullParserException
487        {
488            if ( addDefaultEntities )
489            {
490                // ----------------------------------------------------------------------
491                // Latin 1 entities
492                // ----------------------------------------------------------------------
493    
494                parser.defineEntityReplacementText( "nbsp", "\u00a0" );
495                parser.defineEntityReplacementText( "iexcl", "\u00a1" );
496                parser.defineEntityReplacementText( "cent", "\u00a2" );
497                parser.defineEntityReplacementText( "pound", "\u00a3" );
498                parser.defineEntityReplacementText( "curren", "\u00a4" );
499                parser.defineEntityReplacementText( "yen", "\u00a5" );
500                parser.defineEntityReplacementText( "brvbar", "\u00a6" );
501                parser.defineEntityReplacementText( "sect", "\u00a7" );
502                parser.defineEntityReplacementText( "uml", "\u00a8" );
503                parser.defineEntityReplacementText( "copy", "\u00a9" );
504                parser.defineEntityReplacementText( "ordf", "\u00aa" );
505                parser.defineEntityReplacementText( "laquo", "\u00ab" );
506                parser.defineEntityReplacementText( "not", "\u00ac" );
507                parser.defineEntityReplacementText( "shy", "\u00ad" );
508                parser.defineEntityReplacementText( "reg", "\u00ae" );
509                parser.defineEntityReplacementText( "macr", "\u00af" );
510                parser.defineEntityReplacementText( "deg", "\u00b0" );
511                parser.defineEntityReplacementText( "plusmn", "\u00b1" );
512                parser.defineEntityReplacementText( "sup2", "\u00b2" );
513                parser.defineEntityReplacementText( "sup3", "\u00b3" );
514                parser.defineEntityReplacementText( "acute", "\u00b4" );
515                parser.defineEntityReplacementText( "micro", "\u00b5" );
516                parser.defineEntityReplacementText( "para", "\u00b6" );
517                parser.defineEntityReplacementText( "middot", "\u00b7" );
518                parser.defineEntityReplacementText( "cedil", "\u00b8" );
519                parser.defineEntityReplacementText( "sup1", "\u00b9" );
520                parser.defineEntityReplacementText( "ordm", "\u00ba" );
521                parser.defineEntityReplacementText( "raquo", "\u00bb" );
522                parser.defineEntityReplacementText( "frac14", "\u00bc" );
523                parser.defineEntityReplacementText( "frac12", "\u00bd" );
524                parser.defineEntityReplacementText( "frac34", "\u00be" );
525                parser.defineEntityReplacementText( "iquest", "\u00bf" );
526                parser.defineEntityReplacementText( "Agrave", "\u00c0" );
527                parser.defineEntityReplacementText( "Aacute", "\u00c1" );
528                parser.defineEntityReplacementText( "Acirc", "\u00c2" );
529                parser.defineEntityReplacementText( "Atilde", "\u00c3" );
530                parser.defineEntityReplacementText( "Auml", "\u00c4" );
531                parser.defineEntityReplacementText( "Aring", "\u00c5" );
532                parser.defineEntityReplacementText( "AElig", "\u00c6" );
533                parser.defineEntityReplacementText( "Ccedil", "\u00c7" );
534                parser.defineEntityReplacementText( "Egrave", "\u00c8" );
535                parser.defineEntityReplacementText( "Eacute", "\u00c9" );
536                parser.defineEntityReplacementText( "Ecirc", "\u00ca" );
537                parser.defineEntityReplacementText( "Euml", "\u00cb" );
538                parser.defineEntityReplacementText( "Igrave", "\u00cc" );
539                parser.defineEntityReplacementText( "Iacute", "\u00cd" );
540                parser.defineEntityReplacementText( "Icirc", "\u00ce" );
541                parser.defineEntityReplacementText( "Iuml", "\u00cf" );
542                parser.defineEntityReplacementText( "ETH", "\u00d0" );
543                parser.defineEntityReplacementText( "Ntilde", "\u00d1" );
544                parser.defineEntityReplacementText( "Ograve", "\u00d2" );
545                parser.defineEntityReplacementText( "Oacute", "\u00d3" );
546                parser.defineEntityReplacementText( "Ocirc", "\u00d4" );
547                parser.defineEntityReplacementText( "Otilde", "\u00d5" );
548                parser.defineEntityReplacementText( "Ouml", "\u00d6" );
549                parser.defineEntityReplacementText( "times", "\u00d7" );
550                parser.defineEntityReplacementText( "Oslash", "\u00d8" );
551                parser.defineEntityReplacementText( "Ugrave", "\u00d9" );
552                parser.defineEntityReplacementText( "Uacute", "\u00da" );
553                parser.defineEntityReplacementText( "Ucirc", "\u00db" );
554                parser.defineEntityReplacementText( "Uuml", "\u00dc" );
555                parser.defineEntityReplacementText( "Yacute", "\u00dd" );
556                parser.defineEntityReplacementText( "THORN", "\u00de" );
557                parser.defineEntityReplacementText( "szlig", "\u00df" );
558                parser.defineEntityReplacementText( "agrave", "\u00e0" );
559                parser.defineEntityReplacementText( "aacute", "\u00e1" );
560                parser.defineEntityReplacementText( "acirc", "\u00e2" );
561                parser.defineEntityReplacementText( "atilde", "\u00e3" );
562                parser.defineEntityReplacementText( "auml", "\u00e4" );
563                parser.defineEntityReplacementText( "aring", "\u00e5" );
564                parser.defineEntityReplacementText( "aelig", "\u00e6" );
565                parser.defineEntityReplacementText( "ccedil", "\u00e7" );
566                parser.defineEntityReplacementText( "egrave", "\u00e8" );
567                parser.defineEntityReplacementText( "eacute", "\u00e9" );
568                parser.defineEntityReplacementText( "ecirc", "\u00ea" );
569                parser.defineEntityReplacementText( "euml", "\u00eb" );
570                parser.defineEntityReplacementText( "igrave", "\u00ec" );
571                parser.defineEntityReplacementText( "iacute", "\u00ed" );
572                parser.defineEntityReplacementText( "icirc", "\u00ee" );
573                parser.defineEntityReplacementText( "iuml", "\u00ef" );
574                parser.defineEntityReplacementText( "eth", "\u00f0" );
575                parser.defineEntityReplacementText( "ntilde", "\u00f1" );
576                parser.defineEntityReplacementText( "ograve", "\u00f2" );
577                parser.defineEntityReplacementText( "oacute", "\u00f3" );
578                parser.defineEntityReplacementText( "ocirc", "\u00f4" );
579                parser.defineEntityReplacementText( "otilde", "\u00f5" );
580                parser.defineEntityReplacementText( "ouml", "\u00f6" );
581                parser.defineEntityReplacementText( "divide", "\u00f7" );
582                parser.defineEntityReplacementText( "oslash", "\u00f8" );
583                parser.defineEntityReplacementText( "ugrave", "\u00f9" );
584                parser.defineEntityReplacementText( "uacute", "\u00fa" );
585                parser.defineEntityReplacementText( "ucirc", "\u00fb" );
586                parser.defineEntityReplacementText( "uuml", "\u00fc" );
587                parser.defineEntityReplacementText( "yacute", "\u00fd" );
588                parser.defineEntityReplacementText( "thorn", "\u00fe" );
589                parser.defineEntityReplacementText( "yuml", "\u00ff" );
590    
591                // ----------------------------------------------------------------------
592                // Special entities
593                // ----------------------------------------------------------------------
594    
595                parser.defineEntityReplacementText( "OElig", "\u0152" );
596                parser.defineEntityReplacementText( "oelig", "\u0153" );
597                parser.defineEntityReplacementText( "Scaron", "\u0160" );
598                parser.defineEntityReplacementText( "scaron", "\u0161" );
599                parser.defineEntityReplacementText( "Yuml", "\u0178" );
600                parser.defineEntityReplacementText( "circ", "\u02c6" );
601                parser.defineEntityReplacementText( "tilde", "\u02dc" );
602                parser.defineEntityReplacementText( "ensp", "\u2002" );
603                parser.defineEntityReplacementText( "emsp", "\u2003" );
604                parser.defineEntityReplacementText( "thinsp", "\u2009" );
605                parser.defineEntityReplacementText( "zwnj", "\u200c" );
606                parser.defineEntityReplacementText( "zwj", "\u200d" );
607                parser.defineEntityReplacementText( "lrm", "\u200e" );
608                parser.defineEntityReplacementText( "rlm", "\u200f" );
609                parser.defineEntityReplacementText( "ndash", "\u2013" );
610                parser.defineEntityReplacementText( "mdash", "\u2014" );
611                parser.defineEntityReplacementText( "lsquo", "\u2018" );
612                parser.defineEntityReplacementText( "rsquo", "\u2019" );
613                parser.defineEntityReplacementText( "sbquo", "\u201a" );
614                parser.defineEntityReplacementText( "ldquo", "\u201c" );
615                parser.defineEntityReplacementText( "rdquo", "\u201d" );
616                parser.defineEntityReplacementText( "bdquo", "\u201e" );
617                parser.defineEntityReplacementText( "dagger", "\u2020" );
618                parser.defineEntityReplacementText( "Dagger", "\u2021" );
619                parser.defineEntityReplacementText( "permil", "\u2030" );
620                parser.defineEntityReplacementText( "lsaquo", "\u2039" );
621                parser.defineEntityReplacementText( "rsaquo", "\u203a" );
622                parser.defineEntityReplacementText( "euro", "\u20ac" );
623    
624                // ----------------------------------------------------------------------
625                // Symbol entities
626                // ----------------------------------------------------------------------
627    
628                parser.defineEntityReplacementText( "fnof", "\u0192" );
629                parser.defineEntityReplacementText( "Alpha", "\u0391" );
630                parser.defineEntityReplacementText( "Beta", "\u0392" );
631                parser.defineEntityReplacementText( "Gamma", "\u0393" );
632                parser.defineEntityReplacementText( "Delta", "\u0394" );
633                parser.defineEntityReplacementText( "Epsilon", "\u0395" );
634                parser.defineEntityReplacementText( "Zeta", "\u0396" );
635                parser.defineEntityReplacementText( "Eta", "\u0397" );
636                parser.defineEntityReplacementText( "Theta", "\u0398" );
637                parser.defineEntityReplacementText( "Iota", "\u0399" );
638                parser.defineEntityReplacementText( "Kappa", "\u039a" );
639                parser.defineEntityReplacementText( "Lambda", "\u039b" );
640                parser.defineEntityReplacementText( "Mu", "\u039c" );
641                parser.defineEntityReplacementText( "Nu", "\u039d" );
642                parser.defineEntityReplacementText( "Xi", "\u039e" );
643                parser.defineEntityReplacementText( "Omicron", "\u039f" );
644                parser.defineEntityReplacementText( "Pi", "\u03a0" );
645                parser.defineEntityReplacementText( "Rho", "\u03a1" );
646                parser.defineEntityReplacementText( "Sigma", "\u03a3" );
647                parser.defineEntityReplacementText( "Tau", "\u03a4" );
648                parser.defineEntityReplacementText( "Upsilon", "\u03a5" );
649                parser.defineEntityReplacementText( "Phi", "\u03a6" );
650                parser.defineEntityReplacementText( "Chi", "\u03a7" );
651                parser.defineEntityReplacementText( "Psi", "\u03a8" );
652                parser.defineEntityReplacementText( "Omega", "\u03a9" );
653                parser.defineEntityReplacementText( "alpha", "\u03b1" );
654                parser.defineEntityReplacementText( "beta", "\u03b2" );
655                parser.defineEntityReplacementText( "gamma", "\u03b3" );
656                parser.defineEntityReplacementText( "delta", "\u03b4" );
657                parser.defineEntityReplacementText( "epsilon", "\u03b5" );
658                parser.defineEntityReplacementText( "zeta", "\u03b6" );
659                parser.defineEntityReplacementText( "eta", "\u03b7" );
660                parser.defineEntityReplacementText( "theta", "\u03b8" );
661                parser.defineEntityReplacementText( "iota", "\u03b9" );
662                parser.defineEntityReplacementText( "kappa", "\u03ba" );
663                parser.defineEntityReplacementText( "lambda", "\u03bb" );
664                parser.defineEntityReplacementText( "mu", "\u03bc" );
665                parser.defineEntityReplacementText( "nu", "\u03bd" );
666                parser.defineEntityReplacementText( "xi", "\u03be" );
667                parser.defineEntityReplacementText( "omicron", "\u03bf" );
668                parser.defineEntityReplacementText( "pi", "\u03c0" );
669                parser.defineEntityReplacementText( "rho", "\u03c1" );
670                parser.defineEntityReplacementText( "sigmaf", "\u03c2" );
671                parser.defineEntityReplacementText( "sigma", "\u03c3" );
672                parser.defineEntityReplacementText( "tau", "\u03c4" );
673                parser.defineEntityReplacementText( "upsilon", "\u03c5" );
674                parser.defineEntityReplacementText( "phi", "\u03c6" );
675                parser.defineEntityReplacementText( "chi", "\u03c7" );
676                parser.defineEntityReplacementText( "psi", "\u03c8" );
677                parser.defineEntityReplacementText( "omega", "\u03c9" );
678                parser.defineEntityReplacementText( "thetasym", "\u03d1" );
679                parser.defineEntityReplacementText( "upsih", "\u03d2" );
680                parser.defineEntityReplacementText( "piv", "\u03d6" );
681                parser.defineEntityReplacementText( "bull", "\u2022" );
682                parser.defineEntityReplacementText( "hellip", "\u2026" );
683                parser.defineEntityReplacementText( "prime", "\u2032" );
684                parser.defineEntityReplacementText( "Prime", "\u2033" );
685                parser.defineEntityReplacementText( "oline", "\u203e" );
686                parser.defineEntityReplacementText( "frasl", "\u2044" );
687                parser.defineEntityReplacementText( "weierp", "\u2118" );
688                parser.defineEntityReplacementText( "image", "\u2111" );
689                parser.defineEntityReplacementText( "real", "\u211c" );
690                parser.defineEntityReplacementText( "trade", "\u2122" );
691                parser.defineEntityReplacementText( "alefsym", "\u2135" );
692                parser.defineEntityReplacementText( "larr", "\u2190" );
693                parser.defineEntityReplacementText( "uarr", "\u2191" );
694                parser.defineEntityReplacementText( "rarr", "\u2192" );
695                parser.defineEntityReplacementText( "darr", "\u2193" );
696                parser.defineEntityReplacementText( "harr", "\u2194" );
697                parser.defineEntityReplacementText( "crarr", "\u21b5" );
698                parser.defineEntityReplacementText( "lArr", "\u21d0" );
699                parser.defineEntityReplacementText( "uArr", "\u21d1" );
700                parser.defineEntityReplacementText( "rArr", "\u21d2" );
701                parser.defineEntityReplacementText( "dArr", "\u21d3" );
702                parser.defineEntityReplacementText( "hArr", "\u21d4" );
703                parser.defineEntityReplacementText( "forall", "\u2200" );
704                parser.defineEntityReplacementText( "part", "\u2202" );
705                parser.defineEntityReplacementText( "exist", "\u2203" );
706                parser.defineEntityReplacementText( "empty", "\u2205" );
707                parser.defineEntityReplacementText( "nabla", "\u2207" );
708                parser.defineEntityReplacementText( "isin", "\u2208" );
709                parser.defineEntityReplacementText( "notin", "\u2209" );
710                parser.defineEntityReplacementText( "ni", "\u220b" );
711                parser.defineEntityReplacementText( "prod", "\u220f" );
712                parser.defineEntityReplacementText( "sum", "\u2211" );
713                parser.defineEntityReplacementText( "minus", "\u2212" );
714                parser.defineEntityReplacementText( "lowast", "\u2217" );
715                parser.defineEntityReplacementText( "radic", "\u221a" );
716                parser.defineEntityReplacementText( "prop", "\u221d" );
717                parser.defineEntityReplacementText( "infin", "\u221e" );
718                parser.defineEntityReplacementText( "ang", "\u2220" );
719                parser.defineEntityReplacementText( "and", "\u2227" );
720                parser.defineEntityReplacementText( "or", "\u2228" );
721                parser.defineEntityReplacementText( "cap", "\u2229" );
722                parser.defineEntityReplacementText( "cup", "\u222a" );
723                parser.defineEntityReplacementText( "int", "\u222b" );
724                parser.defineEntityReplacementText( "there4", "\u2234" );
725                parser.defineEntityReplacementText( "sim", "\u223c" );
726                parser.defineEntityReplacementText( "cong", "\u2245" );
727                parser.defineEntityReplacementText( "asymp", "\u2248" );
728                parser.defineEntityReplacementText( "ne", "\u2260" );
729                parser.defineEntityReplacementText( "equiv", "\u2261" );
730                parser.defineEntityReplacementText( "le", "\u2264" );
731                parser.defineEntityReplacementText( "ge", "\u2265" );
732                parser.defineEntityReplacementText( "sub", "\u2282" );
733                parser.defineEntityReplacementText( "sup", "\u2283" );
734                parser.defineEntityReplacementText( "nsub", "\u2284" );
735                parser.defineEntityReplacementText( "sube", "\u2286" );
736                parser.defineEntityReplacementText( "supe", "\u2287" );
737                parser.defineEntityReplacementText( "oplus", "\u2295" );
738                parser.defineEntityReplacementText( "otimes", "\u2297" );
739                parser.defineEntityReplacementText( "perp", "\u22a5" );
740                parser.defineEntityReplacementText( "sdot", "\u22c5" );
741                parser.defineEntityReplacementText( "lceil", "\u2308" );
742                parser.defineEntityReplacementText( "rceil", "\u2309" );
743                parser.defineEntityReplacementText( "lfloor", "\u230a" );
744                parser.defineEntityReplacementText( "rfloor", "\u230b" );
745                parser.defineEntityReplacementText( "lang", "\u2329" );
746                parser.defineEntityReplacementText( "rang", "\u232a" );
747                parser.defineEntityReplacementText( "loz", "\u25ca" );
748                parser.defineEntityReplacementText( "spades", "\u2660" );
749                parser.defineEntityReplacementText( "clubs", "\u2663" );
750                parser.defineEntityReplacementText( "hearts", "\u2665" );
751                parser.defineEntityReplacementText( "diams", "\u2666" );
752    
753            }
754        } //-- void initParser( XmlPullParser )
755    
756        /**
757         * Method nextTag.
758         * 
759         * @param parser
760         * @throws IOException
761         * @throws XmlPullParserException
762         * @return int
763         */
764        private int nextTag( XmlPullParser parser )
765            throws IOException, XmlPullParserException
766        {
767            int eventType = parser.next();
768            if ( eventType == XmlPullParser.TEXT )
769            {
770                eventType = parser.next();
771            }
772            if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
773            {
774                throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
775            }
776            return eventType;
777        } //-- int nextTag( XmlPullParser )
778    
779        /**
780         * Method parsePersistedToolchains.
781         * 
782         * @param parser
783         * @param strict
784         * @throws IOException
785         * @throws XmlPullParserException
786         * @return PersistedToolchains
787         */
788        private PersistedToolchains parsePersistedToolchains( XmlPullParser parser, boolean strict )
789            throws IOException, XmlPullParserException
790        {
791            String tagName = parser.getName();
792            PersistedToolchains persistedToolchains = new PersistedToolchains();
793            for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
794            {
795                String name = parser.getAttributeName( i );
796                String value = parser.getAttributeValue( i );
797    
798                if ( name.indexOf( ':' ) >= 0 )
799                {
800                    // just ignore attributes with non-default namespace (for example: xmlns:xsi)
801                }
802                else if ( "xmlns".equals( name ) )
803                {
804                    // ignore xmlns attribute in root class, which is a reserved attribute name
805                }
806                else
807                {
808                    checkUnknownAttribute( parser, name, tagName, strict );
809                }
810            }
811            java.util.Set parsed = new java.util.HashSet();
812            while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
813            {
814                if ( "toolchain".equals( parser.getName() ) )
815                {
816                    java.util.List toolchains = persistedToolchains.getToolchains();
817                    if ( toolchains == null )
818                    {
819                        toolchains = new java.util.ArrayList/*<ToolchainModel>*/();
820                        persistedToolchains.setToolchains( toolchains );
821                    }
822                    toolchains.add( parseToolchainModel( parser, strict ) );
823                }
824                else
825                {
826                    checkUnknownElement( parser, strict );
827                }
828            }
829            return persistedToolchains;
830        } //-- PersistedToolchains parsePersistedToolchains( XmlPullParser, boolean )
831    
832        /**
833         * Method parseToolchainModel.
834         * 
835         * @param parser
836         * @param strict
837         * @throws IOException
838         * @throws XmlPullParserException
839         * @return ToolchainModel
840         */
841        private ToolchainModel parseToolchainModel( XmlPullParser parser, boolean strict )
842            throws IOException, XmlPullParserException
843        {
844            String tagName = parser.getName();
845            ToolchainModel toolchainModel = new ToolchainModel();
846            for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
847            {
848                String name = parser.getAttributeName( i );
849                String value = parser.getAttributeValue( i );
850    
851                if ( name.indexOf( ':' ) >= 0 )
852                {
853                    // just ignore attributes with non-default namespace (for example: xmlns:xsi)
854                }
855                else
856                {
857                    checkUnknownAttribute( parser, name, tagName, strict );
858                }
859            }
860            java.util.Set parsed = new java.util.HashSet();
861            while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
862            {
863                if ( checkFieldWithDuplicate( parser, "type", null, parsed ) )
864                {
865                    toolchainModel.setType( getTrimmedValue( parser.nextText() ) );
866                }
867                else if ( checkFieldWithDuplicate( parser, "provides", null, parsed ) )
868                {
869                    toolchainModel.setProvides( Xpp3DomBuilder.build( parser ) );
870                }
871                else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
872                {
873                    toolchainModel.setConfiguration( Xpp3DomBuilder.build( parser ) );
874                }
875                else
876                {
877                    checkUnknownElement( parser, strict );
878                }
879            }
880            return toolchainModel;
881        } //-- ToolchainModel parseToolchainModel( XmlPullParser, boolean )
882    
883        /**
884         * @see ReaderFactory#newXmlReader
885         * 
886         * @param reader
887         * @param strict
888         * @throws IOException
889         * @throws XmlPullParserException
890         * @return PersistedToolchains
891         */
892        public PersistedToolchains read( Reader reader, boolean strict )
893            throws IOException, XmlPullParserException
894        {
895            XmlPullParser parser = new MXParser();
896    
897            parser.setInput( reader );
898    
899            initParser( parser );
900    
901            return read( parser, strict );
902        } //-- PersistedToolchains read( Reader, boolean )
903    
904        /**
905         * @see ReaderFactory#newXmlReader
906         * 
907         * @param reader
908         * @throws IOException
909         * @throws XmlPullParserException
910         * @return PersistedToolchains
911         */
912        public PersistedToolchains read( Reader reader )
913            throws IOException, XmlPullParserException
914        {
915            return read( reader, true );
916        } //-- PersistedToolchains read( Reader )
917    
918        /**
919         * Method read.
920         * 
921         * @param in
922         * @param strict
923         * @throws IOException
924         * @throws XmlPullParserException
925         * @return PersistedToolchains
926         */
927        public PersistedToolchains read( InputStream in, boolean strict )
928            throws IOException, XmlPullParserException
929        {
930            return read( ReaderFactory.newXmlReader( in ), strict );
931        } //-- PersistedToolchains read( InputStream, boolean )
932    
933        /**
934         * Method read.
935         * 
936         * @param in
937         * @throws IOException
938         * @throws XmlPullParserException
939         * @return PersistedToolchains
940         */
941        public PersistedToolchains read( InputStream in )
942            throws IOException, XmlPullParserException
943        {
944            return read( ReaderFactory.newXmlReader( in ) );
945        } //-- PersistedToolchains read( InputStream )
946    
947        /**
948         * Method read.
949         * 
950         * @param parser
951         * @param strict
952         * @throws IOException
953         * @throws XmlPullParserException
954         * @return PersistedToolchains
955         */
956        private PersistedToolchains read( XmlPullParser parser, boolean strict )
957            throws IOException, XmlPullParserException
958        {
959            int eventType = parser.getEventType();
960            while ( eventType != XmlPullParser.END_DOCUMENT )
961            {
962                if ( eventType == XmlPullParser.START_TAG )
963                {
964                    if ( strict && ! "toolchains".equals( parser.getName() ) )
965                    {
966                        throw new XmlPullParserException( "Expected root element 'toolchains' but found '" + parser.getName() + "'", parser, null );
967                    }
968                    PersistedToolchains persistedToolchains = parsePersistedToolchains( parser, strict );
969                    persistedToolchains.setModelEncoding( parser.getInputEncoding() );
970                    return persistedToolchains;
971                }
972                eventType = parser.next();
973            }
974            throw new XmlPullParserException( "Expected root element 'toolchains' but found no element at all: invalid XML document", parser, null );
975        } //-- PersistedToolchains read( XmlPullParser, boolean )
976    
977        /**
978         * Sets the state of the "add default entities" flag.
979         * 
980         * @param addDefaultEntities
981         */
982        public void setAddDefaultEntities( boolean addDefaultEntities )
983        {
984            this.addDefaultEntities = addDefaultEntities;
985        } //-- void setAddDefaultEntities( boolean )
986    
987    }