View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.scm.providers.vss.settings.io.xpp3;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.io.IOException;
12  import java.io.InputStream;
13  import java.io.Reader;
14  import java.text.DateFormat;
15  import java.util.Locale;
16  import org.apache.maven.scm.providers.vss.settings.Settings;
17  import org.codehaus.plexus.util.ReaderFactory;
18  import org.codehaus.plexus.util.xml.pull.MXParser;
19  import org.codehaus.plexus.util.xml.pull.XmlPullParser;
20  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
21  
22  /**
23   * Class VssXpp3Reader.
24   * 
25   * @version $Revision$ $Date$
26   */
27  public class VssXpp3Reader {
28  
29  
30        //--------------------------/
31       //- Class/Member Variables -/
32      //--------------------------/
33  
34      /**
35       * If set the parser will be loaded with all single characters
36       * from the XHTML specification.
37       * The entities used:
38       * <ul>
39       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
40       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
41       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
42       * </ul>
43       */
44      private boolean addDefaultEntities = true;
45  
46  
47        //-----------/
48       //- Methods -/
49      //-----------/
50  
51      /**
52       * Returns the state of the "add default entities" flag.
53       * 
54       * @return boolean
55       */
56      public boolean getAddDefaultEntities()
57      {
58          return addDefaultEntities;
59      } //-- boolean getAddDefaultEntities() 
60  
61      /**
62       * Method getBooleanValue.
63       * 
64       * @param s
65       * @param parser
66       * @param attribute
67       * @throws XmlPullParserException
68       * @return boolean
69       */
70      public boolean getBooleanValue(String s, String attribute, XmlPullParser parser)
71          throws XmlPullParserException
72      {
73          return getBooleanValue( s, attribute, parser, null );
74      } //-- boolean getBooleanValue(String, String, XmlPullParser) 
75  
76      /**
77       * Method getBooleanValue.
78       * 
79       * @param s
80       * @param defaultValue
81       * @param parser
82       * @param attribute
83       * @throws XmlPullParserException
84       * @return boolean
85       */
86      public boolean getBooleanValue(String s, String attribute, XmlPullParser parser, String defaultValue)
87          throws XmlPullParserException
88      {
89          if ( s != null && s.length() != 0 )
90          {
91              return Boolean.valueOf( s ).booleanValue();
92          }
93          if ( defaultValue != null )
94          {
95              return Boolean.valueOf( defaultValue ).booleanValue();
96          }
97          return false;
98      } //-- boolean getBooleanValue(String, String, XmlPullParser, String) 
99  
100     /**
101      * Method getCharacterValue.
102      * 
103      * @param s
104      * @param parser
105      * @param attribute
106      * @throws XmlPullParserException
107      * @return char
108      */
109     public char getCharacterValue(String s, String attribute, XmlPullParser parser)
110         throws XmlPullParserException
111     {
112         if ( s != null )
113         {
114             return s.charAt( 0 );
115         }
116         return 0;
117     } //-- char getCharacterValue(String, String, XmlPullParser) 
118 
119     /**
120      * Method getDateValue.
121      * 
122      * @param s
123      * @param parser
124      * @param attribute
125      * @throws XmlPullParserException
126      * @return java.util.Date
127      */
128     public java.util.Date getDateValue(String s, String attribute, XmlPullParser parser)
129         throws XmlPullParserException
130     {
131         return getDateValue( s, attribute, null, parser );
132     } //-- java.util.Date getDateValue(String, String, XmlPullParser) 
133 
134     /**
135      * Method getDateValue.
136      * 
137      * @param s
138      * @param parser
139      * @param dateFormat
140      * @param attribute
141      * @throws XmlPullParserException
142      * @return java.util.Date
143      */
144     public java.util.Date getDateValue(String s, String attribute, String dateFormat, XmlPullParser parser)
145         throws XmlPullParserException
146     {
147         if ( s != null )
148         {
149             if ( dateFormat == null )
150             {
151                 return new java.util.Date( Long.valueOf( s ).longValue() );
152             }
153             else
154             {
155                 DateFormat dateParser = new java.text.SimpleDateFormat( dateFormat, Locale.US );
156                 try
157                 {
158                     return dateParser.parse( s );
159                 }
160                 catch ( java.text.ParseException e )
161                 {
162                     throw new XmlPullParserException( e.getMessage() );
163                 }
164             }
165         }
166         return null;
167     } //-- java.util.Date getDateValue(String, String, String, XmlPullParser) 
168 
169     /**
170      * Method getDoubleValue.
171      * 
172      * @param s
173      * @param strict
174      * @param parser
175      * @param attribute
176      * @throws XmlPullParserException
177      * @return double
178      */
179     public double getDoubleValue(String s, String attribute, XmlPullParser parser, boolean strict)
180         throws XmlPullParserException
181     {
182         if ( s != null )
183         {
184             try
185             {
186                 return Double.valueOf( s ).doubleValue();
187             }
188             catch ( NumberFormatException e )
189             {
190                 if ( strict )
191                 {
192                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, null );
193                 }
194             }
195         }
196         return 0;
197     } //-- double getDoubleValue(String, String, XmlPullParser, boolean) 
198 
199     /**
200      * Method getFloatValue.
201      * 
202      * @param s
203      * @param strict
204      * @param parser
205      * @param attribute
206      * @throws XmlPullParserException
207      * @return float
208      */
209     public float getFloatValue(String s, String attribute, XmlPullParser parser, boolean strict)
210         throws XmlPullParserException
211     {
212         if ( s != null )
213         {
214             try
215             {
216                 return Float.valueOf( s ).floatValue();
217             }
218             catch ( NumberFormatException e )
219             {
220                 if ( strict )
221                 {
222                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, null );
223                 }
224             }
225         }
226         return 0;
227     } //-- float getFloatValue(String, String, XmlPullParser, boolean) 
228 
229     /**
230      * Method getIntegerValue.
231      * 
232      * @param s
233      * @param strict
234      * @param parser
235      * @param attribute
236      * @throws XmlPullParserException
237      * @return int
238      */
239     public int getIntegerValue(String s, String attribute, XmlPullParser parser, boolean strict)
240         throws XmlPullParserException
241     {
242         if ( s != null )
243         {
244             try
245             {
246                 return Integer.valueOf( s ).intValue();
247             }
248             catch ( NumberFormatException e )
249             {
250                 if ( strict )
251                 {
252                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, null );
253                 }
254             }
255         }
256         return 0;
257     } //-- int getIntegerValue(String, String, XmlPullParser, boolean) 
258 
259     /**
260      * Method getLongValue.
261      * 
262      * @param s
263      * @param strict
264      * @param parser
265      * @param attribute
266      * @throws XmlPullParserException
267      * @return long
268      */
269     public long getLongValue(String s, String attribute, XmlPullParser parser, boolean strict)
270         throws XmlPullParserException
271     {
272         if ( s != null )
273         {
274             try
275             {
276                 return Long.valueOf( s ).longValue();
277             }
278             catch ( NumberFormatException e )
279             {
280                 if ( strict )
281                 {
282                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, null );
283                 }
284             }
285         }
286         return 0;
287     } //-- long getLongValue(String, String, XmlPullParser, boolean) 
288 
289     /**
290      * Method getRequiredAttributeValue.
291      * 
292      * @param s
293      * @param strict
294      * @param parser
295      * @param attribute
296      * @throws XmlPullParserException
297      * @return String
298      */
299     public String getRequiredAttributeValue(String s, String attribute, XmlPullParser parser, boolean strict)
300         throws XmlPullParserException
301     {
302         if ( s == null )
303         {
304             if ( strict )
305             {
306                 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
307             }
308         }
309         return s;
310     } //-- String getRequiredAttributeValue(String, String, XmlPullParser, boolean) 
311 
312     /**
313      * Method getShortValue.
314      * 
315      * @param s
316      * @param strict
317      * @param parser
318      * @param attribute
319      * @throws XmlPullParserException
320      * @return short
321      */
322     public short getShortValue(String s, String attribute, XmlPullParser parser, boolean strict)
323         throws XmlPullParserException
324     {
325         if ( s != null )
326         {
327             try
328             {
329                 return Short.valueOf( s ).shortValue();
330             }
331             catch ( NumberFormatException e )
332             {
333                 if ( strict )
334                 {
335                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, null );
336                 }
337             }
338         }
339         return 0;
340     } //-- short getShortValue(String, String, XmlPullParser, boolean) 
341 
342     /**
343      * Method getTrimmedValue.
344      * 
345      * @param s
346      * @return String
347      */
348     public String getTrimmedValue(String s)
349     {
350         if ( s != null )
351         {
352             s = s.trim();
353         }
354         return s;
355     } //-- String getTrimmedValue(String) 
356 
357     /**
358      * Method parseSettings.
359      * 
360      * @param tagName
361      * @param strict
362      * @param parser
363      * @throws IOException
364      * @throws XmlPullParserException
365      * @return Settings
366      */
367     private Settings parseSettings(String tagName, XmlPullParser parser, boolean strict)
368         throws IOException, XmlPullParserException
369     {
370         Settings settings = new Settings();
371         java.util.Set parsed = new java.util.HashSet();
372         int eventType = parser.getEventType();
373         boolean foundRoot = false;
374         while ( eventType != XmlPullParser.END_DOCUMENT )
375         {
376             if ( eventType == XmlPullParser.START_TAG )
377             {
378                 if ( parser.getName().equals( tagName ) )
379                 {
380                     foundRoot = true;
381                 }
382                 else if ( parser.getName().equals( "vssDirectory" )  )
383                 {
384                     if ( parsed.contains( "vssDirectory" ) )
385                     {
386                         throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null );
387                     }
388                     parsed.add( "vssDirectory" );
389                     settings.setVssDirectory( getTrimmedValue( parser.nextText()) );
390                 }
391                 else if ( !foundRoot && strict )
392                 {
393                     throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
394                 }
395             }
396             eventType = parser.next();
397         }
398         return settings;
399     } //-- Settings parseSettings(String, XmlPullParser, boolean) 
400 
401     /**
402      * @see ReaderFactory#newXmlReader
403      * 
404      * @param reader
405      * @param strict
406      * @throws IOException
407      * @throws XmlPullParserException
408      * @return Settings
409      */
410     public Settings read(Reader reader, boolean strict)
411         throws IOException, XmlPullParserException
412     {
413         XmlPullParser parser = new MXParser();
414         
415         parser.setInput( reader );
416         
417         if ( addDefaultEntities ) 
418         {
419             // ----------------------------------------------------------------------
420             // Latin 1 entities
421             // ----------------------------------------------------------------------
422             
423             parser.defineEntityReplacementText( "nbsp", "\u00a0" ); 
424             parser.defineEntityReplacementText( "iexcl", "\u00a1" ); 
425             parser.defineEntityReplacementText( "cent", "\u00a2" ); 
426             parser.defineEntityReplacementText( "pound", "\u00a3" ); 
427             parser.defineEntityReplacementText( "curren", "\u00a4" ); 
428             parser.defineEntityReplacementText( "yen", "\u00a5" ); 
429             parser.defineEntityReplacementText( "brvbar", "\u00a6" ); 
430             parser.defineEntityReplacementText( "sect", "\u00a7" ); 
431             parser.defineEntityReplacementText( "uml", "\u00a8" ); 
432             parser.defineEntityReplacementText( "copy", "\u00a9" ); 
433             parser.defineEntityReplacementText( "ordf", "\u00aa" ); 
434             parser.defineEntityReplacementText( "laquo", "\u00ab" ); 
435             parser.defineEntityReplacementText( "not", "\u00ac" ); 
436             parser.defineEntityReplacementText( "shy", "\u00ad" ); 
437             parser.defineEntityReplacementText( "reg", "\u00ae" ); 
438             parser.defineEntityReplacementText( "macr", "\u00af" ); 
439             parser.defineEntityReplacementText( "deg", "\u00b0" ); 
440             parser.defineEntityReplacementText( "plusmn", "\u00b1" ); 
441             parser.defineEntityReplacementText( "sup2", "\u00b2" ); 
442             parser.defineEntityReplacementText( "sup3", "\u00b3" ); 
443             parser.defineEntityReplacementText( "acute", "\u00b4" ); 
444             parser.defineEntityReplacementText( "micro", "\u00b5" ); 
445             parser.defineEntityReplacementText( "para", "\u00b6" ); 
446             parser.defineEntityReplacementText( "middot", "\u00b7" ); 
447             parser.defineEntityReplacementText( "cedil", "\u00b8" ); 
448             parser.defineEntityReplacementText( "sup1", "\u00b9" ); 
449             parser.defineEntityReplacementText( "ordm", "\u00ba" ); 
450             parser.defineEntityReplacementText( "raquo", "\u00bb" ); 
451             parser.defineEntityReplacementText( "frac14", "\u00bc" ); 
452             parser.defineEntityReplacementText( "frac12", "\u00bd" ); 
453             parser.defineEntityReplacementText( "frac34", "\u00be" ); 
454             parser.defineEntityReplacementText( "iquest", "\u00bf" ); 
455             parser.defineEntityReplacementText( "Agrave", "\u00c0" ); 
456             parser.defineEntityReplacementText( "Aacute", "\u00c1" ); 
457             parser.defineEntityReplacementText( "Acirc", "\u00c2" ); 
458             parser.defineEntityReplacementText( "Atilde", "\u00c3" ); 
459             parser.defineEntityReplacementText( "Auml", "\u00c4" ); 
460             parser.defineEntityReplacementText( "Aring", "\u00c5" ); 
461             parser.defineEntityReplacementText( "AElig", "\u00c6" ); 
462             parser.defineEntityReplacementText( "Ccedil", "\u00c7" ); 
463             parser.defineEntityReplacementText( "Egrave", "\u00c8" ); 
464             parser.defineEntityReplacementText( "Eacute", "\u00c9" ); 
465             parser.defineEntityReplacementText( "Ecirc", "\u00ca" ); 
466             parser.defineEntityReplacementText( "Euml", "\u00cb" ); 
467             parser.defineEntityReplacementText( "Igrave", "\u00cc" ); 
468             parser.defineEntityReplacementText( "Iacute", "\u00cd" ); 
469             parser.defineEntityReplacementText( "Icirc", "\u00ce" ); 
470             parser.defineEntityReplacementText( "Iuml", "\u00cf" ); 
471             parser.defineEntityReplacementText( "ETH", "\u00d0" ); 
472             parser.defineEntityReplacementText( "Ntilde", "\u00d1" ); 
473             parser.defineEntityReplacementText( "Ograve", "\u00d2" ); 
474             parser.defineEntityReplacementText( "Oacute", "\u00d3" ); 
475             parser.defineEntityReplacementText( "Ocirc", "\u00d4" ); 
476             parser.defineEntityReplacementText( "Otilde", "\u00d5" ); 
477             parser.defineEntityReplacementText( "Ouml", "\u00d6" ); 
478             parser.defineEntityReplacementText( "times", "\u00d7" ); 
479             parser.defineEntityReplacementText( "Oslash", "\u00d8" ); 
480             parser.defineEntityReplacementText( "Ugrave", "\u00d9" ); 
481             parser.defineEntityReplacementText( "Uacute", "\u00da" ); 
482             parser.defineEntityReplacementText( "Ucirc", "\u00db" ); 
483             parser.defineEntityReplacementText( "Uuml", "\u00dc" ); 
484             parser.defineEntityReplacementText( "Yacute", "\u00dd" ); 
485             parser.defineEntityReplacementText( "THORN", "\u00de" ); 
486             parser.defineEntityReplacementText( "szlig", "\u00df" ); 
487             parser.defineEntityReplacementText( "agrave", "\u00e0" ); 
488             parser.defineEntityReplacementText( "aacute", "\u00e1" ); 
489             parser.defineEntityReplacementText( "acirc", "\u00e2" ); 
490             parser.defineEntityReplacementText( "atilde", "\u00e3" ); 
491             parser.defineEntityReplacementText( "auml", "\u00e4" ); 
492             parser.defineEntityReplacementText( "aring", "\u00e5" ); 
493             parser.defineEntityReplacementText( "aelig", "\u00e6" ); 
494             parser.defineEntityReplacementText( "ccedil", "\u00e7" ); 
495             parser.defineEntityReplacementText( "egrave", "\u00e8" ); 
496             parser.defineEntityReplacementText( "eacute", "\u00e9" ); 
497             parser.defineEntityReplacementText( "ecirc", "\u00ea" ); 
498             parser.defineEntityReplacementText( "euml", "\u00eb" ); 
499             parser.defineEntityReplacementText( "igrave", "\u00ec" ); 
500             parser.defineEntityReplacementText( "iacute", "\u00ed" ); 
501             parser.defineEntityReplacementText( "icirc", "\u00ee" ); 
502             parser.defineEntityReplacementText( "iuml", "\u00ef" ); 
503             parser.defineEntityReplacementText( "eth", "\u00f0" ); 
504             parser.defineEntityReplacementText( "ntilde", "\u00f1" ); 
505             parser.defineEntityReplacementText( "ograve", "\u00f2" ); 
506             parser.defineEntityReplacementText( "oacute", "\u00f3" ); 
507             parser.defineEntityReplacementText( "ocirc", "\u00f4" ); 
508             parser.defineEntityReplacementText( "otilde", "\u00f5" ); 
509             parser.defineEntityReplacementText( "ouml", "\u00f6" ); 
510             parser.defineEntityReplacementText( "divide", "\u00f7" ); 
511             parser.defineEntityReplacementText( "oslash", "\u00f8" ); 
512             parser.defineEntityReplacementText( "ugrave", "\u00f9" ); 
513             parser.defineEntityReplacementText( "uacute", "\u00fa" ); 
514             parser.defineEntityReplacementText( "ucirc", "\u00fb" ); 
515             parser.defineEntityReplacementText( "uuml", "\u00fc" ); 
516             parser.defineEntityReplacementText( "yacute", "\u00fd" ); 
517             parser.defineEntityReplacementText( "thorn", "\u00fe" ); 
518             parser.defineEntityReplacementText( "yuml", "\u00ff" ); 
519             
520             // ----------------------------------------------------------------------
521             // Special entities
522             // ----------------------------------------------------------------------
523             
524             parser.defineEntityReplacementText( "OElig", "\u0152" ); 
525             parser.defineEntityReplacementText( "oelig", "\u0153" ); 
526             parser.defineEntityReplacementText( "Scaron", "\u0160" ); 
527             parser.defineEntityReplacementText( "scaron", "\u0161" ); 
528             parser.defineEntityReplacementText( "Yuml", "\u0178" ); 
529             parser.defineEntityReplacementText( "circ", "\u02c6" ); 
530             parser.defineEntityReplacementText( "tilde", "\u02dc" ); 
531             parser.defineEntityReplacementText( "ensp", "\u2002" ); 
532             parser.defineEntityReplacementText( "emsp", "\u2003" ); 
533             parser.defineEntityReplacementText( "thinsp", "\u2009" ); 
534             parser.defineEntityReplacementText( "zwnj", "\u200c" ); 
535             parser.defineEntityReplacementText( "zwj", "\u200d" ); 
536             parser.defineEntityReplacementText( "lrm", "\u200e" ); 
537             parser.defineEntityReplacementText( "rlm", "\u200f" ); 
538             parser.defineEntityReplacementText( "ndash", "\u2013" ); 
539             parser.defineEntityReplacementText( "mdash", "\u2014" ); 
540             parser.defineEntityReplacementText( "lsquo", "\u2018" ); 
541             parser.defineEntityReplacementText( "rsquo", "\u2019" ); 
542             parser.defineEntityReplacementText( "sbquo", "\u201a" ); 
543             parser.defineEntityReplacementText( "ldquo", "\u201c" ); 
544             parser.defineEntityReplacementText( "rdquo", "\u201d" ); 
545             parser.defineEntityReplacementText( "bdquo", "\u201e" ); 
546             parser.defineEntityReplacementText( "dagger", "\u2020" ); 
547             parser.defineEntityReplacementText( "Dagger", "\u2021" ); 
548             parser.defineEntityReplacementText( "permil", "\u2030" ); 
549             parser.defineEntityReplacementText( "lsaquo", "\u2039" ); 
550             parser.defineEntityReplacementText( "rsaquo", "\u203a" ); 
551             parser.defineEntityReplacementText( "euro", "\u20ac" ); 
552             
553             // ----------------------------------------------------------------------
554             // Symbol entities
555             // ----------------------------------------------------------------------
556             
557             parser.defineEntityReplacementText( "fnof", "\u0192" ); 
558             parser.defineEntityReplacementText( "Alpha", "\u0391" ); 
559             parser.defineEntityReplacementText( "Beta", "\u0392" ); 
560             parser.defineEntityReplacementText( "Gamma", "\u0393" ); 
561             parser.defineEntityReplacementText( "Delta", "\u0394" ); 
562             parser.defineEntityReplacementText( "Epsilon", "\u0395" ); 
563             parser.defineEntityReplacementText( "Zeta", "\u0396" ); 
564             parser.defineEntityReplacementText( "Eta", "\u0397" ); 
565             parser.defineEntityReplacementText( "Theta", "\u0398" ); 
566             parser.defineEntityReplacementText( "Iota", "\u0399" ); 
567             parser.defineEntityReplacementText( "Kappa", "\u039a" ); 
568             parser.defineEntityReplacementText( "Lambda", "\u039b" ); 
569             parser.defineEntityReplacementText( "Mu", "\u039c" ); 
570             parser.defineEntityReplacementText( "Nu", "\u039d" ); 
571             parser.defineEntityReplacementText( "Xi", "\u039e" ); 
572             parser.defineEntityReplacementText( "Omicron", "\u039f" ); 
573             parser.defineEntityReplacementText( "Pi", "\u03a0" ); 
574             parser.defineEntityReplacementText( "Rho", "\u03a1" ); 
575             parser.defineEntityReplacementText( "Sigma", "\u03a3" ); 
576             parser.defineEntityReplacementText( "Tau", "\u03a4" ); 
577             parser.defineEntityReplacementText( "Upsilon", "\u03a5" ); 
578             parser.defineEntityReplacementText( "Phi", "\u03a6" ); 
579             parser.defineEntityReplacementText( "Chi", "\u03a7" ); 
580             parser.defineEntityReplacementText( "Psi", "\u03a8" ); 
581             parser.defineEntityReplacementText( "Omega", "\u03a9" ); 
582             parser.defineEntityReplacementText( "alpha", "\u03b1" ); 
583             parser.defineEntityReplacementText( "beta", "\u03b2" ); 
584             parser.defineEntityReplacementText( "gamma", "\u03b3" ); 
585             parser.defineEntityReplacementText( "delta", "\u03b4" ); 
586             parser.defineEntityReplacementText( "epsilon", "\u03b5" ); 
587             parser.defineEntityReplacementText( "zeta", "\u03b6" ); 
588             parser.defineEntityReplacementText( "eta", "\u03b7" ); 
589             parser.defineEntityReplacementText( "theta", "\u03b8" ); 
590             parser.defineEntityReplacementText( "iota", "\u03b9" ); 
591             parser.defineEntityReplacementText( "kappa", "\u03ba" ); 
592             parser.defineEntityReplacementText( "lambda", "\u03bb" ); 
593             parser.defineEntityReplacementText( "mu", "\u03bc" ); 
594             parser.defineEntityReplacementText( "nu", "\u03bd" ); 
595             parser.defineEntityReplacementText( "xi", "\u03be" ); 
596             parser.defineEntityReplacementText( "omicron", "\u03bf" ); 
597             parser.defineEntityReplacementText( "pi", "\u03c0" ); 
598             parser.defineEntityReplacementText( "rho", "\u03c1" ); 
599             parser.defineEntityReplacementText( "sigmaf", "\u03c2" ); 
600             parser.defineEntityReplacementText( "sigma", "\u03c3" ); 
601             parser.defineEntityReplacementText( "tau", "\u03c4" ); 
602             parser.defineEntityReplacementText( "upsilon", "\u03c5" ); 
603             parser.defineEntityReplacementText( "phi", "\u03c6" ); 
604             parser.defineEntityReplacementText( "chi", "\u03c7" ); 
605             parser.defineEntityReplacementText( "psi", "\u03c8" ); 
606             parser.defineEntityReplacementText( "omega", "\u03c9" ); 
607             parser.defineEntityReplacementText( "thetasym", "\u03d1" ); 
608             parser.defineEntityReplacementText( "upsih", "\u03d2" ); 
609             parser.defineEntityReplacementText( "piv", "\u03d6" ); 
610             parser.defineEntityReplacementText( "bull", "\u2022" ); 
611             parser.defineEntityReplacementText( "hellip", "\u2026" ); 
612             parser.defineEntityReplacementText( "prime", "\u2032" ); 
613             parser.defineEntityReplacementText( "Prime", "\u2033" ); 
614             parser.defineEntityReplacementText( "oline", "\u203e" ); 
615             parser.defineEntityReplacementText( "frasl", "\u2044" ); 
616             parser.defineEntityReplacementText( "weierp", "\u2118" ); 
617             parser.defineEntityReplacementText( "image", "\u2111" ); 
618             parser.defineEntityReplacementText( "real", "\u211c" ); 
619             parser.defineEntityReplacementText( "trade", "\u2122" ); 
620             parser.defineEntityReplacementText( "alefsym", "\u2135" ); 
621             parser.defineEntityReplacementText( "larr", "\u2190" ); 
622             parser.defineEntityReplacementText( "uarr", "\u2191" ); 
623             parser.defineEntityReplacementText( "rarr", "\u2192" ); 
624             parser.defineEntityReplacementText( "darr", "\u2193" ); 
625             parser.defineEntityReplacementText( "harr", "\u2194" ); 
626             parser.defineEntityReplacementText( "crarr", "\u21b5" ); 
627             parser.defineEntityReplacementText( "lArr", "\u21d0" ); 
628             parser.defineEntityReplacementText( "uArr", "\u21d1" ); 
629             parser.defineEntityReplacementText( "rArr", "\u21d2" ); 
630             parser.defineEntityReplacementText( "dArr", "\u21d3" ); 
631             parser.defineEntityReplacementText( "hArr", "\u21d4" ); 
632             parser.defineEntityReplacementText( "forall", "\u2200" ); 
633             parser.defineEntityReplacementText( "part", "\u2202" ); 
634             parser.defineEntityReplacementText( "exist", "\u2203" ); 
635             parser.defineEntityReplacementText( "empty", "\u2205" ); 
636             parser.defineEntityReplacementText( "nabla", "\u2207" ); 
637             parser.defineEntityReplacementText( "isin", "\u2208" ); 
638             parser.defineEntityReplacementText( "notin", "\u2209" ); 
639             parser.defineEntityReplacementText( "ni", "\u220b" ); 
640             parser.defineEntityReplacementText( "prod", "\u220f" ); 
641             parser.defineEntityReplacementText( "sum", "\u2211" ); 
642             parser.defineEntityReplacementText( "minus", "\u2212" ); 
643             parser.defineEntityReplacementText( "lowast", "\u2217" ); 
644             parser.defineEntityReplacementText( "radic", "\u221a" ); 
645             parser.defineEntityReplacementText( "prop", "\u221d" ); 
646             parser.defineEntityReplacementText( "infin", "\u221e" ); 
647             parser.defineEntityReplacementText( "ang", "\u2220" ); 
648             parser.defineEntityReplacementText( "and", "\u2227" ); 
649             parser.defineEntityReplacementText( "or", "\u2228" ); 
650             parser.defineEntityReplacementText( "cap", "\u2229" ); 
651             parser.defineEntityReplacementText( "cup", "\u222a" ); 
652             parser.defineEntityReplacementText( "int", "\u222b" ); 
653             parser.defineEntityReplacementText( "there4", "\u2234" ); 
654             parser.defineEntityReplacementText( "sim", "\u223c" ); 
655             parser.defineEntityReplacementText( "cong", "\u2245" ); 
656             parser.defineEntityReplacementText( "asymp", "\u2248" ); 
657             parser.defineEntityReplacementText( "ne", "\u2260" ); 
658             parser.defineEntityReplacementText( "equiv", "\u2261" ); 
659             parser.defineEntityReplacementText( "le", "\u2264" ); 
660             parser.defineEntityReplacementText( "ge", "\u2265" ); 
661             parser.defineEntityReplacementText( "sub", "\u2282" ); 
662             parser.defineEntityReplacementText( "sup", "\u2283" ); 
663             parser.defineEntityReplacementText( "nsub", "\u2284" ); 
664             parser.defineEntityReplacementText( "sube", "\u2286" ); 
665             parser.defineEntityReplacementText( "supe", "\u2287" ); 
666             parser.defineEntityReplacementText( "oplus", "\u2295" ); 
667             parser.defineEntityReplacementText( "otimes", "\u2297" ); 
668             parser.defineEntityReplacementText( "perp", "\u22a5" ); 
669             parser.defineEntityReplacementText( "sdot", "\u22c5" ); 
670             parser.defineEntityReplacementText( "lceil", "\u2308" ); 
671             parser.defineEntityReplacementText( "rceil", "\u2309" ); 
672             parser.defineEntityReplacementText( "lfloor", "\u230a" ); 
673             parser.defineEntityReplacementText( "rfloor", "\u230b" ); 
674             parser.defineEntityReplacementText( "lang", "\u2329" ); 
675             parser.defineEntityReplacementText( "rang", "\u232a" ); 
676             parser.defineEntityReplacementText( "loz", "\u25ca" ); 
677             parser.defineEntityReplacementText( "spades", "\u2660" ); 
678             parser.defineEntityReplacementText( "clubs", "\u2663" ); 
679             parser.defineEntityReplacementText( "hearts", "\u2665" ); 
680             parser.defineEntityReplacementText( "diams", "\u2666" ); 
681             
682         }
683         
684         parser.next();
685         return parseSettings( "vss-settings", parser, strict );
686     } //-- Settings read(Reader, boolean) 
687 
688     /**
689      * @see ReaderFactory#newXmlReader
690      * 
691      * @param reader
692      * @throws IOException
693      * @throws XmlPullParserException
694      * @return Settings
695      */
696     public Settings read(Reader reader)
697         throws IOException, XmlPullParserException
698     {
699         return read( reader, true );
700     } //-- Settings read(Reader) 
701 
702     /**
703      * Method read.
704      * 
705      * @param in
706      * @param strict
707      * @throws IOException
708      * @throws XmlPullParserException
709      * @return Settings
710      */
711     public Settings read(InputStream in, boolean strict)
712         throws IOException, XmlPullParserException
713     {
714         Reader reader = ReaderFactory.newXmlReader( in );
715         
716         return read( reader, strict );
717     } //-- Settings read(InputStream, boolean) 
718 
719     /**
720      * Method read.
721      * 
722      * @param in
723      * @throws IOException
724      * @throws XmlPullParserException
725      * @return Settings
726      */
727     public Settings read(InputStream in)
728         throws IOException, XmlPullParserException
729     {
730         Reader reader = ReaderFactory.newXmlReader( in );
731         
732         return read( reader );
733     } //-- Settings read(InputStream) 
734 
735     /**
736      * Sets the state of the "add default entities" flag.
737      * 
738      * @param addDefaultEntities
739      */
740     public void setAddDefaultEntities(boolean addDefaultEntities)
741     {
742         this.addDefaultEntities = addDefaultEntities;
743     } //-- void setAddDefaultEntities(boolean) 
744 
745 
746 }