001/*
002 =================== DO NOT EDIT THIS FILE ====================
003 Generated by Modello 1.9.2-SNAPSHOT,
004 any modifications will be overwritten.
005 ==============================================================
006 */
007
008package org.codehaus.modello.test.features.io.dom4j;
009
010  //---------------------------------/
011 //- Imported classes and packages -/
012//---------------------------------/
013
014import java.io.IOException;
015import java.io.InputStream;
016import java.io.Reader;
017import java.net.URL;
018import java.text.DateFormat;
019import java.text.ParsePosition;
020import java.util.Date;
021import java.util.Iterator;
022import java.util.Locale;
023import org.codehaus.modello.test.features.Action;
024import org.codehaus.modello.test.features.AnnotationTest;
025import org.codehaus.modello.test.features.ArrayFeatures;
026import org.codehaus.modello.test.features.AssociationFeatures;
027import org.codehaus.modello.test.features.BaseClass;
028import org.codehaus.modello.test.features.BidiInList;
029import org.codehaus.modello.test.features.BidiInSet;
030import org.codehaus.modello.test.features.Bidirectional;
031import org.codehaus.modello.test.features.ContentTest;
032import org.codehaus.modello.test.features.DueTo;
033import org.codehaus.modello.test.features.Features;
034import org.codehaus.modello.test.features.File;
035import org.codehaus.modello.test.features.InterfacesFeature;
036import org.codehaus.modello.test.features.JavaFeatures;
037import org.codehaus.modello.test.features.NodeItem;
038import org.codehaus.modello.test.features.Reference;
039import org.codehaus.modello.test.features.SimpleInterface;
040import org.codehaus.modello.test.features.SimpleTypes;
041import org.codehaus.modello.test.features.SubClassLevel1;
042import org.codehaus.modello.test.features.SubClassLevel2;
043import org.codehaus.modello.test.features.SubClassLevel3;
044import org.codehaus.modello.test.features.SubInterface;
045import org.codehaus.modello.test.features.SuperThing;
046import org.codehaus.modello.test.features.Thing;
047import org.codehaus.modello.test.features.Thingy;
048import org.codehaus.modello.test.features.XdocFeatures;
049import org.codehaus.modello.test.features.XmlAttributes;
050import org.codehaus.modello.test.features.XmlContent;
051import org.codehaus.modello.test.features.XmlContentLong;
052import org.codehaus.modello.test.features.XmlContentLongWithAttributes;
053import org.codehaus.modello.test.features.XmlFeatures;
054import org.codehaus.modello.test.features.XmlFieldsOrder;
055import org.codehaus.modello.test.features.XmlFieldsOrderParent;
056import org.codehaus.modello.test.features.XmlFieldsOrderParent2;
057import org.codehaus.modello.test.features.XmlTransientFields;
058import org.codehaus.modello.test.features.XsdFeatures;
059import org.codehaus.modello.test.features.other.PackageNameFeature;
060import org.codehaus.modello.test.features.other.SubInterfaceInPackage;
061import org.codehaus.plexus.util.xml.Xpp3Dom;
062import org.dom4j.Attribute;
063import org.dom4j.Document;
064import org.dom4j.DocumentException;
065import org.dom4j.Element;
066import org.dom4j.Node;
067import org.dom4j.io.SAXReader;
068
069/**
070 * Class ModelloFeaturesTestDom4jReader.
071 * 
072 * @version $Revision$ $Date$
073 */
074@SuppressWarnings( "all" )
075public class ModelloFeaturesTestDom4jReader
076{
077
078      //-----------/
079     //- Methods -/
080    //-----------/
081
082    /**
083     * Method checkFieldWithDuplicate.
084     * 
085     * @param element
086     * @param parsed
087     * @param alias
088     * @param tagName
089     * @throws DocumentException
090     * @return boolean
091     */
092    private boolean checkFieldWithDuplicate( Element element, String tagName, String alias, java.util.Set parsed )
093        throws DocumentException
094    {
095        if ( !( element.getName().equals( tagName ) || element.getName().equals( alias ) ) )
096        {
097            return false;
098        }
099        if ( !parsed.add( tagName ) )
100        {
101            throw new DocumentException( "Duplicated tag: '" + tagName + "'" );
102        }
103        return true;
104    } //-- boolean checkFieldWithDuplicate( Element, String, String, java.util.Set )
105
106    /**
107     * Method checkUnknownElement.
108     * 
109     * @param element
110     * @param strict
111     * @throws DocumentException
112     */
113    private void checkUnknownElement( Element element, boolean strict )
114        throws DocumentException
115    {
116        if ( strict )
117        {
118            throw new DocumentException( "Unrecognised tag: '" + element.getName() + "'" );
119        }
120    } //-- void checkUnknownElement( Element, boolean )
121
122    /**
123     * Method getBooleanValue.
124     * 
125     * @param s
126     * @param attribute
127     * @return boolean
128     */
129    private boolean getBooleanValue( String s, String attribute )
130    {
131        if ( s != null )
132        {
133            return Boolean.valueOf( s ).booleanValue();
134        }
135        return false;
136    } //-- boolean getBooleanValue( String, String )
137
138    /**
139     * Method getByteValue.
140     * 
141     * @param s
142     * @param strict
143     * @param attribute
144     * @throws DocumentException
145     * @return byte
146     */
147    private byte getByteValue( String s, String attribute, boolean strict )
148        throws DocumentException
149    {
150        if ( s != null )
151        {
152            try
153            {
154                return Byte.valueOf( s ).byteValue();
155            }
156            catch ( NumberFormatException nfe )
157            {
158                if ( strict )
159                {
160                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be a byte", nfe );
161                }
162            }
163        }
164        return 0;
165    } //-- byte getByteValue( String, String, boolean )
166
167    /**
168     * Method getCharacterValue.
169     * 
170     * @param s
171     * @param attribute
172     * @return char
173     */
174    private char getCharacterValue( String s, String attribute )
175    {
176        if ( s != null )
177        {
178            return s.charAt( 0 );
179        }
180        return 0;
181    } //-- char getCharacterValue( String, String )
182
183    /**
184     * Method getDateValue.
185     * 
186     * @param s
187     * @param dateFormat
188     * @param attribute
189     * @throws DocumentException
190     * @return Date
191     */
192    private java.util.Date getDateValue( String s, String attribute, String dateFormat )
193        throws DocumentException
194    {
195        if ( s != null )
196        {
197            String effectiveDateFormat = dateFormat;
198            if ( dateFormat == null )
199            {
200                effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS";
201            }
202            if ( "long".equals( effectiveDateFormat ) )
203            {
204                try
205                {
206                    return new java.util.Date( Long.parseLong( s ) );
207                }
208                catch ( NumberFormatException e )
209                {
210                    throw new DocumentException( e.getMessage(), e );
211                }
212            }
213            else
214            {
215                try
216                {
217                    DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
218                    return dateParser.parse( s );
219                }
220                catch ( java.text.ParseException e )
221                {
222                    throw new DocumentException( e.getMessage(), e );
223                }
224            }
225        }
226        return null;
227    } //-- java.util.Date getDateValue( String, String, String )
228
229    /**
230     * Method getDoubleValue.
231     * 
232     * @param s
233     * @param strict
234     * @param attribute
235     * @throws DocumentException
236     * @return double
237     */
238    private double getDoubleValue( String s, String attribute, boolean strict )
239        throws DocumentException
240    {
241        if ( s != null )
242        {
243            try
244            {
245                return Double.valueOf( s ).doubleValue();
246            }
247            catch ( NumberFormatException nfe )
248            {
249                if ( strict )
250                {
251                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be a floating point number", nfe );
252                }
253            }
254        }
255        return 0;
256    } //-- double getDoubleValue( String, String, boolean )
257
258    /**
259     * Method getFloatValue.
260     * 
261     * @param s
262     * @param strict
263     * @param attribute
264     * @throws DocumentException
265     * @return float
266     */
267    private float getFloatValue( String s, String attribute, boolean strict )
268        throws DocumentException
269    {
270        if ( s != null )
271        {
272            try
273            {
274                return Float.valueOf( s ).floatValue();
275            }
276            catch ( NumberFormatException nfe )
277            {
278                if ( strict )
279                {
280                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be a floating point number", nfe );
281                }
282            }
283        }
284        return 0;
285    } //-- float getFloatValue( String, String, boolean )
286
287    /**
288     * Method getIntegerValue.
289     * 
290     * @param s
291     * @param strict
292     * @param attribute
293     * @throws DocumentException
294     * @return int
295     */
296    private int getIntegerValue( String s, String attribute, boolean strict )
297        throws DocumentException
298    {
299        if ( s != null )
300        {
301            try
302            {
303                return Integer.valueOf( s ).intValue();
304            }
305            catch ( NumberFormatException nfe )
306            {
307                if ( strict )
308                {
309                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be an integer", nfe );
310                }
311            }
312        }
313        return 0;
314    } //-- int getIntegerValue( String, String, boolean )
315
316    /**
317     * Method getLongValue.
318     * 
319     * @param s
320     * @param strict
321     * @param attribute
322     * @throws DocumentException
323     * @return long
324     */
325    private long getLongValue( String s, String attribute, boolean strict )
326        throws DocumentException
327    {
328        if ( s != null )
329        {
330            try
331            {
332                return Long.valueOf( s ).longValue();
333            }
334            catch ( NumberFormatException nfe )
335            {
336                if ( strict )
337                {
338                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be a long integer", nfe );
339                }
340            }
341        }
342        return 0;
343    } //-- long getLongValue( String, String, boolean )
344
345    /**
346     * Method getShortValue.
347     * 
348     * @param s
349     * @param strict
350     * @param attribute
351     * @throws DocumentException
352     * @return short
353     */
354    private short getShortValue( String s, String attribute, boolean strict )
355        throws DocumentException
356    {
357        if ( s != null )
358        {
359            try
360            {
361                return Short.valueOf( s ).shortValue();
362            }
363            catch ( NumberFormatException nfe )
364            {
365                if ( strict )
366                {
367                    throw new DocumentException( "Unable to parse element '" + attribute + "', must be a short integer", nfe );
368                }
369            }
370        }
371        return 0;
372    } //-- short getShortValue( String, String, boolean )
373
374    /**
375     * Method getTrimmedValue.
376     * 
377     * @param s
378     * @return String
379     */
380    private String getTrimmedValue( String s )
381    {
382        if ( s != null )
383        {
384            s = s.trim();
385        }
386        return s;
387    } //-- String getTrimmedValue( String )
388
389    /**
390     * Method parseAction.
391     * 
392     * @param tagName
393     * @param strict
394     * @param element
395     * @throws IOException
396     * @throws DocumentException
397     * @return Action
398     */
399    private Action parseAction( String tagName, Element element, boolean strict )
400        throws IOException, DocumentException
401    {
402        Action action = new Action();
403        if ( element.attributeValue( "dev" ) != null  )
404        {
405            action.setDev( getTrimmedValue( element.attributeValue( "dev" ) ) );
406        }
407        action.setAction( getTrimmedValue( element.getText() ) );
408        return action;
409    } //-- Action parseAction( String, Element, boolean )
410
411    /**
412     * Method parseAnnotationTest.
413     * 
414     * @param tagName
415     * @param strict
416     * @param element
417     * @throws IOException
418     * @throws DocumentException
419     * @return AnnotationTest
420     */
421    private AnnotationTest parseAnnotationTest( String tagName, Element element, boolean strict )
422        throws IOException, DocumentException
423    {
424        AnnotationTest annotationTest = new AnnotationTest();
425        java.util.Set parsed = new java.util.HashSet();
426        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
427        {
428            Node node = (Node) i.next();
429            if ( node.getNodeType() == Node.ELEMENT_NODE )
430            {
431                Element childElement = (Element) node;
432                if ( checkFieldWithDuplicate( childElement, "anyField", null, parsed ) )
433                {
434                    annotationTest.setAnyField( getTrimmedValue( childElement.getText() ) );
435                }
436                else
437                {
438                    checkUnknownElement( childElement, strict );
439                }
440            }
441        }
442        return annotationTest;
443    } //-- AnnotationTest parseAnnotationTest( String, Element, boolean )
444
445    /**
446     * Method parseArrayFeatures.
447     * 
448     * @param tagName
449     * @param strict
450     * @param element
451     * @throws IOException
452     * @throws DocumentException
453     * @return ArrayFeatures
454     */
455    private ArrayFeatures parseArrayFeatures( String tagName, Element element, boolean strict )
456        throws IOException, DocumentException
457    {
458        ArrayFeatures arrayFeatures = new ArrayFeatures();
459        java.util.Set parsed = new java.util.HashSet();
460        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
461        {
462            Node node = (Node) i.next();
463            if ( node.getNodeType() == Node.ELEMENT_NODE )
464            {
465                Element childElement = (Element) node;
466                checkUnknownElement( childElement, strict );
467            }
468        }
469        return arrayFeatures;
470    } //-- ArrayFeatures parseArrayFeatures( String, Element, boolean )
471
472    /**
473     * Method parseAssociationFeatures.
474     * 
475     * @param tagName
476     * @param strict
477     * @param element
478     * @throws IOException
479     * @throws DocumentException
480     * @return AssociationFeatures
481     */
482    private AssociationFeatures parseAssociationFeatures( String tagName, Element element, boolean strict )
483        throws IOException, DocumentException
484    {
485        AssociationFeatures associationFeatures = new AssociationFeatures();
486        java.util.Set parsed = new java.util.HashSet();
487        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
488        {
489            Node node = (Node) i.next();
490            if ( node.getNodeType() == Node.ELEMENT_NODE )
491            {
492                Element childElement = (Element) node;
493                if ( checkFieldWithDuplicate( childElement, "listReferences", null, parsed ) )
494                {
495                    java.util.List listReferences = new java.util.ArrayList/*<Reference>*/();
496                    associationFeatures.setListReferences( listReferences );
497                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
498                    {
499                        Node n = (Node) j.next();
500                        if ( n.getNodeType() == Node.ELEMENT_NODE )
501                        {
502                            Element listElement = (Element) n;
503                            if ( "listReference".equals( listElement.getName() ) )
504                            {
505                                listReferences.add( parseReference( "listReference", listElement, strict ) );
506                            }
507                            else
508                            {
509                            }
510                        }
511                    }
512                }
513                else if ( checkFieldWithDuplicate( childElement, "setReferences", null, parsed ) )
514                {
515                    java.util.Set setReferences = new java.util.HashSet/*<Reference>*/();
516                    associationFeatures.setSetReferences( setReferences );
517                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
518                    {
519                        Node n = (Node) j.next();
520                        if ( n.getNodeType() == Node.ELEMENT_NODE )
521                        {
522                            Element listElement = (Element) n;
523                            if ( "setReference".equals( listElement.getName() ) )
524                            {
525                                setReferences.add( parseReference( "setReference", listElement, strict ) );
526                            }
527                            else
528                            {
529                            }
530                        }
531                    }
532                }
533                else if ( checkFieldWithDuplicate( childElement, "listStrings", null, parsed ) )
534                {
535                    java.util.List listStrings = new java.util.ArrayList/*<String>*/();
536                    associationFeatures.setListStrings( listStrings );
537                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
538                    {
539                        Node n = (Node) j.next();
540                        if ( n.getNodeType() == Node.ELEMENT_NODE )
541                        {
542                            Element listElement = (Element) n;
543                            if ( "listString".equals( listElement.getName() ) )
544                            {
545                                listStrings.add( getTrimmedValue( listElement.getText() ) );
546                            }
547                            else
548                            {
549                            }
550                        }
551                    }
552                }
553                else if ( checkFieldWithDuplicate( childElement, "setStrings", null, parsed ) )
554                {
555                    java.util.Set setStrings = new java.util.HashSet/*<String>*/();
556                    associationFeatures.setSetStrings( setStrings );
557                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
558                    {
559                        Node n = (Node) j.next();
560                        if ( n.getNodeType() == Node.ELEMENT_NODE )
561                        {
562                            Element listElement = (Element) n;
563                            if ( "setString".equals( listElement.getName() ) )
564                            {
565                                setStrings.add( getTrimmedValue( listElement.getText() ) );
566                            }
567                            else
568                            {
569                            }
570                        }
571                    }
572                }
573                else if ( checkFieldWithDuplicate( childElement, "properties", null, parsed ) )
574                {
575                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
576                    {
577                        Node n = (Node) j.next();
578                        if ( n.getNodeType() == Node.ELEMENT_NODE )
579                        {
580                            Element listElement = (Element) n;
581                            String key = listElement.getName();
582                            String value = listElement.getText().trim();
583                            associationFeatures.addProperty( key, value );
584                        }
585                    }
586                }
587                else if ( checkFieldWithDuplicate( childElement, "bidi", null, parsed ) )
588                {
589                    associationFeatures.setBidi( parseBidirectional( "bidi", childElement, strict ) );
590                }
591                else if ( checkFieldWithDuplicate( childElement, "listOfBidis", null, parsed ) )
592                {
593                    java.util.List listOfBidis = new java.util.ArrayList/*<BidiInList>*/();
594                    associationFeatures.setListOfBidis( listOfBidis );
595                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
596                    {
597                        Node n = (Node) j.next();
598                        if ( n.getNodeType() == Node.ELEMENT_NODE )
599                        {
600                            Element listElement = (Element) n;
601                            if ( "listOfBidi".equals( listElement.getName() ) )
602                            {
603                                listOfBidis.add( parseBidiInList( "listOfBidi", listElement, strict ) );
604                            }
605                            else
606                            {
607                            }
608                        }
609                    }
610                }
611                else if ( checkFieldWithDuplicate( childElement, "setOfBidis", null, parsed ) )
612                {
613                    java.util.Set setOfBidis = new java.util.HashSet/*<BidiInSet>*/();
614                    associationFeatures.setSetOfBidis( setOfBidis );
615                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
616                    {
617                        Node n = (Node) j.next();
618                        if ( n.getNodeType() == Node.ELEMENT_NODE )
619                        {
620                            Element listElement = (Element) n;
621                            if ( "setOfBidi".equals( listElement.getName() ) )
622                            {
623                                setOfBidis.add( parseBidiInSet( "setOfBidi", listElement, strict ) );
624                            }
625                            else
626                            {
627                            }
628                        }
629                    }
630                }
631                else
632                {
633                    checkUnknownElement( childElement, strict );
634                }
635            }
636        }
637        return associationFeatures;
638    } //-- AssociationFeatures parseAssociationFeatures( String, Element, boolean )
639
640    /**
641     * Method parseBaseClass.
642     * 
643     * @param tagName
644     * @param strict
645     * @param element
646     * @throws IOException
647     * @throws DocumentException
648     * @return BaseClass
649     */
650    private BaseClass parseBaseClass( String tagName, Element element, boolean strict )
651        throws IOException, DocumentException
652    {
653        BaseClass baseClass = new BaseClass();
654        if ( element.attributeValue( "baseAttribute" ) != null  )
655        {
656            baseClass.setBaseAttribute( getIntegerValue( getTrimmedValue( element.attributeValue( "baseAttribute" ) ), "baseAttribute", strict ) );
657        }
658        java.util.Set parsed = new java.util.HashSet();
659        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
660        {
661            Node node = (Node) i.next();
662            if ( node.getNodeType() == Node.ELEMENT_NODE )
663            {
664                Element childElement = (Element) node;
665                if ( checkFieldWithDuplicate( childElement, "baseElement", null, parsed ) )
666                {
667                    baseClass.setBaseElement( getIntegerValue( getTrimmedValue( childElement.getText() ), "baseElement", strict ) );
668                }
669                else
670                {
671                    checkUnknownElement( childElement, strict );
672                }
673            }
674        }
675        return baseClass;
676    } //-- BaseClass parseBaseClass( String, Element, boolean )
677
678    /**
679     * Method parseBidiInList.
680     * 
681     * @param tagName
682     * @param strict
683     * @param element
684     * @throws IOException
685     * @throws DocumentException
686     * @return BidiInList
687     */
688    private BidiInList parseBidiInList( String tagName, Element element, boolean strict )
689        throws IOException, DocumentException
690    {
691        BidiInList bidiInList = new BidiInList();
692        java.util.Set parsed = new java.util.HashSet();
693        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
694        {
695            Node node = (Node) i.next();
696            if ( node.getNodeType() == Node.ELEMENT_NODE )
697            {
698                Element childElement = (Element) node;
699                if ( checkFieldWithDuplicate( childElement, "parent", null, parsed ) )
700                {
701                    bidiInList.setParent( parseAssociationFeatures( "parent", childElement, strict ) );
702                }
703                else
704                {
705                    checkUnknownElement( childElement, strict );
706                }
707            }
708        }
709        return bidiInList;
710    } //-- BidiInList parseBidiInList( String, Element, boolean )
711
712    /**
713     * Method parseBidiInSet.
714     * 
715     * @param tagName
716     * @param strict
717     * @param element
718     * @throws IOException
719     * @throws DocumentException
720     * @return BidiInSet
721     */
722    private BidiInSet parseBidiInSet( String tagName, Element element, boolean strict )
723        throws IOException, DocumentException
724    {
725        BidiInSet bidiInSet = new BidiInSet();
726        java.util.Set parsed = new java.util.HashSet();
727        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
728        {
729            Node node = (Node) i.next();
730            if ( node.getNodeType() == Node.ELEMENT_NODE )
731            {
732                Element childElement = (Element) node;
733                if ( checkFieldWithDuplicate( childElement, "parent", null, parsed ) )
734                {
735                    bidiInSet.setParent( parseAssociationFeatures( "parent", childElement, strict ) );
736                }
737                else
738                {
739                    checkUnknownElement( childElement, strict );
740                }
741            }
742        }
743        return bidiInSet;
744    } //-- BidiInSet parseBidiInSet( String, Element, boolean )
745
746    /**
747     * Method parseBidirectional.
748     * 
749     * @param tagName
750     * @param strict
751     * @param element
752     * @throws IOException
753     * @throws DocumentException
754     * @return Bidirectional
755     */
756    private Bidirectional parseBidirectional( String tagName, Element element, boolean strict )
757        throws IOException, DocumentException
758    {
759        Bidirectional bidirectional = new Bidirectional();
760        java.util.Set parsed = new java.util.HashSet();
761        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
762        {
763            Node node = (Node) i.next();
764            if ( node.getNodeType() == Node.ELEMENT_NODE )
765            {
766                Element childElement = (Element) node;
767                if ( checkFieldWithDuplicate( childElement, "parent", null, parsed ) )
768                {
769                    bidirectional.setParent( parseAssociationFeatures( "parent", childElement, strict ) );
770                }
771                else
772                {
773                    checkUnknownElement( childElement, strict );
774                }
775            }
776        }
777        return bidirectional;
778    } //-- Bidirectional parseBidirectional( String, Element, boolean )
779
780    /**
781     * Method parseContentTest.
782     * 
783     * @param tagName
784     * @param strict
785     * @param element
786     * @throws IOException
787     * @throws DocumentException
788     * @return ContentTest
789     */
790    private ContentTest parseContentTest( String tagName, Element element, boolean strict )
791        throws IOException, DocumentException
792    {
793        ContentTest contentTest = new ContentTest();
794        if ( element.attributeValue( "attr" ) != null  )
795        {
796            contentTest.setAttr( getTrimmedValue( element.attributeValue( "attr" ) ) );
797        }
798        if ( element.attributeValue( "attr2" ) != null  )
799        {
800            contentTest.setAttr2( getIntegerValue( getTrimmedValue( element.attributeValue( "attr2" ) ), "attr2", strict ) );
801        }
802        contentTest.setContent( getTrimmedValue( element.getText() ) );
803        return contentTest;
804    } //-- ContentTest parseContentTest( String, Element, boolean )
805
806    /**
807     * Method parseDueTo.
808     * 
809     * @param tagName
810     * @param strict
811     * @param element
812     * @throws IOException
813     * @throws DocumentException
814     * @return DueTo
815     */
816    private DueTo parseDueTo( String tagName, Element element, boolean strict )
817        throws IOException, DocumentException
818    {
819        DueTo dueTo = new DueTo();
820        if ( element.attributeValue( "name" ) != null  )
821        {
822            dueTo.setName( getTrimmedValue( element.attributeValue( "name" ) ) );
823        }
824        if ( element.attributeValue( "email" ) != null  )
825        {
826            dueTo.setEmail( getTrimmedValue( element.attributeValue( "email" ) ) );
827        }
828        java.util.Set parsed = new java.util.HashSet();
829        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
830        {
831            Node node = (Node) i.next();
832            if ( node.getNodeType() == Node.ELEMENT_NODE )
833            {
834                Element childElement = (Element) node;
835                checkUnknownElement( childElement, strict );
836            }
837        }
838        return dueTo;
839    } //-- DueTo parseDueTo( String, Element, boolean )
840
841    /**
842     * Method parseFeatures.
843     * 
844     * @param tagName
845     * @param strict
846     * @param element
847     * @throws IOException
848     * @throws DocumentException
849     * @return Features
850     */
851    private Features parseFeatures( String tagName, Element element, boolean strict )
852        throws IOException, DocumentException
853    {
854        Features features = new Features();
855        if ( strict )
856        {
857            if ( !element.getName().equals( tagName ) )
858            {
859                throw new DocumentException( "Error parsing model: root element tag is '" + element.getName() + "' instead of '" + tagName + "'" );
860            }
861        }
862        java.util.Set parsed = new java.util.HashSet();
863        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
864        {
865            Node node = (Node) i.next();
866            if ( node.getNodeType() == Node.ELEMENT_NODE )
867            {
868                Element childElement = (Element) node;
869                if ( checkFieldWithDuplicate( childElement, "versionField", null, parsed ) )
870                {
871                    features.setVersionField( getTrimmedValue( childElement.getText() ) );
872                }
873                else if ( checkFieldWithDuplicate( childElement, "comment", null, parsed ) )
874                {
875                    features.setComment( getTrimmedValue( childElement.getText() ) );
876                }
877                else if ( checkFieldWithDuplicate( childElement, "description", null, parsed ) )
878                {
879                    features.setDescription( getTrimmedValue( childElement.getText() ) );
880                }
881                else if ( checkFieldWithDuplicate( childElement, "required", null, parsed ) )
882                {
883                    features.setRequired( getTrimmedValue( childElement.getText() ) );
884                }
885                else if ( checkFieldWithDuplicate( childElement, "identifier", null, parsed ) )
886                {
887                    features.setIdentifier( getTrimmedValue( childElement.getText() ) );
888                }
889                else if ( checkFieldWithDuplicate( childElement, "identifierPart2", null, parsed ) )
890                {
891                    features.setIdentifierPart2( parseReference( "identifierPart2", childElement, strict ) );
892                }
893                else if ( checkFieldWithDuplicate( childElement, "simpleTypes", null, parsed ) )
894                {
895                    features.setSimpleTypes( parseSimpleTypes( "simpleTypes", childElement, strict ) );
896                }
897                else if ( checkFieldWithDuplicate( childElement, "defaultValues", null, parsed ) )
898                {
899                    features.setDefaultValues( parseSimpleTypes( "defaultValues", childElement, strict ) );
900                }
901                else if ( checkFieldWithDuplicate( childElement, "arrays", null, parsed ) )
902                {
903                    features.setArrays( parseArrayFeatures( "arrays", childElement, strict ) );
904                }
905                else if ( checkFieldWithDuplicate( childElement, "associationFeatures", null, parsed ) )
906                {
907                    features.setAssociationFeatures( parseAssociationFeatures( "associationFeatures", childElement, strict ) );
908                }
909                else if ( checkFieldWithDuplicate( childElement, "javaFeatures", null, parsed ) )
910                {
911                    features.setJavaFeatures( parseJavaFeatures( "javaFeatures", childElement, strict ) );
912                }
913                else if ( checkFieldWithDuplicate( childElement, "xmlFeatures", null, parsed ) )
914                {
915                    features.setXmlFeatures( parseXmlFeatures( "xmlFeatures", childElement, strict ) );
916                }
917                else if ( checkFieldWithDuplicate( childElement, "xdocFeatures", null, parsed ) )
918                {
919                    features.setXdocFeatures( parseXdocFeatures( "xdocFeatures", childElement, strict ) );
920                }
921                else if ( checkFieldWithDuplicate( childElement, "node", null, parsed ) )
922                {
923                    features.setNode( parseNodeItem( "node", childElement, strict ) );
924                }
925                else if ( checkFieldWithDuplicate( childElement, "cloneable", null, parsed ) )
926                {
927                    features.setCloneable( parseThing( "cloneable", childElement, strict ) );
928                }
929                else if ( checkFieldWithDuplicate( childElement, "file", null, parsed ) )
930                {
931                    features.setFile( parseFile( "file", childElement, strict ) );
932                }
933                else if ( checkFieldWithDuplicate( childElement, "action", null, parsed ) )
934                {
935                    features.setAction( parseAction( "action", childElement, strict ) );
936                }
937                else
938                {
939                    checkUnknownElement( childElement, strict );
940                }
941            }
942        }
943        return features;
944    } //-- Features parseFeatures( String, Element, boolean )
945
946    /**
947     * Method parseFile.
948     * 
949     * @param tagName
950     * @param strict
951     * @param element
952     * @throws IOException
953     * @throws DocumentException
954     * @return File
955     */
956    private File parseFile( String tagName, Element element, boolean strict )
957        throws IOException, DocumentException
958    {
959        File file = new File();
960        java.util.Set parsed = new java.util.HashSet();
961        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
962        {
963            Node node = (Node) i.next();
964            if ( node.getNodeType() == Node.ELEMENT_NODE )
965            {
966                Element childElement = (Element) node;
967                if ( checkFieldWithDuplicate( childElement, "file", null, parsed ) )
968                {
969                    file.setFile( getTrimmedValue( childElement.getText() ) );
970                }
971                else
972                {
973                    checkUnknownElement( childElement, strict );
974                }
975            }
976        }
977        return file;
978    } //-- File parseFile( String, Element, boolean )
979
980    /**
981     * Method parseInterfacesFeature.
982     * 
983     * @param tagName
984     * @param strict
985     * @param element
986     * @throws IOException
987     * @throws DocumentException
988     * @return InterfacesFeature
989     */
990    private InterfacesFeature parseInterfacesFeature( String tagName, Element element, boolean strict )
991        throws IOException, DocumentException
992    {
993        InterfacesFeature interfacesFeature = new InterfacesFeature();
994        java.util.Set parsed = new java.util.HashSet();
995        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
996        {
997            Node node = (Node) i.next();
998            if ( node.getNodeType() == Node.ELEMENT_NODE )
999            {
1000                Element childElement = (Element) node;
1001                if ( checkFieldWithDuplicate( childElement, "id", null, parsed ) )
1002                {
1003                    interfacesFeature.setId( getTrimmedValue( childElement.getText() ) );
1004                }
1005                else
1006                {
1007                    checkUnknownElement( childElement, strict );
1008                }
1009            }
1010        }
1011        return interfacesFeature;
1012    } //-- InterfacesFeature parseInterfacesFeature( String, Element, boolean )
1013
1014    /**
1015     * Method parseJavaFeatures.
1016     * 
1017     * @param tagName
1018     * @param strict
1019     * @param element
1020     * @throws IOException
1021     * @throws DocumentException
1022     * @return JavaFeatures
1023     */
1024    private JavaFeatures parseJavaFeatures( String tagName, Element element, boolean strict )
1025        throws IOException, DocumentException
1026    {
1027        JavaFeatures javaFeatures = new JavaFeatures();
1028        java.util.Set parsed = new java.util.HashSet();
1029        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1030        {
1031            Node node = (Node) i.next();
1032            if ( node.getNodeType() == Node.ELEMENT_NODE )
1033            {
1034                Element childElement = (Element) node;
1035                if ( checkFieldWithDuplicate( childElement, "interfaces", null, parsed ) )
1036                {
1037                    javaFeatures.setInterfaces( parseInterfacesFeature( "interfaces", childElement, strict ) );
1038                }
1039                else if ( checkFieldWithDuplicate( childElement, "packageName", null, parsed ) )
1040                {
1041                    javaFeatures.setPackageName( parsePackageNameFeature( "packageName", childElement, strict ) );
1042                }
1043                else if ( checkFieldWithDuplicate( childElement, "base", null, parsed ) )
1044                {
1045                    javaFeatures.setBase( parseBaseClass( "base", childElement, strict ) );
1046                }
1047                else if ( checkFieldWithDuplicate( childElement, "subClass", null, parsed ) )
1048                {
1049                    javaFeatures.setSubClass( parseSubClassLevel1( "subClass", childElement, strict ) );
1050                }
1051                else if ( checkFieldWithDuplicate( childElement, "subClass2", null, parsed ) )
1052                {
1053                    javaFeatures.setSubClass2( parseSubClassLevel2( "subClass2", childElement, strict ) );
1054                }
1055                else if ( checkFieldWithDuplicate( childElement, "subClass3", null, parsed ) )
1056                {
1057                    javaFeatures.setSubClass3( parseSubClassLevel3( "subClass3", childElement, strict ) );
1058                }
1059                else if ( checkFieldWithDuplicate( childElement, "annotation", null, parsed ) )
1060                {
1061                    javaFeatures.setAnnotation( parseAnnotationTest( "annotation", childElement, strict ) );
1062                }
1063                else
1064                {
1065                    checkUnknownElement( childElement, strict );
1066                }
1067            }
1068        }
1069        return javaFeatures;
1070    } //-- JavaFeatures parseJavaFeatures( String, Element, boolean )
1071
1072    /**
1073     * Method parseNodeItem.
1074     * 
1075     * @param tagName
1076     * @param strict
1077     * @param element
1078     * @throws IOException
1079     * @throws DocumentException
1080     * @return NodeItem
1081     */
1082    private NodeItem parseNodeItem( String tagName, Element element, boolean strict )
1083        throws IOException, DocumentException
1084    {
1085        NodeItem nodeItem = new NodeItem();
1086        java.util.Set parsed = new java.util.HashSet();
1087        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1088        {
1089            Node node = (Node) i.next();
1090            if ( node.getNodeType() == Node.ELEMENT_NODE )
1091            {
1092                Element childElement = (Element) node;
1093                if ( checkFieldWithDuplicate( childElement, "value", null, parsed ) )
1094                {
1095                    nodeItem.setValue( getTrimmedValue( childElement.getText() ) );
1096                }
1097                else if ( checkFieldWithDuplicate( childElement, "child", null, parsed ) )
1098                {
1099                    nodeItem.setChild( parseNodeItem( "child", childElement, strict ) );
1100                }
1101                else
1102                {
1103                    checkUnknownElement( childElement, strict );
1104                }
1105            }
1106        }
1107        return nodeItem;
1108    } //-- NodeItem parseNodeItem( String, Element, boolean )
1109
1110    /**
1111     * Method parsePackageNameFeature.
1112     * 
1113     * @param tagName
1114     * @param strict
1115     * @param element
1116     * @throws IOException
1117     * @throws DocumentException
1118     * @return PackageNameFeature
1119     */
1120    private PackageNameFeature parsePackageNameFeature( String tagName, Element element, boolean strict )
1121        throws IOException, DocumentException
1122    {
1123        PackageNameFeature packageNameFeature = new PackageNameFeature();
1124        java.util.Set parsed = new java.util.HashSet();
1125        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1126        {
1127            Node node = (Node) i.next();
1128            if ( node.getNodeType() == Node.ELEMENT_NODE )
1129            {
1130                Element childElement = (Element) node;
1131                if ( checkFieldWithDuplicate( childElement, "reference", null, parsed ) )
1132                {
1133                    packageNameFeature.setReference( parseReference( "reference", childElement, strict ) );
1134                }
1135                else
1136                {
1137                    checkUnknownElement( childElement, strict );
1138                }
1139            }
1140        }
1141        return packageNameFeature;
1142    } //-- PackageNameFeature parsePackageNameFeature( String, Element, boolean )
1143
1144    /**
1145     * Method parseReference.
1146     * 
1147     * @param tagName
1148     * @param strict
1149     * @param element
1150     * @throws IOException
1151     * @throws DocumentException
1152     * @return Reference
1153     */
1154    private Reference parseReference( String tagName, Element element, boolean strict )
1155        throws IOException, DocumentException
1156    {
1157        Reference reference = new Reference();
1158        java.util.Set parsed = new java.util.HashSet();
1159        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1160        {
1161            Node node = (Node) i.next();
1162            if ( node.getNodeType() == Node.ELEMENT_NODE )
1163            {
1164                Element childElement = (Element) node;
1165                if ( checkFieldWithDuplicate( childElement, "id", "key", parsed ) )
1166                {
1167                    reference.setId( getTrimmedValue( childElement.getText() ) );
1168                }
1169                else
1170                {
1171                    checkUnknownElement( childElement, strict );
1172                }
1173            }
1174        }
1175        return reference;
1176    } //-- Reference parseReference( String, Element, boolean )
1177
1178    /**
1179     * Method parseSimpleTypes.
1180     * 
1181     * @param tagName
1182     * @param strict
1183     * @param element
1184     * @throws IOException
1185     * @throws DocumentException
1186     * @return SimpleTypes
1187     */
1188    private SimpleTypes parseSimpleTypes( String tagName, Element element, boolean strict )
1189        throws IOException, DocumentException
1190    {
1191        SimpleTypes simpleTypes = new SimpleTypes();
1192        java.util.Set parsed = new java.util.HashSet();
1193        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1194        {
1195            Node node = (Node) i.next();
1196            if ( node.getNodeType() == Node.ELEMENT_NODE )
1197            {
1198                Element childElement = (Element) node;
1199                if ( checkFieldWithDuplicate( childElement, "primitiveBoolean", null, parsed ) )
1200                {
1201                    simpleTypes.setPrimitiveBoolean( getBooleanValue( getTrimmedValue( childElement.getText() ), "primitiveBoolean" ) );
1202                }
1203                else if ( checkFieldWithDuplicate( childElement, "primitiveChar", null, parsed ) )
1204                {
1205                    simpleTypes.setPrimitiveChar( getCharacterValue( getTrimmedValue( childElement.getText() ), "primitiveChar" ) );
1206                }
1207                else if ( checkFieldWithDuplicate( childElement, "primitiveByte", null, parsed ) )
1208                {
1209                    simpleTypes.setPrimitiveByte( getByteValue( getTrimmedValue( childElement.getText() ), "primitiveByte", strict ) );
1210                }
1211                else if ( checkFieldWithDuplicate( childElement, "primitiveShort", null, parsed ) )
1212                {
1213                    simpleTypes.setPrimitiveShort( getShortValue( getTrimmedValue( childElement.getText() ), "primitiveShort", strict ) );
1214                }
1215                else if ( checkFieldWithDuplicate( childElement, "primitiveInt", null, parsed ) )
1216                {
1217                    simpleTypes.setPrimitiveInt( getIntegerValue( getTrimmedValue( childElement.getText() ), "primitiveInt", strict ) );
1218                }
1219                else if ( checkFieldWithDuplicate( childElement, "primitiveLong", null, parsed ) )
1220                {
1221                    simpleTypes.setPrimitiveLong( getLongValue( getTrimmedValue( childElement.getText() ), "primitiveLong", strict ) );
1222                }
1223                else if ( checkFieldWithDuplicate( childElement, "primitiveFloat", null, parsed ) )
1224                {
1225                    simpleTypes.setPrimitiveFloat( getFloatValue( getTrimmedValue( childElement.getText() ), "primitiveFloat", strict ) );
1226                }
1227                else if ( checkFieldWithDuplicate( childElement, "primitiveDouble", null, parsed ) )
1228                {
1229                    simpleTypes.setPrimitiveDouble( getDoubleValue( getTrimmedValue( childElement.getText() ), "primitiveDouble", strict ) );
1230                }
1231                else if ( checkFieldWithDuplicate( childElement, "objectString", null, parsed ) )
1232                {
1233                    simpleTypes.setObjectString( getTrimmedValue( childElement.getText() ) );
1234                }
1235                else if ( checkFieldWithDuplicate( childElement, "objectDate", null, parsed ) )
1236                {
1237                    String dateFormat = null;
1238                    simpleTypes.setObjectDate( getDateValue( getTrimmedValue( childElement.getText() ), "objectDate", dateFormat ) );
1239                }
1240                else if ( checkFieldWithDuplicate( childElement, "primitiveBooleanNoDefault", null, parsed ) )
1241                {
1242                    simpleTypes.setPrimitiveBooleanNoDefault( getBooleanValue( getTrimmedValue( childElement.getText() ), "primitiveBooleanNoDefault" ) );
1243                }
1244                else if ( checkFieldWithDuplicate( childElement, "primitiveCharNoDefault", null, parsed ) )
1245                {
1246                    simpleTypes.setPrimitiveCharNoDefault( getCharacterValue( getTrimmedValue( childElement.getText() ), "primitiveCharNoDefault" ) );
1247                }
1248                else if ( checkFieldWithDuplicate( childElement, "primitiveByteNoDefault", null, parsed ) )
1249                {
1250                    simpleTypes.setPrimitiveByteNoDefault( getByteValue( getTrimmedValue( childElement.getText() ), "primitiveByteNoDefault", strict ) );
1251                }
1252                else if ( checkFieldWithDuplicate( childElement, "primitiveShortNoDefault", null, parsed ) )
1253                {
1254                    simpleTypes.setPrimitiveShortNoDefault( getShortValue( getTrimmedValue( childElement.getText() ), "primitiveShortNoDefault", strict ) );
1255                }
1256                else if ( checkFieldWithDuplicate( childElement, "primitiveIntNoDefault", null, parsed ) )
1257                {
1258                    simpleTypes.setPrimitiveIntNoDefault( getIntegerValue( getTrimmedValue( childElement.getText() ), "primitiveIntNoDefault", strict ) );
1259                }
1260                else if ( checkFieldWithDuplicate( childElement, "primitiveLongNoDefault", null, parsed ) )
1261                {
1262                    simpleTypes.setPrimitiveLongNoDefault( getLongValue( getTrimmedValue( childElement.getText() ), "primitiveLongNoDefault", strict ) );
1263                }
1264                else if ( checkFieldWithDuplicate( childElement, "primitiveFloatNoDefault", null, parsed ) )
1265                {
1266                    simpleTypes.setPrimitiveFloatNoDefault( getFloatValue( getTrimmedValue( childElement.getText() ), "primitiveFloatNoDefault", strict ) );
1267                }
1268                else if ( checkFieldWithDuplicate( childElement, "primitiveDoubleNoDefault", null, parsed ) )
1269                {
1270                    simpleTypes.setPrimitiveDoubleNoDefault( getDoubleValue( getTrimmedValue( childElement.getText() ), "primitiveDoubleNoDefault", strict ) );
1271                }
1272                else if ( checkFieldWithDuplicate( childElement, "objectStringNoDefault", null, parsed ) )
1273                {
1274                    simpleTypes.setObjectStringNoDefault( getTrimmedValue( childElement.getText() ) );
1275                }
1276                else if ( checkFieldWithDuplicate( childElement, "objectDateNoDefault", null, parsed ) )
1277                {
1278                    String dateFormat = null;
1279                    simpleTypes.setObjectDateNoDefault( getDateValue( getTrimmedValue( childElement.getText() ), "objectDateNoDefault", dateFormat ) );
1280                }
1281                else if ( checkFieldWithDuplicate( childElement, "dom", null, parsed ) )
1282                {
1283                    simpleTypes.setDom( writeElementToXpp3Dom( childElement ) );
1284                }
1285                else if ( checkFieldWithDuplicate( childElement, "content", null, parsed ) )
1286                {
1287                    simpleTypes.setContent( parseContentTest( "content", childElement, strict ) );
1288                }
1289                else
1290                {
1291                    checkUnknownElement( childElement, strict );
1292                }
1293            }
1294        }
1295        return simpleTypes;
1296    } //-- SimpleTypes parseSimpleTypes( String, Element, boolean )
1297
1298    /**
1299     * Method parseSubClassLevel1.
1300     * 
1301     * @param tagName
1302     * @param strict
1303     * @param element
1304     * @throws IOException
1305     * @throws DocumentException
1306     * @return SubClassLevel1
1307     */
1308    private SubClassLevel1 parseSubClassLevel1( String tagName, Element element, boolean strict )
1309        throws IOException, DocumentException
1310    {
1311        SubClassLevel1 subClassLevel1 = new SubClassLevel1();
1312        if ( element.attributeValue( "subAttribute1" ) != null  )
1313        {
1314            subClassLevel1.setSubAttribute1( getLongValue( getTrimmedValue( element.attributeValue( "subAttribute1" ) ), "subAttribute1", strict ) );
1315        }
1316        if ( element.attributeValue( "baseAttribute" ) != null  )
1317        {
1318            subClassLevel1.setBaseAttribute( getIntegerValue( getTrimmedValue( element.attributeValue( "baseAttribute" ) ), "baseAttribute", strict ) );
1319        }
1320        java.util.Set parsed = new java.util.HashSet();
1321        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1322        {
1323            Node node = (Node) i.next();
1324            if ( node.getNodeType() == Node.ELEMENT_NODE )
1325            {
1326                Element childElement = (Element) node;
1327                if ( checkFieldWithDuplicate( childElement, "subElement1", null, parsed ) )
1328                {
1329                    subClassLevel1.setSubElement1( getLongValue( getTrimmedValue( childElement.getText() ), "subElement1", strict ) );
1330                }
1331                else if ( checkFieldWithDuplicate( childElement, "baseElement", null, parsed ) )
1332                {
1333                    subClassLevel1.setBaseElement( getIntegerValue( getTrimmedValue( childElement.getText() ), "baseElement", strict ) );
1334                }
1335                else
1336                {
1337                    checkUnknownElement( childElement, strict );
1338                }
1339            }
1340        }
1341        return subClassLevel1;
1342    } //-- SubClassLevel1 parseSubClassLevel1( String, Element, boolean )
1343
1344    /**
1345     * Method parseSubClassLevel2.
1346     * 
1347     * @param tagName
1348     * @param strict
1349     * @param element
1350     * @throws IOException
1351     * @throws DocumentException
1352     * @return SubClassLevel2
1353     */
1354    private SubClassLevel2 parseSubClassLevel2( String tagName, Element element, boolean strict )
1355        throws IOException, DocumentException
1356    {
1357        SubClassLevel2 subClassLevel2 = new SubClassLevel2();
1358        if ( element.attributeValue( "subAttribute2" ) != null  )
1359        {
1360            subClassLevel2.setSubAttribute2( getFloatValue( getTrimmedValue( element.attributeValue( "subAttribute2" ) ), "subAttribute2", strict ) );
1361        }
1362        if ( element.attributeValue( "subAttribute1" ) != null  )
1363        {
1364            subClassLevel2.setSubAttribute1( getLongValue( getTrimmedValue( element.attributeValue( "subAttribute1" ) ), "subAttribute1", strict ) );
1365        }
1366        if ( element.attributeValue( "baseAttribute" ) != null  )
1367        {
1368            subClassLevel2.setBaseAttribute( getIntegerValue( getTrimmedValue( element.attributeValue( "baseAttribute" ) ), "baseAttribute", strict ) );
1369        }
1370        java.util.Set parsed = new java.util.HashSet();
1371        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1372        {
1373            Node node = (Node) i.next();
1374            if ( node.getNodeType() == Node.ELEMENT_NODE )
1375            {
1376                Element childElement = (Element) node;
1377                if ( checkFieldWithDuplicate( childElement, "subElement2", null, parsed ) )
1378                {
1379                    subClassLevel2.setSubElement2( getFloatValue( getTrimmedValue( childElement.getText() ), "subElement2", strict ) );
1380                }
1381                else if ( checkFieldWithDuplicate( childElement, "subElement1", null, parsed ) )
1382                {
1383                    subClassLevel2.setSubElement1( getLongValue( getTrimmedValue( childElement.getText() ), "subElement1", strict ) );
1384                }
1385                else if ( checkFieldWithDuplicate( childElement, "baseElement", null, parsed ) )
1386                {
1387                    subClassLevel2.setBaseElement( getIntegerValue( getTrimmedValue( childElement.getText() ), "baseElement", strict ) );
1388                }
1389                else
1390                {
1391                    checkUnknownElement( childElement, strict );
1392                }
1393            }
1394        }
1395        return subClassLevel2;
1396    } //-- SubClassLevel2 parseSubClassLevel2( String, Element, boolean )
1397
1398    /**
1399     * Method parseSubClassLevel3.
1400     * 
1401     * @param tagName
1402     * @param strict
1403     * @param element
1404     * @throws IOException
1405     * @throws DocumentException
1406     * @return SubClassLevel3
1407     */
1408    private SubClassLevel3 parseSubClassLevel3( String tagName, Element element, boolean strict )
1409        throws IOException, DocumentException
1410    {
1411        SubClassLevel3 subClassLevel3 = new SubClassLevel3();
1412        if ( element.attributeValue( "subAttribute3" ) != null  )
1413        {
1414            subClassLevel3.setSubAttribute3( getDoubleValue( getTrimmedValue( element.attributeValue( "subAttribute3" ) ), "subAttribute3", strict ) );
1415        }
1416        if ( element.attributeValue( "subAttribute2" ) != null  )
1417        {
1418            subClassLevel3.setSubAttribute2( getFloatValue( getTrimmedValue( element.attributeValue( "subAttribute2" ) ), "subAttribute2", strict ) );
1419        }
1420        if ( element.attributeValue( "subAttribute1" ) != null  )
1421        {
1422            subClassLevel3.setSubAttribute1( getLongValue( getTrimmedValue( element.attributeValue( "subAttribute1" ) ), "subAttribute1", strict ) );
1423        }
1424        if ( element.attributeValue( "baseAttribute" ) != null  )
1425        {
1426            subClassLevel3.setBaseAttribute( getIntegerValue( getTrimmedValue( element.attributeValue( "baseAttribute" ) ), "baseAttribute", strict ) );
1427        }
1428        java.util.Set parsed = new java.util.HashSet();
1429        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1430        {
1431            Node node = (Node) i.next();
1432            if ( node.getNodeType() == Node.ELEMENT_NODE )
1433            {
1434                Element childElement = (Element) node;
1435                if ( checkFieldWithDuplicate( childElement, "subElement3", null, parsed ) )
1436                {
1437                    subClassLevel3.setSubElement3( getDoubleValue( getTrimmedValue( childElement.getText() ), "subElement3", strict ) );
1438                }
1439                else if ( checkFieldWithDuplicate( childElement, "subElement2", null, parsed ) )
1440                {
1441                    subClassLevel3.setSubElement2( getFloatValue( getTrimmedValue( childElement.getText() ), "subElement2", strict ) );
1442                }
1443                else if ( checkFieldWithDuplicate( childElement, "subElement1", null, parsed ) )
1444                {
1445                    subClassLevel3.setSubElement1( getLongValue( getTrimmedValue( childElement.getText() ), "subElement1", strict ) );
1446                }
1447                else if ( checkFieldWithDuplicate( childElement, "baseElement", null, parsed ) )
1448                {
1449                    subClassLevel3.setBaseElement( getIntegerValue( getTrimmedValue( childElement.getText() ), "baseElement", strict ) );
1450                }
1451                else
1452                {
1453                    checkUnknownElement( childElement, strict );
1454                }
1455            }
1456        }
1457        return subClassLevel3;
1458    } //-- SubClassLevel3 parseSubClassLevel3( String, Element, boolean )
1459
1460    /**
1461     * Method parseSuperThing.
1462     * 
1463     * @param tagName
1464     * @param strict
1465     * @param element
1466     * @throws IOException
1467     * @throws DocumentException
1468     * @return SuperThing
1469     */
1470    private SuperThing parseSuperThing( String tagName, Element element, boolean strict )
1471        throws IOException, DocumentException
1472    {
1473        SuperThing superThing = new SuperThing();
1474        java.util.Set parsed = new java.util.HashSet();
1475        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1476        {
1477            Node node = (Node) i.next();
1478            if ( node.getNodeType() == Node.ELEMENT_NODE )
1479            {
1480                Element childElement = (Element) node;
1481                checkUnknownElement( childElement, strict );
1482            }
1483        }
1484        return superThing;
1485    } //-- SuperThing parseSuperThing( String, Element, boolean )
1486
1487    /**
1488     * Method parseThing.
1489     * 
1490     * @param tagName
1491     * @param strict
1492     * @param element
1493     * @throws IOException
1494     * @throws DocumentException
1495     * @return Thing
1496     */
1497    private Thing parseThing( String tagName, Element element, boolean strict )
1498        throws IOException, DocumentException
1499    {
1500        Thing thing = new Thing();
1501        java.util.Set parsed = new java.util.HashSet();
1502        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1503        {
1504            Node node = (Node) i.next();
1505            if ( node.getNodeType() == Node.ELEMENT_NODE )
1506            {
1507                Element childElement = (Element) node;
1508                if ( checkFieldWithDuplicate( childElement, "someBoolean", null, parsed ) )
1509                {
1510                    thing.setSomeBoolean( getBooleanValue( getTrimmedValue( childElement.getText() ), "someBoolean" ) );
1511                }
1512                else if ( checkFieldWithDuplicate( childElement, "someChar", null, parsed ) )
1513                {
1514                    thing.setSomeChar( getCharacterValue( getTrimmedValue( childElement.getText() ), "someChar" ) );
1515                }
1516                else if ( checkFieldWithDuplicate( childElement, "someByte", null, parsed ) )
1517                {
1518                    thing.setSomeByte( getByteValue( getTrimmedValue( childElement.getText() ), "someByte", strict ) );
1519                }
1520                else if ( checkFieldWithDuplicate( childElement, "someShort", null, parsed ) )
1521                {
1522                    thing.setSomeShort( getShortValue( getTrimmedValue( childElement.getText() ), "someShort", strict ) );
1523                }
1524                else if ( checkFieldWithDuplicate( childElement, "someInt", null, parsed ) )
1525                {
1526                    thing.setSomeInt( getIntegerValue( getTrimmedValue( childElement.getText() ), "someInt", strict ) );
1527                }
1528                else if ( checkFieldWithDuplicate( childElement, "someLong", null, parsed ) )
1529                {
1530                    thing.setSomeLong( getLongValue( getTrimmedValue( childElement.getText() ), "someLong", strict ) );
1531                }
1532                else if ( checkFieldWithDuplicate( childElement, "someFloat", null, parsed ) )
1533                {
1534                    thing.setSomeFloat( getFloatValue( getTrimmedValue( childElement.getText() ), "someFloat", strict ) );
1535                }
1536                else if ( checkFieldWithDuplicate( childElement, "someDouble", null, parsed ) )
1537                {
1538                    thing.setSomeDouble( getDoubleValue( getTrimmedValue( childElement.getText() ), "someDouble", strict ) );
1539                }
1540                else if ( checkFieldWithDuplicate( childElement, "someString", null, parsed ) )
1541                {
1542                    thing.setSomeString( getTrimmedValue( childElement.getText() ) );
1543                }
1544                else if ( checkFieldWithDuplicate( childElement, "someDate", null, parsed ) )
1545                {
1546                    String dateFormat = null;
1547                    thing.setSomeDate( getDateValue( getTrimmedValue( childElement.getText() ), "someDate", dateFormat ) );
1548                }
1549                else if ( checkFieldWithDuplicate( childElement, "someDom", null, parsed ) )
1550                {
1551                    thing.setSomeDom( writeElementToXpp3Dom( childElement ) );
1552                }
1553                else if ( checkFieldWithDuplicate( childElement, "someProperties", null, parsed ) )
1554                {
1555                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1556                    {
1557                        Node n = (Node) j.next();
1558                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1559                        {
1560                            Element listElement = (Element) n;
1561                            String key = listElement.getName();
1562                            String value = listElement.getText().trim();
1563                            thing.addSomeProperty( key, value );
1564                        }
1565                    }
1566                }
1567                else if ( checkFieldWithDuplicate( childElement, "someStringList", null, parsed ) )
1568                {
1569                    java.util.List someStringList = new java.util.ArrayList/*<String>*/();
1570                    thing.setSomeStringList( someStringList );
1571                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1572                    {
1573                        Node n = (Node) j.next();
1574                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1575                        {
1576                            Element listElement = (Element) n;
1577                            if ( "someStringList".equals( listElement.getName() ) )
1578                            {
1579                                someStringList.add( getTrimmedValue( listElement.getText() ) );
1580                            }
1581                            else
1582                            {
1583                            }
1584                        }
1585                    }
1586                }
1587                else if ( checkFieldWithDuplicate( childElement, "someStringSet", null, parsed ) )
1588                {
1589                    java.util.Set someStringSet = new java.util.HashSet/*<String>*/();
1590                    thing.setSomeStringSet( someStringSet );
1591                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1592                    {
1593                        Node n = (Node) j.next();
1594                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1595                        {
1596                            Element listElement = (Element) n;
1597                            if ( "someStringSet".equals( listElement.getName() ) )
1598                            {
1599                                someStringSet.add( getTrimmedValue( listElement.getText() ) );
1600                            }
1601                            else
1602                            {
1603                            }
1604                        }
1605                    }
1606                }
1607                else if ( checkFieldWithDuplicate( childElement, "deepThingy", null, parsed ) )
1608                {
1609                    thing.setDeepThingy( parseThingy( "deepThingy", childElement, strict ) );
1610                }
1611                else if ( checkFieldWithDuplicate( childElement, "deepThingyList", null, parsed ) )
1612                {
1613                    java.util.List deepThingyList = new java.util.ArrayList/*<Thingy>*/();
1614                    thing.setDeepThingyList( deepThingyList );
1615                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1616                    {
1617                        Node n = (Node) j.next();
1618                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1619                        {
1620                            Element listElement = (Element) n;
1621                            if ( "deepThingyList".equals( listElement.getName() ) )
1622                            {
1623                                deepThingyList.add( parseThingy( "deepThingyList", listElement, strict ) );
1624                            }
1625                            else
1626                            {
1627                            }
1628                        }
1629                    }
1630                }
1631                else if ( checkFieldWithDuplicate( childElement, "deepThingySet", null, parsed ) )
1632                {
1633                    java.util.Set deepThingySet = new java.util.HashSet/*<Thingy>*/();
1634                    thing.setDeepThingySet( deepThingySet );
1635                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1636                    {
1637                        Node n = (Node) j.next();
1638                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1639                        {
1640                            Element listElement = (Element) n;
1641                            if ( "deepThingySet".equals( listElement.getName() ) )
1642                            {
1643                                deepThingySet.add( parseThingy( "deepThingySet", listElement, strict ) );
1644                            }
1645                            else
1646                            {
1647                            }
1648                        }
1649                    }
1650                }
1651                else if ( checkFieldWithDuplicate( childElement, "shallowThingy", null, parsed ) )
1652                {
1653                    thing.setShallowThingy( parseThingy( "shallowThingy", childElement, strict ) );
1654                }
1655                else if ( checkFieldWithDuplicate( childElement, "shallowThingyList", null, parsed ) )
1656                {
1657                    java.util.List shallowThingyList = new java.util.ArrayList/*<Thingy>*/();
1658                    thing.setShallowThingyList( shallowThingyList );
1659                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1660                    {
1661                        Node n = (Node) j.next();
1662                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1663                        {
1664                            Element listElement = (Element) n;
1665                            if ( "shallowThingyList".equals( listElement.getName() ) )
1666                            {
1667                                shallowThingyList.add( parseThingy( "shallowThingyList", listElement, strict ) );
1668                            }
1669                            else
1670                            {
1671                            }
1672                        }
1673                    }
1674                }
1675                else if ( checkFieldWithDuplicate( childElement, "shallowThingySet", null, parsed ) )
1676                {
1677                    java.util.Set shallowThingySet = new java.util.HashSet/*<Thingy>*/();
1678                    thing.setShallowThingySet( shallowThingySet );
1679                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
1680                    {
1681                        Node n = (Node) j.next();
1682                        if ( n.getNodeType() == Node.ELEMENT_NODE )
1683                        {
1684                            Element listElement = (Element) n;
1685                            if ( "shallowThingySet".equals( listElement.getName() ) )
1686                            {
1687                                shallowThingySet.add( parseThingy( "shallowThingySet", listElement, strict ) );
1688                            }
1689                            else
1690                            {
1691                            }
1692                        }
1693                    }
1694                }
1695                else
1696                {
1697                    checkUnknownElement( childElement, strict );
1698                }
1699            }
1700        }
1701        return thing;
1702    } //-- Thing parseThing( String, Element, boolean )
1703
1704    /**
1705     * Method parseThingy.
1706     * 
1707     * @param tagName
1708     * @param strict
1709     * @param element
1710     * @throws IOException
1711     * @throws DocumentException
1712     * @return Thingy
1713     */
1714    private Thingy parseThingy( String tagName, Element element, boolean strict )
1715        throws IOException, DocumentException
1716    {
1717        Thingy thingy = new Thingy();
1718        thingy.setSomeContent( getTrimmedValue( element.getText() ) );
1719        return thingy;
1720    } //-- Thingy parseThingy( String, Element, boolean )
1721
1722    /**
1723     * Method parseXdocFeatures.
1724     * 
1725     * @param tagName
1726     * @param strict
1727     * @param element
1728     * @throws IOException
1729     * @throws DocumentException
1730     * @return XdocFeatures
1731     */
1732    private XdocFeatures parseXdocFeatures( String tagName, Element element, boolean strict )
1733        throws IOException, DocumentException
1734    {
1735        XdocFeatures xdocFeatures = new XdocFeatures();
1736        java.util.Set parsed = new java.util.HashSet();
1737        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1738        {
1739            Node node = (Node) i.next();
1740            if ( node.getNodeType() == Node.ELEMENT_NODE )
1741            {
1742                Element childElement = (Element) node;
1743                if ( checkFieldWithDuplicate( childElement, "field", null, parsed ) )
1744                {
1745                    xdocFeatures.setField( getTrimmedValue( childElement.getText() ) );
1746                }
1747                else if ( checkFieldWithDuplicate( childElement, "xdocSeparatorNone", null, parsed ) )
1748                {
1749                    xdocFeatures.setXdocSeparatorNone( getTrimmedValue( childElement.getText() ) );
1750                }
1751                else if ( checkFieldWithDuplicate( childElement, "xdocSeparatorBlank", null, parsed ) )
1752                {
1753                    xdocFeatures.setXdocSeparatorBlank( getTrimmedValue( childElement.getText() ) );
1754                }
1755                else
1756                {
1757                    checkUnknownElement( childElement, strict );
1758                }
1759            }
1760        }
1761        return xdocFeatures;
1762    } //-- XdocFeatures parseXdocFeatures( String, Element, boolean )
1763
1764    /**
1765     * Method parseXmlAttributes.
1766     * 
1767     * @param tagName
1768     * @param strict
1769     * @param element
1770     * @throws IOException
1771     * @throws DocumentException
1772     * @return XmlAttributes
1773     */
1774    private XmlAttributes parseXmlAttributes( String tagName, Element element, boolean strict )
1775        throws IOException, DocumentException
1776    {
1777        XmlAttributes xmlAttributes = new XmlAttributes();
1778        if ( element.attributeValue( "primitiveBoolean" ) != null  )
1779        {
1780            xmlAttributes.setPrimitiveBoolean( getBooleanValue( getTrimmedValue( element.attributeValue( "primitiveBoolean" ) ), "primitiveBoolean" ) );
1781        }
1782        if ( element.attributeValue( "primitiveChar" ) != null  )
1783        {
1784            xmlAttributes.setPrimitiveChar( getCharacterValue( getTrimmedValue( element.attributeValue( "primitiveChar" ) ), "primitiveChar" ) );
1785        }
1786        if ( element.attributeValue( "primitiveByte" ) != null  )
1787        {
1788            xmlAttributes.setPrimitiveByte( getByteValue( getTrimmedValue( element.attributeValue( "primitiveByte" ) ), "primitiveByte", strict ) );
1789        }
1790        if ( element.attributeValue( "primitiveShort" ) != null  )
1791        {
1792            xmlAttributes.setPrimitiveShort( getShortValue( getTrimmedValue( element.attributeValue( "primitiveShort" ) ), "primitiveShort", strict ) );
1793        }
1794        if ( element.attributeValue( "primitiveInt" ) != null  )
1795        {
1796            xmlAttributes.setPrimitiveInt( getIntegerValue( getTrimmedValue( element.attributeValue( "primitiveInt" ) ), "primitiveInt", strict ) );
1797        }
1798        if ( element.attributeValue( "primitiveLong" ) != null  )
1799        {
1800            xmlAttributes.setPrimitiveLong( getLongValue( getTrimmedValue( element.attributeValue( "primitiveLong" ) ), "primitiveLong", strict ) );
1801        }
1802        if ( element.attributeValue( "primitiveFloat" ) != null  )
1803        {
1804            xmlAttributes.setPrimitiveFloat( getFloatValue( getTrimmedValue( element.attributeValue( "primitiveFloat" ) ), "primitiveFloat", strict ) );
1805        }
1806        if ( element.attributeValue( "primitiveDouble" ) != null  )
1807        {
1808            xmlAttributes.setPrimitiveDouble( getDoubleValue( getTrimmedValue( element.attributeValue( "primitiveDouble" ) ), "primitiveDouble", strict ) );
1809        }
1810        if ( element.attributeValue( "objectString" ) != null  )
1811        {
1812            xmlAttributes.setObjectString( getTrimmedValue( element.attributeValue( "objectString" ) ) );
1813        }
1814        if ( element.attributeValue( "objectDate" ) != null  )
1815        {
1816            String dateFormat = null;
1817            xmlAttributes.setObjectDate( getDateValue( getTrimmedValue( element.attributeValue( "objectDate" ) ), "objectDate", dateFormat ) );
1818        }
1819        if ( element.attributeValue( "tag-name" ) != null  )
1820        {
1821            xmlAttributes.setAttribute( getTrimmedValue( element.attributeValue( "tag-name" ) ) );
1822        }
1823        java.util.Set parsed = new java.util.HashSet();
1824        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1825        {
1826            Node node = (Node) i.next();
1827            if ( node.getNodeType() == Node.ELEMENT_NODE )
1828            {
1829                Element childElement = (Element) node;
1830                checkUnknownElement( childElement, strict );
1831            }
1832        }
1833        return xmlAttributes;
1834    } //-- XmlAttributes parseXmlAttributes( String, Element, boolean )
1835
1836    /**
1837     * Method parseXmlContent.
1838     * 
1839     * @param tagName
1840     * @param strict
1841     * @param element
1842     * @throws IOException
1843     * @throws DocumentException
1844     * @return XmlContent
1845     */
1846    private XmlContent parseXmlContent( String tagName, Element element, boolean strict )
1847        throws IOException, DocumentException
1848    {
1849        XmlContent xmlContent = new XmlContent();
1850        java.util.Set parsed = new java.util.HashSet();
1851        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1852        {
1853            Node node = (Node) i.next();
1854            if ( node.getNodeType() == Node.ELEMENT_NODE )
1855            {
1856                Element childElement = (Element) node;
1857                if ( checkFieldWithDuplicate( childElement, "content.long", null, parsed ) )
1858                {
1859                    xmlContent.setLongContent( parseXmlContentLong( "content.long", childElement, strict ) );
1860                }
1861                else if ( checkFieldWithDuplicate( childElement, "content.long-with-attributes", null, parsed ) )
1862                {
1863                    xmlContent.setLongContentWithAttributes( parseXmlContentLongWithAttributes( "content.long-with-attributes", childElement, strict ) );
1864                }
1865                else
1866                {
1867                    checkUnknownElement( childElement, strict );
1868                }
1869            }
1870        }
1871        return xmlContent;
1872    } //-- XmlContent parseXmlContent( String, Element, boolean )
1873
1874    /**
1875     * Method parseXmlContentLong.
1876     * 
1877     * @param tagName
1878     * @param strict
1879     * @param element
1880     * @throws IOException
1881     * @throws DocumentException
1882     * @return XmlContentLong
1883     */
1884    private XmlContentLong parseXmlContentLong( String tagName, Element element, boolean strict )
1885        throws IOException, DocumentException
1886    {
1887        XmlContentLong xmlContentLong = new XmlContentLong();
1888        xmlContentLong.setContent( getLongValue( getTrimmedValue( element.getText() ), "content", strict ) );
1889        return xmlContentLong;
1890    } //-- XmlContentLong parseXmlContentLong( String, Element, boolean )
1891
1892    /**
1893     * Method parseXmlContentLongWithAttributes.
1894     * 
1895     * @param tagName
1896     * @param strict
1897     * @param element
1898     * @throws IOException
1899     * @throws DocumentException
1900     * @return XmlContentLongWithAttributes
1901     */
1902    private XmlContentLongWithAttributes parseXmlContentLongWithAttributes( String tagName, Element element, boolean strict )
1903        throws IOException, DocumentException
1904    {
1905        XmlContentLongWithAttributes xmlContentLongWithAttributes = new XmlContentLongWithAttributes();
1906        if ( element.attributeValue( "attr" ) != null  )
1907        {
1908            xmlContentLongWithAttributes.setAttr( getTrimmedValue( element.attributeValue( "attr" ) ) );
1909        }
1910        if ( element.attributeValue( "attr2" ) != null  )
1911        {
1912            xmlContentLongWithAttributes.setAttr2( getIntegerValue( getTrimmedValue( element.attributeValue( "attr2" ) ), "attr2", strict ) );
1913        }
1914        xmlContentLongWithAttributes.setContent( getLongValue( getTrimmedValue( element.getText() ), "content", strict ) );
1915        return xmlContentLongWithAttributes;
1916    } //-- XmlContentLongWithAttributes parseXmlContentLongWithAttributes( String, Element, boolean )
1917
1918    /**
1919     * Method parseXmlFeatures.
1920     * 
1921     * @param tagName
1922     * @param strict
1923     * @param element
1924     * @throws IOException
1925     * @throws DocumentException
1926     * @return XmlFeatures
1927     */
1928    private XmlFeatures parseXmlFeatures( String tagName, Element element, boolean strict )
1929        throws IOException, DocumentException
1930    {
1931        XmlFeatures xmlFeatures = new XmlFeatures();
1932        if ( element.attributeValue( "tag-name.attribute" ) != null  )
1933        {
1934            xmlFeatures.setFieldNameAttribute( getTrimmedValue( element.attributeValue( "tag-name.attribute" ) ) );
1935        }
1936        java.util.Set parsed = new java.util.HashSet();
1937        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
1938        {
1939            Node node = (Node) i.next();
1940            if ( node.getNodeType() == Node.ELEMENT_NODE )
1941            {
1942                Element childElement = (Element) node;
1943                if ( checkFieldWithDuplicate( childElement, "attributes", null, parsed ) )
1944                {
1945                    xmlFeatures.setAttributes( parseXmlAttributes( "attributes", childElement, strict ) );
1946                }
1947                else if ( checkFieldWithDuplicate( childElement, "attributesDefault", null, parsed ) )
1948                {
1949                    xmlFeatures.setAttributesDefault( parseXmlAttributes( "attributesDefault", childElement, strict ) );
1950                }
1951                else if ( checkFieldWithDuplicate( childElement, "content", null, parsed ) )
1952                {
1953                    xmlFeatures.setContent( parseXmlContent( "content", childElement, strict ) );
1954                }
1955                else if ( checkFieldWithDuplicate( childElement, "fieldTrim", null, parsed ) )
1956                {
1957                    xmlFeatures.setFieldTrim( getTrimmedValue( childElement.getText() ) );
1958                }
1959                else if ( checkFieldWithDuplicate( childElement, "fieldNoTrim", null, parsed ) )
1960                {
1961                    xmlFeatures.setFieldNoTrim( childElement.getText() );
1962                }
1963                else if ( checkFieldWithDuplicate( childElement, "dom", null, parsed ) )
1964                {
1965                    xmlFeatures.setDom( writeElementToXpp3Dom( childElement ) );
1966                }
1967                else if ( checkFieldWithDuplicate( childElement, "domNoTrim", null, parsed ) )
1968                {
1969                    xmlFeatures.setDomNoTrim( writeElementToXpp3Dom( childElement ) );
1970                }
1971                else if ( checkFieldWithDuplicate( childElement, "tag-name", null, parsed ) )
1972                {
1973                    xmlFeatures.setFieldName( getTrimmedValue( childElement.getText() ) );
1974                }
1975                else if ( checkFieldWithDuplicate( childElement, "dateXmlFormat", null, parsed ) )
1976                {
1977                    String dateFormat = "yyyy-MM-dd'T'HH:mm:ss";
1978                    xmlFeatures.setDateXmlFormat( getDateValue( getTrimmedValue( childElement.getText() ), "dateXmlFormat", dateFormat ) );
1979                }
1980                else if ( checkFieldWithDuplicate( childElement, "dateLong", null, parsed ) )
1981                {
1982                    String dateFormat = "long";
1983                    xmlFeatures.setDateLong( getDateValue( getTrimmedValue( childElement.getText() ), "dateLong", dateFormat ) );
1984                }
1985                else if ( "xmlItemsStyleFlat".equals( childElement.getName() ) )
1986                {
1987                    Element listElement = childElement;
1988                    java.util.List xmlItemsStyleFlats = xmlFeatures.getXmlItemsStyleFlats();
1989                    if ( xmlItemsStyleFlats == null )
1990                    {
1991                        xmlItemsStyleFlats = new java.util.ArrayList/*<Reference>*/();
1992                        xmlFeatures.setXmlItemsStyleFlats( xmlItemsStyleFlats );
1993                    }
1994                    xmlItemsStyleFlats.add( parseReference( "xmlItemsStyleFlat", listElement, strict ) );
1995                }
1996                else if ( checkFieldWithDuplicate( childElement, "xmlAssociationTagNames", null, parsed ) )
1997                {
1998                    java.util.List xmlAssociationTagNames = new java.util.ArrayList/*<Reference>*/();
1999                    xmlFeatures.setXmlAssociationTagNames( xmlAssociationTagNames );
2000                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
2001                    {
2002                        Node n = (Node) j.next();
2003                        if ( n.getNodeType() == Node.ELEMENT_NODE )
2004                        {
2005                            Element listElement = (Element) n;
2006                            if ( "association.tag-name".equals( listElement.getName() ) )
2007                            {
2008                                xmlAssociationTagNames.add( parseReference( "association.tag-name", listElement, strict ) );
2009                            }
2010                            else
2011                            {
2012                            }
2013                        }
2014                    }
2015                }
2016                else if ( checkFieldWithDuplicate( childElement, "field.tag-names", null, parsed ) )
2017                {
2018                    java.util.List xmlTagNameAssociation = new java.util.ArrayList/*<Reference>*/();
2019                    xmlFeatures.setXmlTagNameAssociation( xmlTagNameAssociation );
2020                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
2021                    {
2022                        Node n = (Node) j.next();
2023                        if ( n.getNodeType() == Node.ELEMENT_NODE )
2024                        {
2025                            Element listElement = (Element) n;
2026                            if ( "field.tag-name".equals( listElement.getName() ) )
2027                            {
2028                                xmlTagNameAssociation.add( parseReference( "field.tag-name", listElement, strict ) );
2029                            }
2030                            else
2031                            {
2032                            }
2033                        }
2034                    }
2035                }
2036                else if ( checkFieldWithDuplicate( childElement, "field.tag-name", null, parsed ) )
2037                {
2038                    java.util.List xmlTagNameAssociationTagNames = new java.util.ArrayList/*<Reference>*/();
2039                    xmlFeatures.setXmlTagNameAssociationTagNames( xmlTagNameAssociationTagNames );
2040                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
2041                    {
2042                        Node n = (Node) j.next();
2043                        if ( n.getNodeType() == Node.ELEMENT_NODE )
2044                        {
2045                            Element listElement = (Element) n;
2046                            if ( "association.tag-name".equals( listElement.getName() ) )
2047                            {
2048                                xmlTagNameAssociationTagNames.add( parseReference( "association.tag-name", listElement, strict ) );
2049                            }
2050                            else
2051                            {
2052                            }
2053                        }
2054                    }
2055                }
2056                else if ( "association.tag-name".equals( childElement.getName() ) )
2057                {
2058                    Element listElement = childElement;
2059                    java.util.List xmlFlatAssociationTagNames = xmlFeatures.getXmlFlatAssociationTagNames();
2060                    if ( xmlFlatAssociationTagNames == null )
2061                    {
2062                        xmlFlatAssociationTagNames = new java.util.ArrayList/*<Reference>*/();
2063                        xmlFeatures.setXmlFlatAssociationTagNames( xmlFlatAssociationTagNames );
2064                    }
2065                    xmlFlatAssociationTagNames.add( parseReference( "association.tag-name", listElement, strict ) );
2066                }
2067                else if ( checkFieldWithDuplicate( childElement, "explodeProperties", null, parsed ) )
2068                {
2069                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
2070                    {
2071                        Node n = (Node) j.next();
2072                        if ( n.getNodeType() == Node.ELEMENT_NODE )
2073                        {
2074                            Element listElement = (Element) n;
2075                            if ( "explodeProperty".equals( listElement.getName() ) )
2076                            {
2077                                String key = null;
2078                                String value = null;
2079                                //explode mode.
2080                                for ( Iterator k = listElement.nodeIterator(); k.hasNext(); )
2081                                {
2082                                    Node nd = (Node) k.next();
2083                                    if ( nd.getNodeType() == Node.ELEMENT_NODE )
2084                                    {
2085                                        Element propertyElement = (Element) nd;
2086                                        if ( "key".equals( propertyElement.getName() ) )
2087                                        {
2088                                            key = propertyElement.getText();
2089                                        }
2090                                        else if ( "value".equals( propertyElement.getName() ) )
2091                                        {
2092                                            value = propertyElement.getText().trim();
2093                                        }
2094                                        else
2095                                        {
2096                                        }
2097                                    }
2098                                }
2099                                xmlFeatures.addExplodeProperty( key, value );
2100                            }
2101                        }
2102                    }
2103                }
2104                else if ( checkFieldWithDuplicate( childElement, "inlineProperties", null, parsed ) )
2105                {
2106                    for ( Iterator j = childElement.nodeIterator(); j.hasNext(); )
2107                    {
2108                        Node n = (Node) j.next();
2109                        if ( n.getNodeType() == Node.ELEMENT_NODE )
2110                        {
2111                            Element listElement = (Element) n;
2112                            String key = listElement.getName();
2113                            String value = listElement.getText().trim();
2114                            xmlFeatures.addInlineProperty( key, value );
2115                        }
2116                    }
2117                }
2118                else if ( checkFieldWithDuplicate( childElement, "xmlTransientFields", null, parsed ) )
2119                {
2120                    xmlFeatures.setXmlTransientFields( parseXmlTransientFields( "xmlTransientFields", childElement, strict ) );
2121                }
2122                else if ( checkFieldWithDuplicate( childElement, "xmlFieldsOrder", null, parsed ) )
2123                {
2124                    xmlFeatures.setXmlFieldsOrder( parseXmlFieldsOrder( "xmlFieldsOrder", childElement, strict ) );
2125                }
2126                else if ( checkFieldWithDuplicate( childElement, "xsdFeatures", null, parsed ) )
2127                {
2128                    xmlFeatures.setXsdFeatures( parseXsdFeatures( "xsdFeatures", childElement, strict ) );
2129                }
2130                else
2131                {
2132                    checkUnknownElement( childElement, strict );
2133                }
2134            }
2135        }
2136        return xmlFeatures;
2137    } //-- XmlFeatures parseXmlFeatures( String, Element, boolean )
2138
2139    /**
2140     * Method parseXmlFieldsOrder.
2141     * 
2142     * @param tagName
2143     * @param strict
2144     * @param element
2145     * @throws IOException
2146     * @throws DocumentException
2147     * @return XmlFieldsOrder
2148     */
2149    private XmlFieldsOrder parseXmlFieldsOrder( String tagName, Element element, boolean strict )
2150        throws IOException, DocumentException
2151    {
2152        XmlFieldsOrder xmlFieldsOrder = new XmlFieldsOrder();
2153        java.util.Set parsed = new java.util.HashSet();
2154        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
2155        {
2156            Node node = (Node) i.next();
2157            if ( node.getNodeType() == Node.ELEMENT_NODE )
2158            {
2159                Element childElement = (Element) node;
2160                if ( checkFieldWithDuplicate( childElement, "field1", null, parsed ) )
2161                {
2162                    xmlFieldsOrder.setField1( getTrimmedValue( childElement.getText() ) );
2163                }
2164                else if ( checkFieldWithDuplicate( childElement, "field-2", null, parsed ) )
2165                {
2166                    xmlFieldsOrder.setField( getTrimmedValue( childElement.getText() ) );
2167                }
2168                else if ( checkFieldWithDuplicate( childElement, "field3", null, parsed ) )
2169                {
2170                    xmlFieldsOrder.setField3( getTrimmedValue( childElement.getText() ) );
2171                }
2172                else if ( checkFieldWithDuplicate( childElement, "field4", null, parsed ) )
2173                {
2174                    xmlFieldsOrder.setField4( getTrimmedValue( childElement.getText() ) );
2175                }
2176                else if ( checkFieldWithDuplicate( childElement, "field5", null, parsed ) )
2177                {
2178                    xmlFieldsOrder.setField5( getTrimmedValue( childElement.getText() ) );
2179                }
2180                else if ( checkFieldWithDuplicate( childElement, "field6", null, parsed ) )
2181                {
2182                    xmlFieldsOrder.setField6( getTrimmedValue( childElement.getText() ) );
2183                }
2184                else if ( checkFieldWithDuplicate( childElement, "field7", null, parsed ) )
2185                {
2186                    xmlFieldsOrder.setField7( getTrimmedValue( childElement.getText() ) );
2187                }
2188                else
2189                {
2190                    checkUnknownElement( childElement, strict );
2191                }
2192            }
2193        }
2194        return xmlFieldsOrder;
2195    } //-- XmlFieldsOrder parseXmlFieldsOrder( String, Element, boolean )
2196
2197    /**
2198     * Method parseXmlFieldsOrderParent.
2199     * 
2200     * @param tagName
2201     * @param strict
2202     * @param element
2203     * @throws IOException
2204     * @throws DocumentException
2205     * @return XmlFieldsOrderParent
2206     */
2207    private XmlFieldsOrderParent parseXmlFieldsOrderParent( String tagName, Element element, boolean strict )
2208        throws IOException, DocumentException
2209    {
2210        XmlFieldsOrderParent xmlFieldsOrderParent = new XmlFieldsOrderParent();
2211        java.util.Set parsed = new java.util.HashSet();
2212        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
2213        {
2214            Node node = (Node) i.next();
2215            if ( node.getNodeType() == Node.ELEMENT_NODE )
2216            {
2217                Element childElement = (Element) node;
2218                if ( checkFieldWithDuplicate( childElement, "field-2", null, parsed ) )
2219                {
2220                    xmlFieldsOrderParent.setField( getTrimmedValue( childElement.getText() ) );
2221                }
2222                else if ( checkFieldWithDuplicate( childElement, "field4", null, parsed ) )
2223                {
2224                    xmlFieldsOrderParent.setField4( getTrimmedValue( childElement.getText() ) );
2225                }
2226                else if ( checkFieldWithDuplicate( childElement, "field5", null, parsed ) )
2227                {
2228                    xmlFieldsOrderParent.setField5( getTrimmedValue( childElement.getText() ) );
2229                }
2230                else if ( checkFieldWithDuplicate( childElement, "field7", null, parsed ) )
2231                {
2232                    xmlFieldsOrderParent.setField7( getTrimmedValue( childElement.getText() ) );
2233                }
2234                else
2235                {
2236                    checkUnknownElement( childElement, strict );
2237                }
2238            }
2239        }
2240        return xmlFieldsOrderParent;
2241    } //-- XmlFieldsOrderParent parseXmlFieldsOrderParent( String, Element, boolean )
2242
2243    /**
2244     * Method parseXmlFieldsOrderParent2.
2245     * 
2246     * @param tagName
2247     * @param strict
2248     * @param element
2249     * @throws IOException
2250     * @throws DocumentException
2251     * @return XmlFieldsOrderParent2
2252     */
2253    private XmlFieldsOrderParent2 parseXmlFieldsOrderParent2( String tagName, Element element, boolean strict )
2254        throws IOException, DocumentException
2255    {
2256        XmlFieldsOrderParent2 xmlFieldsOrderParent2 = new XmlFieldsOrderParent2();
2257        java.util.Set parsed = new java.util.HashSet();
2258        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
2259        {
2260            Node node = (Node) i.next();
2261            if ( node.getNodeType() == Node.ELEMENT_NODE )
2262            {
2263                Element childElement = (Element) node;
2264                if ( checkFieldWithDuplicate( childElement, "field-2", null, parsed ) )
2265                {
2266                    xmlFieldsOrderParent2.setField( getTrimmedValue( childElement.getText() ) );
2267                }
2268                else
2269                {
2270                    checkUnknownElement( childElement, strict );
2271                }
2272            }
2273        }
2274        return xmlFieldsOrderParent2;
2275    } //-- XmlFieldsOrderParent2 parseXmlFieldsOrderParent2( String, Element, boolean )
2276
2277    /**
2278     * Method parseXmlTransientFields.
2279     * 
2280     * @param tagName
2281     * @param strict
2282     * @param element
2283     * @throws IOException
2284     * @throws DocumentException
2285     * @return XmlTransientFields
2286     */
2287    private XmlTransientFields parseXmlTransientFields( String tagName, Element element, boolean strict )
2288        throws IOException, DocumentException
2289    {
2290        XmlTransientFields xmlTransientFields = new XmlTransientFields();
2291        java.util.Set parsed = new java.util.HashSet();
2292        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
2293        {
2294            Node node = (Node) i.next();
2295            if ( node.getNodeType() == Node.ELEMENT_NODE )
2296            {
2297                Element childElement = (Element) node;
2298                if ( checkFieldWithDuplicate( childElement, "persistentField", null, parsed ) )
2299                {
2300                    xmlTransientFields.setPersistentField( getTrimmedValue( childElement.getText() ) );
2301                }
2302                else
2303                {
2304                    checkUnknownElement( childElement, strict );
2305                }
2306            }
2307        }
2308        return xmlTransientFields;
2309    } //-- XmlTransientFields parseXmlTransientFields( String, Element, boolean )
2310
2311    /**
2312     * Method parseXsdFeatures.
2313     * 
2314     * @param tagName
2315     * @param strict
2316     * @param element
2317     * @throws IOException
2318     * @throws DocumentException
2319     * @return XsdFeatures
2320     */
2321    private XsdFeatures parseXsdFeatures( String tagName, Element element, boolean strict )
2322        throws IOException, DocumentException
2323    {
2324        XsdFeatures xsdFeatures = new XsdFeatures();
2325        if ( element.attributeValue( "attribute" ) != null  )
2326        {
2327            xsdFeatures.setAttribute( getTrimmedValue( element.attributeValue( "attribute" ) ) );
2328        }
2329        java.util.Set parsed = new java.util.HashSet();
2330        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
2331        {
2332            Node node = (Node) i.next();
2333            if ( node.getNodeType() == Node.ELEMENT_NODE )
2334            {
2335                Element childElement = (Element) node;
2336                checkUnknownElement( childElement, strict );
2337            }
2338        }
2339        return xsdFeatures;
2340    } //-- XsdFeatures parseXsdFeatures( String, Element, boolean )
2341
2342    /**
2343     * Method read.
2344     * 
2345     * @param reader
2346     * @param strict
2347     * @throws IOException
2348     * @throws DocumentException
2349     * @return Features
2350     */
2351    public Features read( Reader reader, boolean strict )
2352        throws IOException, DocumentException
2353    {
2354        SAXReader parser = new SAXReader();
2355        Document document = parser.read( reader );
2356        return read( document, strict );
2357    } //-- Features read( Reader, boolean )
2358
2359    /**
2360     * Method read.
2361     * 
2362     * @param reader
2363     * @throws IOException
2364     * @throws DocumentException
2365     * @return Features
2366     */
2367    public Features read( Reader reader )
2368        throws IOException, DocumentException
2369    {
2370        return read( reader, true );
2371    } //-- Features read( Reader )
2372
2373    /**
2374     * Method read.
2375     * 
2376     * @param stream
2377     * @param strict
2378     * @throws IOException
2379     * @throws DocumentException
2380     * @return Features
2381     */
2382    public Features read( InputStream stream, boolean strict )
2383        throws IOException, DocumentException
2384    {
2385        SAXReader parser = new SAXReader();
2386        Document document = parser.read( stream );
2387        return read( document, strict );
2388    } //-- Features read( InputStream, boolean )
2389
2390    /**
2391     * Method read.
2392     * 
2393     * @param stream
2394     * @throws IOException
2395     * @throws DocumentException
2396     * @return Features
2397     */
2398    public Features read( InputStream stream )
2399        throws IOException, DocumentException
2400    {
2401        return read( stream, true );
2402    } //-- Features read( InputStream )
2403
2404    /**
2405     * Method read.
2406     * 
2407     * @param url
2408     * @param strict
2409     * @throws IOException
2410     * @throws DocumentException
2411     * @return Features
2412     */
2413    public Features read( URL url, boolean strict )
2414        throws IOException, DocumentException
2415    {
2416        SAXReader parser = new SAXReader();
2417        Document document = parser.read( url );
2418        return read( document, strict );
2419    } //-- Features read( URL, boolean )
2420
2421    /**
2422     * Method read.
2423     * 
2424     * @param url
2425     * @throws IOException
2426     * @throws DocumentException
2427     * @return Features
2428     */
2429    public Features read( URL url )
2430        throws IOException, DocumentException
2431    {
2432        return read( url, true );
2433    } //-- Features read( URL )
2434
2435    /**
2436     * Method read.
2437     * 
2438     * @param document
2439     * @param strict
2440     * @throws IOException
2441     * @throws DocumentException
2442     * @return Features
2443     */
2444    private Features read( Document document, boolean strict )
2445        throws IOException, DocumentException
2446    {
2447        String encoding = document.getXMLEncoding();
2448        Features features = parseFeatures( "features-demo", document.getRootElement(), strict );
2449        features.setModelEncoding( encoding );
2450        return features;
2451    } //-- Features read( Document, boolean )
2452
2453    /**
2454     * Method writeElementToXpp3Dom.
2455     * 
2456     * @param element
2457     * @return Xpp3Dom
2458     */
2459    private Xpp3Dom writeElementToXpp3Dom( Element element )
2460    {
2461        Xpp3Dom xpp3Dom = new Xpp3Dom( element.getName() );
2462        if ( element.elements().isEmpty() && element.getText() != null )
2463        {
2464            xpp3Dom.setValue( element.getText() );
2465        }
2466        for ( Iterator i = element.attributeIterator(); i.hasNext(); )
2467        {
2468            Attribute attribute = (Attribute) i.next();
2469            xpp3Dom.setAttribute( attribute.getName(), attribute.getValue() );
2470        }
2471        for ( Iterator i = element.elementIterator(); i.hasNext(); )
2472        {
2473            Element child = (Element) i.next();
2474            xpp3Dom.addChild( writeElementToXpp3Dom( child ) );
2475        }
2476        return xpp3Dom;
2477    } //-- Xpp3Dom writeElementToXpp3Dom( Element )
2478
2479}