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