View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.usability.plugin.io.xpp3;
25  
26    //---------------------------------/
27   //- Imported classes and packages -/
28  //---------------------------------/
29  
30  import java.io.IOException;
31  import java.io.InputStream;
32  import java.io.Reader;
33  import java.text.DateFormat;
34  import org.apache.maven.usability.plugin.Expression;
35  import org.apache.maven.usability.plugin.ExpressionDocumentation;
36  import org.codehaus.plexus.util.xml.XmlStreamReader;
37  import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
38  import org.codehaus.plexus.util.xml.pull.MXParser;
39  import org.codehaus.plexus.util.xml.pull.XmlPullParser;
40  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
41  
42  /**
43   * Class ParamdocXpp3Reader.
44   * 
45   * @version $Revision$ $Date$
46   */
47  @SuppressWarnings( "all" )
48  public class ParamdocXpp3Reader
49  {
50  
51        //--------------------------/
52       //- Class/Member Variables -/
53      //--------------------------/
54  
55      /**
56       * If set the parser will be loaded with all single characters
57       * from the XHTML specification.
58       * The entities used:
59       * <ul>
60       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
61       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
62       * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
63       * </ul>
64       */
65      private boolean addDefaultEntities = true;
66  
67      /**
68       * Field contentTransformer.
69       */
70      public final ContentTransformer contentTransformer;
71  
72  
73        //----------------/
74       //- Constructors -/
75      //----------------/
76  
77      public ParamdocXpp3Reader()
78      {
79          this( new ContentTransformer()
80          {
81              public String transform( String source, String fieldName )
82              {
83                  return source;
84              }
85          } );
86      } //-- org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader()
87  
88      public ParamdocXpp3Reader(ContentTransformer contentTransformer)
89      {
90          this.contentTransformer = contentTransformer;
91      } //-- org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader(ContentTransformer)
92  
93  
94        //-----------/
95       //- Methods -/
96      //-----------/
97  
98      /**
99       * Method checkFieldWithDuplicate.
100      * 
101      * @param parser a parser object.
102      * @param parsed a parsed object.
103      * @param alias a alias object.
104      * @param tagName a tagName object.
105      * @throws XmlPullParserException XmlPullParserException if
106      * any.
107      * @return boolean
108      */
109     private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, java.util.Set<String> parsed )
110         throws XmlPullParserException
111     {
112         if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) )
113         {
114             return false;
115         }
116         if ( !parsed.add( tagName ) )
117         {
118             throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null );
119         }
120         return true;
121     } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, java.util.Set )
122 
123     /**
124      * Method checkUnknownAttribute.
125      * 
126      * @param parser a parser object.
127      * @param strict a strict object.
128      * @param tagName a tagName object.
129      * @param attribute a attribute object.
130      * @throws XmlPullParserException XmlPullParserException if
131      * any.
132      * @throws IOException IOException if any.
133      */
134     private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict )
135         throws XmlPullParserException, IOException
136     {
137         // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too
138         if ( strict )
139         {
140             throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null );
141         }
142     } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean )
143 
144     /**
145      * Method checkUnknownElement.
146      * 
147      * @param parser a parser object.
148      * @param strict a strict object.
149      * @throws XmlPullParserException XmlPullParserException if
150      * any.
151      * @throws IOException IOException if any.
152      */
153     private void checkUnknownElement( XmlPullParser parser, boolean strict )
154         throws XmlPullParserException, IOException
155     {
156         if ( strict )
157         {
158             throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null );
159         }
160 
161         for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; )
162         {
163             int eventType = parser.next();
164             if ( eventType == XmlPullParser.START_TAG )
165             {
166                 unrecognizedTagCount++;
167             }
168             else if ( eventType == XmlPullParser.END_TAG )
169             {
170                 unrecognizedTagCount--;
171             }
172         }
173     } //-- void checkUnknownElement( XmlPullParser, boolean )
174 
175     /**
176      * Returns the state of the "add default entities" flag.
177      * 
178      * @return boolean
179      */
180     public boolean getAddDefaultEntities()
181     {
182         return addDefaultEntities;
183     } //-- boolean getAddDefaultEntities()
184 
185     /**
186      * Method getBooleanValue.
187      * 
188      * @param s a s object.
189      * @param parser a parser object.
190      * @param attribute a attribute object.
191      * @throws XmlPullParserException XmlPullParserException if
192      * any.
193      * @return boolean
194      */
195     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser )
196         throws XmlPullParserException
197     {
198         return getBooleanValue( s, attribute, parser, null );
199     } //-- boolean getBooleanValue( String, String, XmlPullParser )
200 
201     /**
202      * Method getBooleanValue.
203      * 
204      * @param s a s object.
205      * @param defaultValue a defaultValue object.
206      * @param parser a parser object.
207      * @param attribute a attribute object.
208      * @throws XmlPullParserException XmlPullParserException if
209      * any.
210      * @return boolean
211      */
212     private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue )
213         throws XmlPullParserException
214     {
215         if ( s != null && s.length() != 0 )
216         {
217             return Boolean.valueOf( s ).booleanValue();
218         }
219         if ( defaultValue != null )
220         {
221             return Boolean.valueOf( defaultValue ).booleanValue();
222         }
223         return false;
224     } //-- boolean getBooleanValue( String, String, XmlPullParser, String )
225 
226     /**
227      * Method getByteValue.
228      * 
229      * @param s a s object.
230      * @param strict a strict object.
231      * @param parser a parser object.
232      * @param attribute a attribute object.
233      * @throws XmlPullParserException XmlPullParserException if
234      * any.
235      * @return byte
236      */
237     private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict )
238         throws XmlPullParserException
239     {
240         if ( s != null )
241         {
242             try
243             {
244                 return Byte.valueOf( s ).byteValue();
245             }
246             catch ( NumberFormatException nfe )
247             {
248                 if ( strict )
249                 {
250                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe );
251                 }
252             }
253         }
254         return 0;
255     } //-- byte getByteValue( String, String, XmlPullParser, boolean )
256 
257     /**
258      * Method getCharacterValue.
259      * 
260      * @param s a s object.
261      * @param parser a parser object.
262      * @param attribute a attribute object.
263      * @throws XmlPullParserException XmlPullParserException if
264      * any.
265      * @return char
266      */
267     private char getCharacterValue( String s, String attribute, XmlPullParser parser )
268         throws XmlPullParserException
269     {
270         if ( s != null )
271         {
272             return s.charAt( 0 );
273         }
274         return 0;
275     } //-- char getCharacterValue( String, String, XmlPullParser )
276 
277     /**
278      * Method getDateValue.
279      * 
280      * @param s a s object.
281      * @param parser a parser object.
282      * @param attribute a attribute object.
283      * @throws XmlPullParserException XmlPullParserException if
284      * any.
285      * @return Date
286      */
287     private java.util.Date getDateValue( String s, String attribute, XmlPullParser parser )
288         throws XmlPullParserException
289     {
290         return getDateValue( s, attribute, null, parser );
291     } //-- java.util.Date getDateValue( String, String, XmlPullParser )
292 
293     /**
294      * Method getDateValue.
295      * 
296      * @param s a s object.
297      * @param parser a parser object.
298      * @param dateFormat a dateFormat object.
299      * @param attribute a attribute object.
300      * @throws XmlPullParserException XmlPullParserException if
301      * any.
302      * @return Date
303      */
304     private java.util.Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser )
305         throws XmlPullParserException
306     {
307         if ( s != null )
308         {
309             String effectiveDateFormat = dateFormat;
310             if ( dateFormat == null )
311             {
312                 effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
313             }
314             if ( "long".equals( effectiveDateFormat ) )
315             {
316                 try
317                 {
318                     return new java.util.Date( Long.parseLong( s ) );
319                 }
320                 catch ( NumberFormatException e )
321                 {
322                     throw new XmlPullParserException( e.getMessage(), parser, e );
323                 }
324             }
325             else
326             {
327                 try
328                 {
329                     DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
330                     return dateParser.parse( s );
331                 }
332                 catch ( java.text.ParseException e )
333                 {
334                     throw new XmlPullParserException( e.getMessage(), parser, e );
335                 }
336             }
337         }
338         return null;
339     } //-- java.util.Date getDateValue( String, String, String, XmlPullParser )
340 
341     /**
342      * Method getDoubleValue.
343      * 
344      * @param s a s object.
345      * @param strict a strict object.
346      * @param parser a parser object.
347      * @param attribute a attribute object.
348      * @throws XmlPullParserException XmlPullParserException if
349      * any.
350      * @return double
351      */
352     private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict )
353         throws XmlPullParserException
354     {
355         if ( s != null )
356         {
357             try
358             {
359                 return Double.valueOf( s ).doubleValue();
360             }
361             catch ( NumberFormatException nfe )
362             {
363                 if ( strict )
364                 {
365                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
366                 }
367             }
368         }
369         return 0;
370     } //-- double getDoubleValue( String, String, XmlPullParser, boolean )
371 
372     /**
373      * Method getFloatValue.
374      * 
375      * @param s a s object.
376      * @param strict a strict object.
377      * @param parser a parser object.
378      * @param attribute a attribute object.
379      * @throws XmlPullParserException XmlPullParserException if
380      * any.
381      * @return float
382      */
383     private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict )
384         throws XmlPullParserException
385     {
386         if ( s != null )
387         {
388             try
389             {
390                 return Float.valueOf( s ).floatValue();
391             }
392             catch ( NumberFormatException nfe )
393             {
394                 if ( strict )
395                 {
396                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe );
397                 }
398             }
399         }
400         return 0;
401     } //-- float getFloatValue( String, String, XmlPullParser, boolean )
402 
403     /**
404      * Method getIntegerValue.
405      * 
406      * @param s a s object.
407      * @param strict a strict object.
408      * @param parser a parser object.
409      * @param attribute a attribute object.
410      * @throws XmlPullParserException XmlPullParserException if
411      * any.
412      * @return int
413      */
414     private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict )
415         throws XmlPullParserException
416     {
417         if ( s != null )
418         {
419             try
420             {
421                 return Integer.valueOf( s ).intValue();
422             }
423             catch ( NumberFormatException nfe )
424             {
425                 if ( strict )
426                 {
427                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe );
428                 }
429             }
430         }
431         return 0;
432     } //-- int getIntegerValue( String, String, XmlPullParser, boolean )
433 
434     /**
435      * Method getLongValue.
436      * 
437      * @param s a s object.
438      * @param strict a strict object.
439      * @param parser a parser object.
440      * @param attribute a attribute object.
441      * @throws XmlPullParserException XmlPullParserException if
442      * any.
443      * @return long
444      */
445     private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict )
446         throws XmlPullParserException
447     {
448         if ( s != null )
449         {
450             try
451             {
452                 return Long.valueOf( s ).longValue();
453             }
454             catch ( NumberFormatException nfe )
455             {
456                 if ( strict )
457                 {
458                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe );
459                 }
460             }
461         }
462         return 0;
463     } //-- long getLongValue( String, String, XmlPullParser, boolean )
464 
465     /**
466      * Method getRequiredAttributeValue.
467      * 
468      * @param s a s object.
469      * @param strict a strict object.
470      * @param parser a parser object.
471      * @param attribute a attribute object.
472      * @throws XmlPullParserException XmlPullParserException if
473      * any.
474      * @return String
475      */
476     private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict )
477         throws XmlPullParserException
478     {
479         if ( s == null )
480         {
481             if ( strict )
482             {
483                 throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null );
484             }
485         }
486         return s;
487     } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean )
488 
489     /**
490      * Method getShortValue.
491      * 
492      * @param s a s object.
493      * @param strict a strict object.
494      * @param parser a parser object.
495      * @param attribute a attribute object.
496      * @throws XmlPullParserException XmlPullParserException if
497      * any.
498      * @return short
499      */
500     private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict )
501         throws XmlPullParserException
502     {
503         if ( s != null )
504         {
505             try
506             {
507                 return Short.valueOf( s ).shortValue();
508             }
509             catch ( NumberFormatException nfe )
510             {
511                 if ( strict )
512                 {
513                     throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe );
514                 }
515             }
516         }
517         return 0;
518     } //-- short getShortValue( String, String, XmlPullParser, boolean )
519 
520     /**
521      * Method getTrimmedValue.
522      * 
523      * @param s a s object.
524      * @return String
525      */
526     private String getTrimmedValue( String s )
527     {
528         if ( s != null )
529         {
530             s = s.trim();
531         }
532         return s;
533     } //-- String getTrimmedValue( String )
534 
535     /**
536      * Method interpolatedTrimmed.
537      * 
538      * @param value a value object.
539      * @param context a context object.
540      * @return String
541      */
542     private String interpolatedTrimmed( String value, String context )
543     {
544         return getTrimmedValue( contentTransformer.transform( value, context ) );
545     } //-- String interpolatedTrimmed( String, String )
546 
547     /**
548      * Method nextTag.
549      * 
550      * @param parser a parser object.
551      * @throws IOException IOException if any.
552      * @throws XmlPullParserException XmlPullParserException if
553      * any.
554      * @return int
555      */
556     private int nextTag( XmlPullParser parser )
557         throws IOException, XmlPullParserException
558     {
559         int eventType = parser.next();
560         if ( eventType == XmlPullParser.TEXT )
561         {
562             eventType = parser.next();
563         }
564         if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG )
565         {
566             throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null );
567         }
568         return eventType;
569     } //-- int nextTag( XmlPullParser )
570 
571     /**
572      * Method read.
573      * 
574      * @param parser a parser object.
575      * @param strict a strict object.
576      * @throws IOException IOException if any.
577      * @throws XmlPullParserException XmlPullParserException if
578      * any.
579      * @return ExpressionDocumentation
580      */
581     public ExpressionDocumentation read( XmlPullParser parser, boolean strict )
582         throws IOException, XmlPullParserException
583     {
584         ExpressionDocumentation expressionDocumentation = null;
585         int eventType = parser.getEventType();
586         boolean parsed = false;
587         while ( eventType != XmlPullParser.END_DOCUMENT )
588         {
589             if ( eventType == XmlPullParser.START_TAG )
590             {
591                 if ( strict && ! "paramdoc".equals( parser.getName() ) )
592                 {
593                     throw new XmlPullParserException( "Expected root element 'paramdoc' but found '" + parser.getName() + "'", parser, null );
594                 }
595                 else if ( parsed )
596                 {
597                     // fallback, already expected a XmlPullParserException due to invalid XML
598                     throw new XmlPullParserException( "Duplicated tag: 'paramdoc'", parser, null );
599                 }
600                 expressionDocumentation = parseExpressionDocumentation( parser, strict );
601                 expressionDocumentation.setModelEncoding( parser.getInputEncoding() );
602                 parsed = true;
603             }
604             eventType = parser.next();
605         }
606         if ( parsed )
607         {
608             return expressionDocumentation;
609         }
610         throw new XmlPullParserException( "Expected root element 'paramdoc' but found no element at all: invalid XML document", parser, null );
611     } //-- ExpressionDocumentation read( XmlPullParser, boolean )
612 
613     /**
614      * @see XmlStreamReader
615      * 
616      * @param reader a reader object.
617      * @param strict a strict object.
618      * @throws IOException IOException if any.
619      * @throws XmlPullParserException XmlPullParserException if
620      * any.
621      * @return ExpressionDocumentation
622      */
623     public ExpressionDocumentation read( Reader reader, boolean strict )
624         throws IOException, XmlPullParserException
625     {
626         XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
627 
628         parser.setInput( reader );
629 
630 
631         return read( parser, strict );
632     } //-- ExpressionDocumentation read( Reader, boolean )
633 
634     /**
635      * @see XmlStreamReader
636      * 
637      * @param reader a reader object.
638      * @throws IOException IOException if any.
639      * @throws XmlPullParserException XmlPullParserException if
640      * any.
641      * @return ExpressionDocumentation
642      */
643     public ExpressionDocumentation read( Reader reader )
644         throws IOException, XmlPullParserException
645     {
646         return read( reader, true );
647     } //-- ExpressionDocumentation read( Reader )
648 
649     /**
650      * Method read.
651      * 
652      * @param in a in object.
653      * @param strict a strict object.
654      * @throws IOException IOException if any.
655      * @throws XmlPullParserException XmlPullParserException if
656      * any.
657      * @return ExpressionDocumentation
658      */
659     public ExpressionDocumentation read( InputStream in, boolean strict )
660         throws IOException, XmlPullParserException
661     {
662         return read( new XmlStreamReader( in ), strict );
663     } //-- ExpressionDocumentation read( InputStream, boolean )
664 
665     /**
666      * Method read.
667      * 
668      * @param in a in object.
669      * @throws IOException IOException if any.
670      * @throws XmlPullParserException XmlPullParserException if
671      * any.
672      * @return ExpressionDocumentation
673      */
674     public ExpressionDocumentation read( InputStream in )
675         throws IOException, XmlPullParserException
676     {
677         return read( new XmlStreamReader( in ) );
678     } //-- ExpressionDocumentation read( InputStream )
679 
680     /**
681      * Method parseExpression.
682      * 
683      * @param parser a parser object.
684      * @param strict a strict object.
685      * @throws IOException IOException if any.
686      * @throws XmlPullParserException XmlPullParserException if
687      * any.
688      * @return Expression
689      */
690     private Expression parseExpression( XmlPullParser parser, boolean strict )
691         throws IOException, XmlPullParserException
692     {
693         String tagName = parser.getName();
694         Expression expression = new Expression();
695         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
696         {
697             String name = parser.getAttributeName( i );
698             String value = parser.getAttributeValue( i );
699 
700             if ( name.indexOf( ':' ) >= 0 )
701             {
702                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
703             }
704             else
705             {
706                 checkUnknownAttribute( parser, name, tagName, strict );
707             }
708         }
709         java.util.Set<String> parsed = new java.util.HashSet<String>();
710         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
711         {
712             if ( checkFieldWithDuplicate( parser, "syntax", null, parsed ) )
713             {
714                 expression.setSyntax( interpolatedTrimmed( parser.nextText(), "syntax" ) );
715             }
716             else if ( checkFieldWithDuplicate( parser, "description", null, parsed ) )
717             {
718                 expression.setDescription( interpolatedTrimmed( parser.nextText(), "description" ) );
719             }
720             else if ( checkFieldWithDuplicate( parser, "configuration", null, parsed ) )
721             {
722                 expression.setConfiguration( interpolatedTrimmed( parser.nextText(), "configuration" ) );
723             }
724             else if ( checkFieldWithDuplicate( parser, "cliOptions", null, parsed ) )
725             {
726                 while ( parser.nextTag() == XmlPullParser.START_TAG )
727                 {
728                     if ( "cliOption".equals( parser.getName() ) )
729                     {
730                         String key = null;
731                         String value = null;
732                         // explode mode.
733                         while ( parser.nextTag() == XmlPullParser.START_TAG )
734                         {
735                             if ( "key".equals( parser.getName() ) )
736                             {
737                                 key = parser.nextText();
738                             }
739                             else if ( "value".equals( parser.getName() ) )
740                             {
741                                 value = parser.nextText().trim();
742                             }
743                             else
744                             {
745                                 parser.nextText();
746                             }
747                         }
748                         expression.addCliOption( key, value );
749                     }
750                     parser.next();
751                 }
752             }
753             else if ( checkFieldWithDuplicate( parser, "apiMethods", null, parsed ) )
754             {
755                 while ( parser.nextTag() == XmlPullParser.START_TAG )
756                 {
757                     if ( "apiMethod".equals( parser.getName() ) )
758                     {
759                         String key = null;
760                         String value = null;
761                         // explode mode.
762                         while ( parser.nextTag() == XmlPullParser.START_TAG )
763                         {
764                             if ( "key".equals( parser.getName() ) )
765                             {
766                                 key = parser.nextText();
767                             }
768                             else if ( "value".equals( parser.getName() ) )
769                             {
770                                 value = parser.nextText().trim();
771                             }
772                             else
773                             {
774                                 parser.nextText();
775                             }
776                         }
777                         expression.addApiMethod( key, value );
778                     }
779                     parser.next();
780                 }
781             }
782             else if ( checkFieldWithDuplicate( parser, "deprecation", null, parsed ) )
783             {
784                 expression.setDeprecation( interpolatedTrimmed( parser.nextText(), "deprecation" ) );
785             }
786             else if ( checkFieldWithDuplicate( parser, "ban", null, parsed ) )
787             {
788                 expression.setBan( interpolatedTrimmed( parser.nextText(), "ban" ) );
789             }
790             else if ( checkFieldWithDuplicate( parser, "editable", null, parsed ) )
791             {
792                 expression.setEditable( getBooleanValue( interpolatedTrimmed( parser.nextText(), "editable" ), "editable", parser, "true" ) );
793             }
794             else
795             {
796                 checkUnknownElement( parser, strict );
797             }
798         }
799         return expression;
800     } //-- Expression parseExpression( XmlPullParser, boolean )
801 
802     /**
803      * Method parseExpressionDocumentation.
804      * 
805      * @param parser a parser object.
806      * @param strict a strict object.
807      * @throws IOException IOException if any.
808      * @throws XmlPullParserException XmlPullParserException if
809      * any.
810      * @return ExpressionDocumentation
811      */
812     private ExpressionDocumentation parseExpressionDocumentation( XmlPullParser parser, boolean strict )
813         throws IOException, XmlPullParserException
814     {
815         String tagName = parser.getName();
816         ExpressionDocumentation expressionDocumentation = new ExpressionDocumentation();
817         for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
818         {
819             String name = parser.getAttributeName( i );
820             String value = parser.getAttributeValue( i );
821 
822             if ( name.indexOf( ':' ) >= 0 )
823             {
824                 // just ignore attributes with non-default namespace (for example: xmlns:xsi)
825             }
826             else if ( "xmlns".equals( name ) )
827             {
828                 // ignore xmlns attribute in root class, which is a reserved attribute name
829             }
830             else
831             {
832                 checkUnknownAttribute( parser, name, tagName, strict );
833             }
834         }
835         java.util.Set<String> parsed = new java.util.HashSet<String>();
836         while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG )
837         {
838             if ( checkFieldWithDuplicate( parser, "expressions", null, parsed ) )
839             {
840                 java.util.List<Expression> expressions = new java.util.ArrayList<Expression>();
841                 while ( parser.nextTag() == XmlPullParser.START_TAG )
842                 {
843                     if ( "expression".equals( parser.getName() ) )
844                     {
845                         expressions.add( parseExpression( parser, strict ) );
846                     }
847                     else
848                     {
849                         checkUnknownElement( parser, strict );
850                     }
851                 }
852                 expressionDocumentation.setExpressions( expressions );
853             }
854             else
855             {
856                 checkUnknownElement( parser, strict );
857             }
858         }
859         return expressionDocumentation;
860     } //-- ExpressionDocumentation parseExpressionDocumentation( XmlPullParser, boolean )
861 
862     /**
863      * Sets the state of the "add default entities" flag.
864      * 
865      * @param addDefaultEntities a addDefaultEntities object.
866      */
867     public void setAddDefaultEntities( boolean addDefaultEntities )
868     {
869         this.addDefaultEntities = addDefaultEntities;
870     } //-- void setAddDefaultEntities( boolean )
871 
872     public static interface ContentTransformer
873 {
874     /**
875      * Interpolate the value read from the xpp3 document
876      * @param source The source value
877      * @param fieldName A description of the field being interpolated. The implementation may use this to
878      *                           log stuff.
879      * @return The interpolated value.
880      */
881     String transform( String source, String fieldName );
882 }
883 
884 }