001/*
002 =================== DO NOT EDIT THIS FILE ====================
003 Generated by Modello 1.9.0-SNAPSHOT,
004 any modifications will be overwritten.
005 ==============================================================
006 */
007
008package org.codehaus.modello.test.features.io.stax;
009
010  //---------------------------------/
011 //- Imported classes and packages -/
012//---------------------------------/
013
014import java.io.IOException;
015import java.io.OutputStream;
016import java.io.StringWriter;
017import java.io.Writer;
018import java.text.DateFormat;
019import java.util.Iterator;
020import java.util.Locale;
021import java.util.jar.Manifest;
022import javax.xml.stream.*;
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;
062
063/**
064 * Class ModelloFeaturesTestStaxWriter.
065 * 
066 * @version $Revision$ $Date$
067 */
068@SuppressWarnings( "all" )
069public class ModelloFeaturesTestStaxWriter
070{
071
072      //--------------------------/
073     //- Class/Member Variables -/
074    //--------------------------/
075
076    /**
077     * Field curId.
078     */
079    private int curId;
080
081    /**
082     * Field idMap.
083     */
084    private java.util.Map idMap;
085
086
087      //----------------/
088     //- Constructors -/
089    //----------------/
090
091    public ModelloFeaturesTestStaxWriter()
092    {
093        idMap = new java.util.HashMap();
094    } //-- org.codehaus.modello.test.features.io.stax.ModelloFeaturesTestStaxWriter()
095
096
097      //-----------/
098     //- Methods -/
099    //-----------/
100
101    /**
102     * Method write.
103     * 
104     * @param writer
105     * @param features
106     * @throws java.io.IOException
107     * @throws XMLStreamException
108     */
109    public void write( Writer writer, Features features )
110        throws java.io.IOException, XMLStreamException
111    {
112        XMLOutputFactory factory = XMLOutputFactory.newInstance();
113        boolean supportWindowsLineEndings = false;
114        if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) )
115        {
116            factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE );
117            supportWindowsLineEndings = true;
118        }
119        if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) )
120        {
121            factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE );
122        }
123        IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( writer ) );
124        if ( supportWindowsLineEndings )
125        {
126            serializer.setNewLine( serializer.getLineSeparator() );
127        }
128        serializer.writeStartDocument( features.getModelEncoding(), "1.0" );
129        writeFeatures( features, "features-demo", serializer );
130        serializer.writeEndDocument();
131    } //-- void write( Writer, Features )
132
133    /**
134     * Method write.
135     * 
136     * @param stream
137     * @param features
138     * @throws java.io.IOException
139     * @throws XMLStreamException
140     */
141    public void write( OutputStream stream, Features features )
142        throws java.io.IOException, XMLStreamException
143    {
144        XMLOutputFactory factory = XMLOutputFactory.newInstance();
145        boolean supportWindowsLineEndings = false;
146        if ( factory.isPropertySupported( "com.ctc.wstx.outputEscapeCr" ) )
147        {
148            factory.setProperty( "com.ctc.wstx.outputEscapeCr", Boolean.FALSE );
149            supportWindowsLineEndings = true;
150        }
151        if ( factory.isPropertySupported( "org.codehaus.stax2.automaticEmptyElements" ) )
152        {
153            factory.setProperty( "org.codehaus.stax2.automaticEmptyElements", Boolean.FALSE );
154        }
155        IndentingXMLStreamWriter serializer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter( stream, features.getModelEncoding() ) );
156        if ( supportWindowsLineEndings )
157        {
158            serializer.setNewLine( serializer.getLineSeparator() );
159        }
160        serializer.writeStartDocument( features.getModelEncoding(), "1.0" );
161        writeFeatures( features, "features-demo", serializer );
162        serializer.writeEndDocument();
163    } //-- void write( OutputStream, Features )
164
165    /**
166     * Method writeAction.
167     * 
168     * @param action
169     * @param serializer
170     * @param tagName
171     * @throws java.io.IOException
172     * @throws XMLStreamException
173     */
174    private void writeAction( Action action, String tagName, XMLStreamWriter serializer )
175        throws java.io.IOException, XMLStreamException
176    {
177        if ( action != null )
178        {
179            serializer.writeStartElement( tagName );
180            if ( action.getDev() != null )
181            {
182                serializer.writeAttribute( "dev", action.getDev() );
183            }
184            serializer.writeCharacters( action.getAction() );
185            serializer.writeEndElement();
186        }
187    } //-- void writeAction( Action, String, XMLStreamWriter )
188
189    /**
190     * Method writeAnnotationTest.
191     * 
192     * @param annotationTest
193     * @param serializer
194     * @param tagName
195     * @throws java.io.IOException
196     * @throws XMLStreamException
197     */
198    private void writeAnnotationTest( AnnotationTest annotationTest, String tagName, XMLStreamWriter serializer )
199        throws java.io.IOException, XMLStreamException
200    {
201        if ( annotationTest != null )
202        {
203            serializer.writeStartElement( tagName );
204            if ( annotationTest.getAnyField() != null )
205            {
206                serializer.writeStartElement( "anyField" );
207                serializer.writeCharacters( annotationTest.getAnyField() );
208                serializer.writeEndElement();
209            }
210            serializer.writeEndElement();
211        }
212    } //-- void writeAnnotationTest( AnnotationTest, String, XMLStreamWriter )
213
214    /**
215     * Method writeArrayFeatures.
216     * 
217     * @param arrayFeatures
218     * @param serializer
219     * @param tagName
220     * @throws java.io.IOException
221     * @throws XMLStreamException
222     */
223    private void writeArrayFeatures( ArrayFeatures arrayFeatures, String tagName, XMLStreamWriter serializer )
224        throws java.io.IOException, XMLStreamException
225    {
226        if ( arrayFeatures != null )
227        {
228            serializer.writeStartElement( tagName );
229            serializer.writeEndElement();
230        }
231    } //-- void writeArrayFeatures( ArrayFeatures, String, XMLStreamWriter )
232
233    /**
234     * Method writeAssociationFeatures.
235     * 
236     * @param associationFeatures
237     * @param serializer
238     * @param tagName
239     * @throws java.io.IOException
240     * @throws XMLStreamException
241     */
242    private void writeAssociationFeatures( AssociationFeatures associationFeatures, String tagName, XMLStreamWriter serializer )
243        throws java.io.IOException, XMLStreamException
244    {
245        if ( associationFeatures != null )
246        {
247            serializer.writeStartElement( tagName );
248            if ( ( associationFeatures.getListReferences() != null ) && ( associationFeatures.getListReferences().size() > 0 ) )
249            {
250                serializer.writeStartElement( "listReferences" );
251                for ( Iterator iter = associationFeatures.getListReferences().iterator(); iter.hasNext(); )
252                {
253                    Reference o = (Reference) iter.next();
254                    writeReference( o, "listReference", serializer );
255                }
256                serializer.writeEndElement();
257            }
258            if ( ( associationFeatures.getSetReferences() != null ) && ( associationFeatures.getSetReferences().size() > 0 ) )
259            {
260                serializer.writeStartElement( "setReferences" );
261                for ( Iterator iter = associationFeatures.getSetReferences().iterator(); iter.hasNext(); )
262                {
263                    Reference o = (Reference) iter.next();
264                    writeReference( o, "setReference", serializer );
265                }
266                serializer.writeEndElement();
267            }
268            if ( ( associationFeatures.getListStrings() != null ) && ( associationFeatures.getListStrings().size() > 0 ) )
269            {
270                serializer.writeStartElement( "listStrings" );
271                for ( Iterator iter = associationFeatures.getListStrings().iterator(); iter.hasNext(); )
272                {
273                    String listString = (String) iter.next();
274                    serializer.writeStartElement( "listString" );
275                    serializer.writeCharacters( listString );
276                    serializer.writeEndElement();
277                }
278                serializer.writeEndElement();
279            }
280            if ( ( associationFeatures.getSetStrings() != null ) && ( associationFeatures.getSetStrings().size() > 0 ) )
281            {
282                serializer.writeStartElement( "setStrings" );
283                for ( Iterator iter = associationFeatures.getSetStrings().iterator(); iter.hasNext(); )
284                {
285                    String setString = (String) iter.next();
286                    serializer.writeStartElement( "setString" );
287                    serializer.writeCharacters( setString );
288                    serializer.writeEndElement();
289                }
290                serializer.writeEndElement();
291            }
292            if ( ( associationFeatures.getProperties() != null ) && ( associationFeatures.getProperties().size() > 0 ) )
293            {
294                serializer.writeStartElement( "properties" );
295                for ( Iterator iter = associationFeatures.getProperties().keySet().iterator(); iter.hasNext(); )
296                {
297                    String key = (String) iter.next();
298                    String value = (String) associationFeatures.getProperties().get( key );
299                    serializer.writeStartElement( "" + key + "" );
300                    serializer.writeCharacters( value );
301                    serializer.writeEndElement();
302                }
303                serializer.writeEndElement();
304            }
305            if ( associationFeatures.getBidi() != null )
306            {
307                writeBidirectional( (Bidirectional) associationFeatures.getBidi(), "bidi", serializer );
308            }
309            if ( ( associationFeatures.getListOfBidis() != null ) && ( associationFeatures.getListOfBidis().size() > 0 ) )
310            {
311                serializer.writeStartElement( "listOfBidis" );
312                for ( Iterator iter = associationFeatures.getListOfBidis().iterator(); iter.hasNext(); )
313                {
314                    BidiInList o = (BidiInList) iter.next();
315                    writeBidiInList( o, "listOfBidi", serializer );
316                }
317                serializer.writeEndElement();
318            }
319            if ( ( associationFeatures.getSetOfBidis() != null ) && ( associationFeatures.getSetOfBidis().size() > 0 ) )
320            {
321                serializer.writeStartElement( "setOfBidis" );
322                for ( Iterator iter = associationFeatures.getSetOfBidis().iterator(); iter.hasNext(); )
323                {
324                    BidiInSet o = (BidiInSet) iter.next();
325                    writeBidiInSet( o, "setOfBidi", serializer );
326                }
327                serializer.writeEndElement();
328            }
329            serializer.writeEndElement();
330        }
331    } //-- void writeAssociationFeatures( AssociationFeatures, String, XMLStreamWriter )
332
333    /**
334     * Method writeBaseClass.
335     * 
336     * @param baseClass
337     * @param serializer
338     * @param tagName
339     * @throws java.io.IOException
340     * @throws XMLStreamException
341     */
342    private void writeBaseClass( BaseClass baseClass, String tagName, XMLStreamWriter serializer )
343        throws java.io.IOException, XMLStreamException
344    {
345        if ( baseClass != null )
346        {
347            serializer.writeStartElement( tagName );
348            if ( baseClass.getBaseAttribute() != 0 )
349            {
350                serializer.writeAttribute( "baseAttribute", String.valueOf( baseClass.getBaseAttribute() ) );
351            }
352            if ( baseClass.getBaseElement() != 0 )
353            {
354                serializer.writeStartElement( "baseElement" );
355                serializer.writeCharacters( String.valueOf( baseClass.getBaseElement() ) );
356                serializer.writeEndElement();
357            }
358            serializer.writeEndElement();
359        }
360    } //-- void writeBaseClass( BaseClass, String, XMLStreamWriter )
361
362    /**
363     * Method writeBidiInList.
364     * 
365     * @param bidiInList
366     * @param serializer
367     * @param tagName
368     * @throws java.io.IOException
369     * @throws XMLStreamException
370     */
371    private void writeBidiInList( BidiInList bidiInList, String tagName, XMLStreamWriter serializer )
372        throws java.io.IOException, XMLStreamException
373    {
374        if ( bidiInList != null )
375        {
376            serializer.writeStartElement( tagName );
377            if ( bidiInList.getParent() != null )
378            {
379                writeAssociationFeatures( (AssociationFeatures) bidiInList.getParent(), "parent", serializer );
380            }
381            serializer.writeEndElement();
382        }
383    } //-- void writeBidiInList( BidiInList, String, XMLStreamWriter )
384
385    /**
386     * Method writeBidiInSet.
387     * 
388     * @param bidiInSet
389     * @param serializer
390     * @param tagName
391     * @throws java.io.IOException
392     * @throws XMLStreamException
393     */
394    private void writeBidiInSet( BidiInSet bidiInSet, String tagName, XMLStreamWriter serializer )
395        throws java.io.IOException, XMLStreamException
396    {
397        if ( bidiInSet != null )
398        {
399            serializer.writeStartElement( tagName );
400            if ( bidiInSet.getParent() != null )
401            {
402                writeAssociationFeatures( (AssociationFeatures) bidiInSet.getParent(), "parent", serializer );
403            }
404            serializer.writeEndElement();
405        }
406    } //-- void writeBidiInSet( BidiInSet, String, XMLStreamWriter )
407
408    /**
409     * Method writeBidirectional.
410     * 
411     * @param bidirectional
412     * @param serializer
413     * @param tagName
414     * @throws java.io.IOException
415     * @throws XMLStreamException
416     */
417    private void writeBidirectional( Bidirectional bidirectional, String tagName, XMLStreamWriter serializer )
418        throws java.io.IOException, XMLStreamException
419    {
420        if ( bidirectional != null )
421        {
422            serializer.writeStartElement( tagName );
423            if ( bidirectional.getParent() != null )
424            {
425                writeAssociationFeatures( (AssociationFeatures) bidirectional.getParent(), "parent", serializer );
426            }
427            serializer.writeEndElement();
428        }
429    } //-- void writeBidirectional( Bidirectional, String, XMLStreamWriter )
430
431    /**
432     * Method writeContentTest.
433     * 
434     * @param contentTest
435     * @param serializer
436     * @param tagName
437     * @throws java.io.IOException
438     * @throws XMLStreamException
439     */
440    private void writeContentTest( ContentTest contentTest, String tagName, XMLStreamWriter serializer )
441        throws java.io.IOException, XMLStreamException
442    {
443        if ( contentTest != null )
444        {
445            serializer.writeStartElement( tagName );
446            if ( contentTest.getAttr() != null )
447            {
448                serializer.writeAttribute( "attr", contentTest.getAttr() );
449            }
450            if ( contentTest.getAttr2() != 0 )
451            {
452                serializer.writeAttribute( "attr2", String.valueOf( contentTest.getAttr2() ) );
453            }
454            serializer.writeCharacters( contentTest.getContent() );
455            serializer.writeEndElement();
456        }
457    } //-- void writeContentTest( ContentTest, String, XMLStreamWriter )
458
459    /**
460     * Method writeDom.
461     * 
462     * @param dom
463     * @param serializer
464     * @throws XMLStreamException
465     */
466    private void writeDom( Xpp3Dom dom, XMLStreamWriter serializer )
467        throws XMLStreamException
468    {
469        serializer.writeStartElement( dom.getName() );
470        String[] attributeNames = dom.getAttributeNames();
471        for ( int i = 0; i < attributeNames.length; i++ )
472        {
473            String attributeName = attributeNames[i];
474            serializer.writeAttribute( attributeName, dom.getAttribute( attributeName ) );
475        }
476        Xpp3Dom[] children = dom.getChildren();
477        for ( int i = 0; i < children.length; i++ )
478        {
479            writeDom( children[i], serializer );
480        }
481        String value = dom.getValue();
482        if ( value != null )
483        {
484            serializer.writeCharacters( value );
485        }
486        serializer.writeEndElement();
487    } //-- void writeDom( Xpp3Dom, XMLStreamWriter )
488
489    /**
490     * Method writeDueTo.
491     * 
492     * @param dueTo
493     * @param serializer
494     * @param tagName
495     * @throws java.io.IOException
496     * @throws XMLStreamException
497     */
498    private void writeDueTo( DueTo dueTo, String tagName, XMLStreamWriter serializer )
499        throws java.io.IOException, XMLStreamException
500    {
501        if ( dueTo != null )
502        {
503            serializer.writeStartElement( tagName );
504            if ( dueTo.getName() != null )
505            {
506                serializer.writeAttribute( "name", dueTo.getName() );
507            }
508            if ( dueTo.getEmail() != null )
509            {
510                serializer.writeAttribute( "email", dueTo.getEmail() );
511            }
512            serializer.writeEndElement();
513        }
514    } //-- void writeDueTo( DueTo, String, XMLStreamWriter )
515
516    /**
517     * Method writeFeatures.
518     * 
519     * @param features
520     * @param serializer
521     * @param tagName
522     * @throws java.io.IOException
523     * @throws XMLStreamException
524     */
525    private void writeFeatures( Features features, String tagName, XMLStreamWriter serializer )
526        throws java.io.IOException, XMLStreamException
527    {
528        if ( features != null )
529        {
530            serializer.setDefaultNamespace( "http://codehaus-plexus.github.io/FEATURES/1.0.0" );
531            serializer.writeStartElement( tagName );
532            serializer.writeDefaultNamespace( "http://codehaus-plexus.github.io/FEATURES/1.0.0" );
533            serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
534            serializer.writeNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
535            serializer.writeAttribute( "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation", "http://codehaus-plexus.github.io/FEATURES/1.0.0 http://codehaus-plexus.github.io/features-1.0.0.xsd" );
536            if ( features.getVersionField() != null )
537            {
538                serializer.writeStartElement( "versionField" );
539                serializer.writeCharacters( features.getVersionField() );
540                serializer.writeEndElement();
541            }
542            if ( features.getComment() != null )
543            {
544                serializer.writeStartElement( "comment" );
545                serializer.writeCharacters( features.getComment() );
546                serializer.writeEndElement();
547            }
548            if ( features.getDescription() != null )
549            {
550                serializer.writeStartElement( "description" );
551                serializer.writeCharacters( features.getDescription() );
552                serializer.writeEndElement();
553            }
554            if ( features.getRequired() != null )
555            {
556                serializer.writeStartElement( "required" );
557                serializer.writeCharacters( features.getRequired() );
558                serializer.writeEndElement();
559            }
560            if ( features.getIdentifier() != null )
561            {
562                serializer.writeStartElement( "identifier" );
563                serializer.writeCharacters( features.getIdentifier() );
564                serializer.writeEndElement();
565            }
566            if ( features.getIdentifierPart2() != null )
567            {
568                writeReference( (Reference) features.getIdentifierPart2(), "identifierPart2", serializer );
569            }
570            if ( features.getSimpleTypes() != null )
571            {
572                writeSimpleTypes( (SimpleTypes) features.getSimpleTypes(), "simpleTypes", serializer );
573            }
574            if ( features.getDefaultValues() != null )
575            {
576                writeSimpleTypes( (SimpleTypes) features.getDefaultValues(), "defaultValues", serializer );
577            }
578            if ( features.getArrays() != null )
579            {
580                writeArrayFeatures( (ArrayFeatures) features.getArrays(), "arrays", serializer );
581            }
582            if ( features.getAssociationFeatures() != null )
583            {
584                writeAssociationFeatures( (AssociationFeatures) features.getAssociationFeatures(), "associationFeatures", serializer );
585            }
586            if ( features.getJavaFeatures() != null )
587            {
588                writeJavaFeatures( (JavaFeatures) features.getJavaFeatures(), "javaFeatures", serializer );
589            }
590            if ( features.getXmlFeatures() != null )
591            {
592                writeXmlFeatures( (XmlFeatures) features.getXmlFeatures(), "xmlFeatures", serializer );
593            }
594            if ( features.getXdocFeatures() != null )
595            {
596                writeXdocFeatures( (XdocFeatures) features.getXdocFeatures(), "xdocFeatures", serializer );
597            }
598            if ( features.getNode() != null )
599            {
600                writeNodeItem( (NodeItem) features.getNode(), "node", serializer );
601            }
602            if ( features.getCloneable() != null )
603            {
604                writeThing( (Thing) features.getCloneable(), "cloneable", serializer );
605            }
606            if ( features.getFile() != null )
607            {
608                writeFile( (File) features.getFile(), "file", serializer );
609            }
610            if ( features.getAction() != null )
611            {
612                writeAction( (Action) features.getAction(), "action", serializer );
613            }
614            serializer.writeEndElement();
615        }
616    } //-- void writeFeatures( Features, String, XMLStreamWriter )
617
618    /**
619     * Method writeFile.
620     * 
621     * @param file
622     * @param serializer
623     * @param tagName
624     * @throws java.io.IOException
625     * @throws XMLStreamException
626     */
627    private void writeFile( File file, String tagName, XMLStreamWriter serializer )
628        throws java.io.IOException, XMLStreamException
629    {
630        if ( file != null )
631        {
632            serializer.writeStartElement( tagName );
633            if ( file.getFile() != null )
634            {
635                serializer.writeStartElement( "file" );
636                serializer.writeCharacters( file.getFile() );
637                serializer.writeEndElement();
638            }
639            serializer.writeEndElement();
640        }
641    } //-- void writeFile( File, String, XMLStreamWriter )
642
643    /**
644     * Method writeInterfacesFeature.
645     * 
646     * @param interfacesFeature
647     * @param serializer
648     * @param tagName
649     * @throws java.io.IOException
650     * @throws XMLStreamException
651     */
652    private void writeInterfacesFeature( InterfacesFeature interfacesFeature, String tagName, XMLStreamWriter serializer )
653        throws java.io.IOException, XMLStreamException
654    {
655        if ( interfacesFeature != null )
656        {
657            serializer.writeStartElement( tagName );
658            if ( interfacesFeature.getId() != null )
659            {
660                serializer.writeStartElement( "id" );
661                serializer.writeCharacters( interfacesFeature.getId() );
662                serializer.writeEndElement();
663            }
664            serializer.writeEndElement();
665        }
666    } //-- void writeInterfacesFeature( InterfacesFeature, String, XMLStreamWriter )
667
668    /**
669     * Method writeJavaFeatures.
670     * 
671     * @param javaFeatures
672     * @param serializer
673     * @param tagName
674     * @throws java.io.IOException
675     * @throws XMLStreamException
676     */
677    private void writeJavaFeatures( JavaFeatures javaFeatures, String tagName, XMLStreamWriter serializer )
678        throws java.io.IOException, XMLStreamException
679    {
680        if ( javaFeatures != null )
681        {
682            serializer.writeStartElement( tagName );
683            if ( javaFeatures.getInterfaces() != null )
684            {
685                writeInterfacesFeature( (InterfacesFeature) javaFeatures.getInterfaces(), "interfaces", serializer );
686            }
687            if ( javaFeatures.getPackageName() != null )
688            {
689                writePackageNameFeature( (PackageNameFeature) javaFeatures.getPackageName(), "packageName", serializer );
690            }
691            if ( javaFeatures.getBase() != null )
692            {
693                writeBaseClass( (BaseClass) javaFeatures.getBase(), "base", serializer );
694            }
695            if ( javaFeatures.getSubClass() != null )
696            {
697                writeSubClassLevel1( (SubClassLevel1) javaFeatures.getSubClass(), "subClass", serializer );
698            }
699            if ( javaFeatures.getSubClass2() != null )
700            {
701                writeSubClassLevel2( (SubClassLevel2) javaFeatures.getSubClass2(), "subClass2", serializer );
702            }
703            if ( javaFeatures.getSubClass3() != null )
704            {
705                writeSubClassLevel3( (SubClassLevel3) javaFeatures.getSubClass3(), "subClass3", serializer );
706            }
707            if ( javaFeatures.getAnnotation() != null )
708            {
709                writeAnnotationTest( (AnnotationTest) javaFeatures.getAnnotation(), "annotation", serializer );
710            }
711            serializer.writeEndElement();
712        }
713    } //-- void writeJavaFeatures( JavaFeatures, String, XMLStreamWriter )
714
715    /**
716     * Method writeNodeItem.
717     * 
718     * @param nodeItem
719     * @param serializer
720     * @param tagName
721     * @throws java.io.IOException
722     * @throws XMLStreamException
723     */
724    private void writeNodeItem( NodeItem nodeItem, String tagName, XMLStreamWriter serializer )
725        throws java.io.IOException, XMLStreamException
726    {
727        if ( nodeItem != null )
728        {
729            serializer.writeStartElement( tagName );
730            if ( nodeItem.getValue() != null )
731            {
732                serializer.writeStartElement( "value" );
733                serializer.writeCharacters( nodeItem.getValue() );
734                serializer.writeEndElement();
735            }
736            if ( nodeItem.getChild() != null )
737            {
738                writeNodeItem( (NodeItem) nodeItem.getChild(), "child", serializer );
739            }
740            serializer.writeEndElement();
741        }
742    } //-- void writeNodeItem( NodeItem, String, XMLStreamWriter )
743
744    /**
745     * Method writePackageNameFeature.
746     * 
747     * @param packageNameFeature
748     * @param serializer
749     * @param tagName
750     * @throws java.io.IOException
751     * @throws XMLStreamException
752     */
753    private void writePackageNameFeature( PackageNameFeature packageNameFeature, String tagName, XMLStreamWriter serializer )
754        throws java.io.IOException, XMLStreamException
755    {
756        if ( packageNameFeature != null )
757        {
758            serializer.writeStartElement( tagName );
759            if ( packageNameFeature.getReference() != null )
760            {
761                writeReference( (Reference) packageNameFeature.getReference(), "reference", serializer );
762            }
763            serializer.writeEndElement();
764        }
765    } //-- void writePackageNameFeature( PackageNameFeature, String, XMLStreamWriter )
766
767    /**
768     * Method writeReference.
769     * 
770     * @param reference
771     * @param serializer
772     * @param tagName
773     * @throws java.io.IOException
774     * @throws XMLStreamException
775     */
776    private void writeReference( Reference reference, String tagName, XMLStreamWriter serializer )
777        throws java.io.IOException, XMLStreamException
778    {
779        if ( reference != null )
780        {
781            serializer.writeStartElement( tagName );
782            if ( reference.getId() != null )
783            {
784                serializer.writeStartElement( "id" );
785                serializer.writeCharacters( reference.getId() );
786                serializer.writeEndElement();
787            }
788            serializer.writeEndElement();
789        }
790    } //-- void writeReference( Reference, String, XMLStreamWriter )
791
792    /**
793     * Method writeSimpleTypes.
794     * 
795     * @param simpleTypes
796     * @param serializer
797     * @param tagName
798     * @throws java.io.IOException
799     * @throws XMLStreamException
800     */
801    private void writeSimpleTypes( SimpleTypes simpleTypes, String tagName, XMLStreamWriter serializer )
802        throws java.io.IOException, XMLStreamException
803    {
804        if ( simpleTypes != null )
805        {
806            serializer.writeStartElement( tagName );
807            if ( simpleTypes.isPrimitiveBoolean() != true )
808            {
809                serializer.writeStartElement( "primitiveBoolean" );
810                serializer.writeCharacters( String.valueOf( simpleTypes.isPrimitiveBoolean() ) );
811                serializer.writeEndElement();
812            }
813            if ( simpleTypes.getPrimitiveChar() != 'H' )
814            {
815                serializer.writeStartElement( "primitiveChar" );
816                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveChar() ) );
817                serializer.writeEndElement();
818            }
819            if ( simpleTypes.getPrimitiveByte() != 12 )
820            {
821                serializer.writeStartElement( "primitiveByte" );
822                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveByte() ) );
823                serializer.writeEndElement();
824            }
825            if ( simpleTypes.getPrimitiveShort() != 1212 )
826            {
827                serializer.writeStartElement( "primitiveShort" );
828                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveShort() ) );
829                serializer.writeEndElement();
830            }
831            if ( simpleTypes.getPrimitiveInt() != 121212 )
832            {
833                serializer.writeStartElement( "primitiveInt" );
834                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveInt() ) );
835                serializer.writeEndElement();
836            }
837            if ( simpleTypes.getPrimitiveLong() != 1234567890123L )
838            {
839                serializer.writeStartElement( "primitiveLong" );
840                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveLong() ) );
841                serializer.writeEndElement();
842            }
843            if ( simpleTypes.getPrimitiveFloat() != 12.12f )
844            {
845                serializer.writeStartElement( "primitiveFloat" );
846                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveFloat() ) );
847                serializer.writeEndElement();
848            }
849            if ( simpleTypes.getPrimitiveDouble() != 12.12 )
850            {
851                serializer.writeStartElement( "primitiveDouble" );
852                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveDouble() ) );
853                serializer.writeEndElement();
854            }
855            if ( ( simpleTypes.getObjectString() != null ) && !simpleTypes.getObjectString().equals( "default value" ) )
856            {
857                serializer.writeStartElement( "objectString" );
858                serializer.writeCharacters( simpleTypes.getObjectString() );
859                serializer.writeEndElement();
860            }
861            if ( ( simpleTypes.getObjectDate() != null ) && !simpleTypes.getObjectDate().equals( new java.util.Date( 1356383532012L ) ) )
862            {
863                serializer.writeStartElement( "objectDate" );
864                serializer.writeCharacters( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( simpleTypes.getObjectDate() ) );
865                serializer.writeEndElement();
866            }
867            if ( simpleTypes.isPrimitiveBooleanNoDefault() != false )
868            {
869                serializer.writeStartElement( "primitiveBooleanNoDefault" );
870                serializer.writeCharacters( String.valueOf( simpleTypes.isPrimitiveBooleanNoDefault() ) );
871                serializer.writeEndElement();
872            }
873            if ( simpleTypes.getPrimitiveCharNoDefault() != '\0' )
874            {
875                serializer.writeStartElement( "primitiveCharNoDefault" );
876                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveCharNoDefault() ) );
877                serializer.writeEndElement();
878            }
879            if ( simpleTypes.getPrimitiveByteNoDefault() != 0 )
880            {
881                serializer.writeStartElement( "primitiveByteNoDefault" );
882                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveByteNoDefault() ) );
883                serializer.writeEndElement();
884            }
885            if ( simpleTypes.getPrimitiveShortNoDefault() != 0 )
886            {
887                serializer.writeStartElement( "primitiveShortNoDefault" );
888                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveShortNoDefault() ) );
889                serializer.writeEndElement();
890            }
891            if ( simpleTypes.getPrimitiveIntNoDefault() != 0 )
892            {
893                serializer.writeStartElement( "primitiveIntNoDefault" );
894                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveIntNoDefault() ) );
895                serializer.writeEndElement();
896            }
897            if ( simpleTypes.getPrimitiveLongNoDefault() != 0L )
898            {
899                serializer.writeStartElement( "primitiveLongNoDefault" );
900                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveLongNoDefault() ) );
901                serializer.writeEndElement();
902            }
903            if ( simpleTypes.getPrimitiveFloatNoDefault() != 0.0f )
904            {
905                serializer.writeStartElement( "primitiveFloatNoDefault" );
906                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveFloatNoDefault() ) );
907                serializer.writeEndElement();
908            }
909            if ( simpleTypes.getPrimitiveDoubleNoDefault() != 0.0 )
910            {
911                serializer.writeStartElement( "primitiveDoubleNoDefault" );
912                serializer.writeCharacters( String.valueOf( simpleTypes.getPrimitiveDoubleNoDefault() ) );
913                serializer.writeEndElement();
914            }
915            if ( simpleTypes.getObjectStringNoDefault() != null )
916            {
917                serializer.writeStartElement( "objectStringNoDefault" );
918                serializer.writeCharacters( simpleTypes.getObjectStringNoDefault() );
919                serializer.writeEndElement();
920            }
921            if ( simpleTypes.getObjectDateNoDefault() != null )
922            {
923                serializer.writeStartElement( "objectDateNoDefault" );
924                serializer.writeCharacters( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( simpleTypes.getObjectDateNoDefault() ) );
925                serializer.writeEndElement();
926            }
927            if ( simpleTypes.getDom() != null )
928            {
929                writeDom( (Xpp3Dom) simpleTypes.getDom(), serializer );
930            }
931            if ( simpleTypes.getContent() != null )
932            {
933                writeContentTest( (ContentTest) simpleTypes.getContent(), "content", serializer );
934            }
935            serializer.writeEndElement();
936        }
937    } //-- void writeSimpleTypes( SimpleTypes, String, XMLStreamWriter )
938
939    /**
940     * Method writeSubClassLevel1.
941     * 
942     * @param subClassLevel1
943     * @param serializer
944     * @param tagName
945     * @throws java.io.IOException
946     * @throws XMLStreamException
947     */
948    private void writeSubClassLevel1( SubClassLevel1 subClassLevel1, String tagName, XMLStreamWriter serializer )
949        throws java.io.IOException, XMLStreamException
950    {
951        if ( subClassLevel1 != null )
952        {
953            serializer.writeStartElement( tagName );
954            if ( subClassLevel1.getSubAttribute1() != 0L )
955            {
956                serializer.writeAttribute( "subAttribute1", String.valueOf( subClassLevel1.getSubAttribute1() ) );
957            }
958            if ( subClassLevel1.getBaseAttribute() != 0 )
959            {
960                serializer.writeAttribute( "baseAttribute", String.valueOf( subClassLevel1.getBaseAttribute() ) );
961            }
962            if ( subClassLevel1.getSubElement1() != 0L )
963            {
964                serializer.writeStartElement( "subElement1" );
965                serializer.writeCharacters( String.valueOf( subClassLevel1.getSubElement1() ) );
966                serializer.writeEndElement();
967            }
968            if ( subClassLevel1.getBaseElement() != 0 )
969            {
970                serializer.writeStartElement( "baseElement" );
971                serializer.writeCharacters( String.valueOf( subClassLevel1.getBaseElement() ) );
972                serializer.writeEndElement();
973            }
974            serializer.writeEndElement();
975        }
976    } //-- void writeSubClassLevel1( SubClassLevel1, String, XMLStreamWriter )
977
978    /**
979     * Method writeSubClassLevel2.
980     * 
981     * @param subClassLevel2
982     * @param serializer
983     * @param tagName
984     * @throws java.io.IOException
985     * @throws XMLStreamException
986     */
987    private void writeSubClassLevel2( SubClassLevel2 subClassLevel2, String tagName, XMLStreamWriter serializer )
988        throws java.io.IOException, XMLStreamException
989    {
990        if ( subClassLevel2 != null )
991        {
992            serializer.writeStartElement( tagName );
993            if ( subClassLevel2.getSubAttribute2() != 0.0f )
994            {
995                serializer.writeAttribute( "subAttribute2", String.valueOf( subClassLevel2.getSubAttribute2() ) );
996            }
997            if ( subClassLevel2.getSubAttribute1() != 0L )
998            {
999                serializer.writeAttribute( "subAttribute1", String.valueOf( subClassLevel2.getSubAttribute1() ) );
1000            }
1001            if ( subClassLevel2.getBaseAttribute() != 0 )
1002            {
1003                serializer.writeAttribute( "baseAttribute", String.valueOf( subClassLevel2.getBaseAttribute() ) );
1004            }
1005            if ( subClassLevel2.getSubElement2() != 0.0f )
1006            {
1007                serializer.writeStartElement( "subElement2" );
1008                serializer.writeCharacters( String.valueOf( subClassLevel2.getSubElement2() ) );
1009                serializer.writeEndElement();
1010            }
1011            if ( subClassLevel2.getSubElement1() != 0L )
1012            {
1013                serializer.writeStartElement( "subElement1" );
1014                serializer.writeCharacters( String.valueOf( subClassLevel2.getSubElement1() ) );
1015                serializer.writeEndElement();
1016            }
1017            if ( subClassLevel2.getBaseElement() != 0 )
1018            {
1019                serializer.writeStartElement( "baseElement" );
1020                serializer.writeCharacters( String.valueOf( subClassLevel2.getBaseElement() ) );
1021                serializer.writeEndElement();
1022            }
1023            serializer.writeEndElement();
1024        }
1025    } //-- void writeSubClassLevel2( SubClassLevel2, String, XMLStreamWriter )
1026
1027    /**
1028     * Method writeSubClassLevel3.
1029     * 
1030     * @param subClassLevel3
1031     * @param serializer
1032     * @param tagName
1033     * @throws java.io.IOException
1034     * @throws XMLStreamException
1035     */
1036    private void writeSubClassLevel3( SubClassLevel3 subClassLevel3, String tagName, XMLStreamWriter serializer )
1037        throws java.io.IOException, XMLStreamException
1038    {
1039        if ( subClassLevel3 != null )
1040        {
1041            serializer.writeStartElement( tagName );
1042            if ( subClassLevel3.getSubAttribute3() != 0.0 )
1043            {
1044                serializer.writeAttribute( "subAttribute3", String.valueOf( subClassLevel3.getSubAttribute3() ) );
1045            }
1046            if ( subClassLevel3.getSubAttribute2() != 0.0f )
1047            {
1048                serializer.writeAttribute( "subAttribute2", String.valueOf( subClassLevel3.getSubAttribute2() ) );
1049            }
1050            if ( subClassLevel3.getSubAttribute1() != 0L )
1051            {
1052                serializer.writeAttribute( "subAttribute1", String.valueOf( subClassLevel3.getSubAttribute1() ) );
1053            }
1054            if ( subClassLevel3.getBaseAttribute() != 0 )
1055            {
1056                serializer.writeAttribute( "baseAttribute", String.valueOf( subClassLevel3.getBaseAttribute() ) );
1057            }
1058            if ( subClassLevel3.getSubElement3() != 0.0 )
1059            {
1060                serializer.writeStartElement( "subElement3" );
1061                serializer.writeCharacters( String.valueOf( subClassLevel3.getSubElement3() ) );
1062                serializer.writeEndElement();
1063            }
1064            if ( subClassLevel3.getSubElement2() != 0.0f )
1065            {
1066                serializer.writeStartElement( "subElement2" );
1067                serializer.writeCharacters( String.valueOf( subClassLevel3.getSubElement2() ) );
1068                serializer.writeEndElement();
1069            }
1070            if ( subClassLevel3.getSubElement1() != 0L )
1071            {
1072                serializer.writeStartElement( "subElement1" );
1073                serializer.writeCharacters( String.valueOf( subClassLevel3.getSubElement1() ) );
1074                serializer.writeEndElement();
1075            }
1076            if ( subClassLevel3.getBaseElement() != 0 )
1077            {
1078                serializer.writeStartElement( "baseElement" );
1079                serializer.writeCharacters( String.valueOf( subClassLevel3.getBaseElement() ) );
1080                serializer.writeEndElement();
1081            }
1082            serializer.writeEndElement();
1083        }
1084    } //-- void writeSubClassLevel3( SubClassLevel3, String, XMLStreamWriter )
1085
1086    /**
1087     * Method writeSuperThing.
1088     * 
1089     * @param superThing
1090     * @param serializer
1091     * @param tagName
1092     * @throws java.io.IOException
1093     * @throws XMLStreamException
1094     */
1095    private void writeSuperThing( SuperThing superThing, String tagName, XMLStreamWriter serializer )
1096        throws java.io.IOException, XMLStreamException
1097    {
1098        if ( superThing != null )
1099        {
1100            serializer.writeStartElement( tagName );
1101            serializer.writeEndElement();
1102        }
1103    } //-- void writeSuperThing( SuperThing, String, XMLStreamWriter )
1104
1105    /**
1106     * Method writeThing.
1107     * 
1108     * @param thing
1109     * @param serializer
1110     * @param tagName
1111     * @throws java.io.IOException
1112     * @throws XMLStreamException
1113     */
1114    private void writeThing( Thing thing, String tagName, XMLStreamWriter serializer )
1115        throws java.io.IOException, XMLStreamException
1116    {
1117        if ( thing != null )
1118        {
1119            serializer.writeStartElement( tagName );
1120            if ( thing.isSomeBoolean() != false )
1121            {
1122                serializer.writeStartElement( "someBoolean" );
1123                serializer.writeCharacters( String.valueOf( thing.isSomeBoolean() ) );
1124                serializer.writeEndElement();
1125            }
1126            if ( thing.getSomeChar() != '\0' )
1127            {
1128                serializer.writeStartElement( "someChar" );
1129                serializer.writeCharacters( String.valueOf( thing.getSomeChar() ) );
1130                serializer.writeEndElement();
1131            }
1132            if ( thing.getSomeByte() != 0 )
1133            {
1134                serializer.writeStartElement( "someByte" );
1135                serializer.writeCharacters( String.valueOf( thing.getSomeByte() ) );
1136                serializer.writeEndElement();
1137            }
1138            if ( thing.getSomeShort() != 0 )
1139            {
1140                serializer.writeStartElement( "someShort" );
1141                serializer.writeCharacters( String.valueOf( thing.getSomeShort() ) );
1142                serializer.writeEndElement();
1143            }
1144            if ( thing.getSomeInt() != 0 )
1145            {
1146                serializer.writeStartElement( "someInt" );
1147                serializer.writeCharacters( String.valueOf( thing.getSomeInt() ) );
1148                serializer.writeEndElement();
1149            }
1150            if ( thing.getSomeLong() != 0L )
1151            {
1152                serializer.writeStartElement( "someLong" );
1153                serializer.writeCharacters( String.valueOf( thing.getSomeLong() ) );
1154                serializer.writeEndElement();
1155            }
1156            if ( thing.getSomeFloat() != 0.0f )
1157            {
1158                serializer.writeStartElement( "someFloat" );
1159                serializer.writeCharacters( String.valueOf( thing.getSomeFloat() ) );
1160                serializer.writeEndElement();
1161            }
1162            if ( thing.getSomeDouble() != 0.0 )
1163            {
1164                serializer.writeStartElement( "someDouble" );
1165                serializer.writeCharacters( String.valueOf( thing.getSomeDouble() ) );
1166                serializer.writeEndElement();
1167            }
1168            if ( thing.getSomeString() != null )
1169            {
1170                serializer.writeStartElement( "someString" );
1171                serializer.writeCharacters( thing.getSomeString() );
1172                serializer.writeEndElement();
1173            }
1174            if ( thing.getSomeDate() != null )
1175            {
1176                serializer.writeStartElement( "someDate" );
1177                serializer.writeCharacters( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( thing.getSomeDate() ) );
1178                serializer.writeEndElement();
1179            }
1180            if ( thing.getSomeDom() != null )
1181            {
1182                writeDom( (Xpp3Dom) thing.getSomeDom(), serializer );
1183            }
1184            if ( ( thing.getSomeProperties() != null ) && ( thing.getSomeProperties().size() > 0 ) )
1185            {
1186                serializer.writeStartElement( "someProperties" );
1187                for ( Iterator iter = thing.getSomeProperties().keySet().iterator(); iter.hasNext(); )
1188                {
1189                    String key = (String) iter.next();
1190                    String value = (String) thing.getSomeProperties().get( key );
1191                    serializer.writeStartElement( "" + key + "" );
1192                    serializer.writeCharacters( value );
1193                    serializer.writeEndElement();
1194                }
1195                serializer.writeEndElement();
1196            }
1197            if ( ( thing.getSomeStringList() != null ) && ( thing.getSomeStringList().size() > 0 ) )
1198            {
1199                serializer.writeStartElement( "someStringList" );
1200                for ( Iterator iter = thing.getSomeStringList().iterator(); iter.hasNext(); )
1201                {
1202                    String someStringList = (String) iter.next();
1203                    serializer.writeStartElement( "someStringList" );
1204                    serializer.writeCharacters( someStringList );
1205                    serializer.writeEndElement();
1206                }
1207                serializer.writeEndElement();
1208            }
1209            if ( ( thing.getSomeStringSet() != null ) && ( thing.getSomeStringSet().size() > 0 ) )
1210            {
1211                serializer.writeStartElement( "someStringSet" );
1212                for ( Iterator iter = thing.getSomeStringSet().iterator(); iter.hasNext(); )
1213                {
1214                    String someStringSet = (String) iter.next();
1215                    serializer.writeStartElement( "someStringSet" );
1216                    serializer.writeCharacters( someStringSet );
1217                    serializer.writeEndElement();
1218                }
1219                serializer.writeEndElement();
1220            }
1221            if ( thing.getDeepThingy() != null )
1222            {
1223                writeThingy( (Thingy) thing.getDeepThingy(), "deepThingy", serializer );
1224            }
1225            if ( ( thing.getDeepThingyList() != null ) && ( thing.getDeepThingyList().size() > 0 ) )
1226            {
1227                serializer.writeStartElement( "deepThingyList" );
1228                for ( Iterator iter = thing.getDeepThingyList().iterator(); iter.hasNext(); )
1229                {
1230                    Thingy o = (Thingy) iter.next();
1231                    writeThingy( o, "deepThingyList", serializer );
1232                }
1233                serializer.writeEndElement();
1234            }
1235            if ( ( thing.getDeepThingySet() != null ) && ( thing.getDeepThingySet().size() > 0 ) )
1236            {
1237                serializer.writeStartElement( "deepThingySet" );
1238                for ( Iterator iter = thing.getDeepThingySet().iterator(); iter.hasNext(); )
1239                {
1240                    Thingy o = (Thingy) iter.next();
1241                    writeThingy( o, "deepThingySet", serializer );
1242                }
1243                serializer.writeEndElement();
1244            }
1245            if ( thing.getShallowThingy() != null )
1246            {
1247                writeThingy( (Thingy) thing.getShallowThingy(), "shallowThingy", serializer );
1248            }
1249            if ( ( thing.getShallowThingyList() != null ) && ( thing.getShallowThingyList().size() > 0 ) )
1250            {
1251                serializer.writeStartElement( "shallowThingyList" );
1252                for ( Iterator iter = thing.getShallowThingyList().iterator(); iter.hasNext(); )
1253                {
1254                    Thingy o = (Thingy) iter.next();
1255                    writeThingy( o, "shallowThingyList", serializer );
1256                }
1257                serializer.writeEndElement();
1258            }
1259            if ( ( thing.getShallowThingySet() != null ) && ( thing.getShallowThingySet().size() > 0 ) )
1260            {
1261                serializer.writeStartElement( "shallowThingySet" );
1262                for ( Iterator iter = thing.getShallowThingySet().iterator(); iter.hasNext(); )
1263                {
1264                    Thingy o = (Thingy) iter.next();
1265                    writeThingy( o, "shallowThingySet", serializer );
1266                }
1267                serializer.writeEndElement();
1268            }
1269            serializer.writeEndElement();
1270        }
1271    } //-- void writeThing( Thing, String, XMLStreamWriter )
1272
1273    /**
1274     * Method writeThingy.
1275     * 
1276     * @param thingy
1277     * @param serializer
1278     * @param tagName
1279     * @throws java.io.IOException
1280     * @throws XMLStreamException
1281     */
1282    private void writeThingy( Thingy thingy, String tagName, XMLStreamWriter serializer )
1283        throws java.io.IOException, XMLStreamException
1284    {
1285        if ( thingy != null )
1286        {
1287            serializer.writeStartElement( tagName );
1288            serializer.writeCharacters( thingy.getSomeContent() );
1289            serializer.writeEndElement();
1290        }
1291    } //-- void writeThingy( Thingy, String, XMLStreamWriter )
1292
1293    /**
1294     * Method writeXdocFeatures.
1295     * 
1296     * @param xdocFeatures
1297     * @param serializer
1298     * @param tagName
1299     * @throws java.io.IOException
1300     * @throws XMLStreamException
1301     */
1302    private void writeXdocFeatures( XdocFeatures xdocFeatures, String tagName, XMLStreamWriter serializer )
1303        throws java.io.IOException, XMLStreamException
1304    {
1305        if ( xdocFeatures != null )
1306        {
1307            serializer.writeStartElement( tagName );
1308            if ( xdocFeatures.getField() != null )
1309            {
1310                serializer.writeStartElement( "field" );
1311                serializer.writeCharacters( xdocFeatures.getField() );
1312                serializer.writeEndElement();
1313            }
1314            if ( xdocFeatures.getXdocSeparatorNone() != null )
1315            {
1316                serializer.writeStartElement( "xdocSeparatorNone" );
1317                serializer.writeCharacters( xdocFeatures.getXdocSeparatorNone() );
1318                serializer.writeEndElement();
1319            }
1320            if ( xdocFeatures.getXdocSeparatorBlank() != null )
1321            {
1322                serializer.writeStartElement( "xdocSeparatorBlank" );
1323                serializer.writeCharacters( xdocFeatures.getXdocSeparatorBlank() );
1324                serializer.writeEndElement();
1325            }
1326            serializer.writeEndElement();
1327        }
1328    } //-- void writeXdocFeatures( XdocFeatures, String, XMLStreamWriter )
1329
1330    /**
1331     * Method writeXmlAttributes.
1332     * 
1333     * @param xmlAttributes
1334     * @param serializer
1335     * @param tagName
1336     * @throws java.io.IOException
1337     * @throws XMLStreamException
1338     */
1339    private void writeXmlAttributes( XmlAttributes xmlAttributes, String tagName, XMLStreamWriter serializer )
1340        throws java.io.IOException, XMLStreamException
1341    {
1342        if ( xmlAttributes != null )
1343        {
1344            serializer.writeStartElement( tagName );
1345            if ( xmlAttributes.isPrimitiveBoolean() != true )
1346            {
1347                serializer.writeAttribute( "primitiveBoolean", String.valueOf( xmlAttributes.isPrimitiveBoolean() ) );
1348            }
1349            if ( xmlAttributes.getPrimitiveChar() != 'H' )
1350            {
1351                serializer.writeAttribute( "primitiveChar", String.valueOf( xmlAttributes.getPrimitiveChar() ) );
1352            }
1353            if ( xmlAttributes.getPrimitiveByte() != 12 )
1354            {
1355                serializer.writeAttribute( "primitiveByte", String.valueOf( xmlAttributes.getPrimitiveByte() ) );
1356            }
1357            if ( xmlAttributes.getPrimitiveShort() != 1212 )
1358            {
1359                serializer.writeAttribute( "primitiveShort", String.valueOf( xmlAttributes.getPrimitiveShort() ) );
1360            }
1361            if ( xmlAttributes.getPrimitiveInt() != 121212 )
1362            {
1363                serializer.writeAttribute( "primitiveInt", String.valueOf( xmlAttributes.getPrimitiveInt() ) );
1364            }
1365            if ( xmlAttributes.getPrimitiveLong() != 1234567890123L )
1366            {
1367                serializer.writeAttribute( "primitiveLong", String.valueOf( xmlAttributes.getPrimitiveLong() ) );
1368            }
1369            if ( xmlAttributes.getPrimitiveFloat() != 12.12f )
1370            {
1371                serializer.writeAttribute( "primitiveFloat", String.valueOf( xmlAttributes.getPrimitiveFloat() ) );
1372            }
1373            if ( xmlAttributes.getPrimitiveDouble() != 12.12 )
1374            {
1375                serializer.writeAttribute( "primitiveDouble", String.valueOf( xmlAttributes.getPrimitiveDouble() ) );
1376            }
1377            if ( ( xmlAttributes.getObjectString() != null ) && !xmlAttributes.getObjectString().equals( "default value" ) )
1378            {
1379                serializer.writeAttribute( "objectString", xmlAttributes.getObjectString() );
1380            }
1381            if ( xmlAttributes.getObjectDate() != null )
1382            {
1383                serializer.writeAttribute( "objectDate", new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( xmlAttributes.getObjectDate() ) );
1384            }
1385            if ( ( xmlAttributes.getAttribute() != null ) && !xmlAttributes.getAttribute().equals( "default" ) )
1386            {
1387                serializer.writeAttribute( "tag-name", xmlAttributes.getAttribute() );
1388            }
1389            serializer.writeEndElement();
1390        }
1391    } //-- void writeXmlAttributes( XmlAttributes, String, XMLStreamWriter )
1392
1393    /**
1394     * Method writeXmlContent.
1395     * 
1396     * @param xmlContent
1397     * @param serializer
1398     * @param tagName
1399     * @throws java.io.IOException
1400     * @throws XMLStreamException
1401     */
1402    private void writeXmlContent( XmlContent xmlContent, String tagName, XMLStreamWriter serializer )
1403        throws java.io.IOException, XMLStreamException
1404    {
1405        if ( xmlContent != null )
1406        {
1407            serializer.writeStartElement( tagName );
1408            if ( xmlContent.getLongContent() != null )
1409            {
1410                writeXmlContentLong( (XmlContentLong) xmlContent.getLongContent(), "content.long", serializer );
1411            }
1412            if ( xmlContent.getLongContentWithAttributes() != null )
1413            {
1414                writeXmlContentLongWithAttributes( (XmlContentLongWithAttributes) xmlContent.getLongContentWithAttributes(), "content.long-with-attributes", serializer );
1415            }
1416            serializer.writeEndElement();
1417        }
1418    } //-- void writeXmlContent( XmlContent, String, XMLStreamWriter )
1419
1420    /**
1421     * Method writeXmlContentLong.
1422     * 
1423     * @param xmlContentLong
1424     * @param serializer
1425     * @param tagName
1426     * @throws java.io.IOException
1427     * @throws XMLStreamException
1428     */
1429    private void writeXmlContentLong( XmlContentLong xmlContentLong, String tagName, XMLStreamWriter serializer )
1430        throws java.io.IOException, XMLStreamException
1431    {
1432        if ( xmlContentLong != null )
1433        {
1434            serializer.writeStartElement( tagName );
1435            serializer.writeCharacters( String.valueOf( xmlContentLong.getContent() ) );
1436            serializer.writeEndElement();
1437        }
1438    } //-- void writeXmlContentLong( XmlContentLong, String, XMLStreamWriter )
1439
1440    /**
1441     * Method writeXmlContentLongWithAttributes.
1442     * 
1443     * @param xmlContentLongWithAttributes
1444     * @param serializer
1445     * @param tagName
1446     * @throws java.io.IOException
1447     * @throws XMLStreamException
1448     */
1449    private void writeXmlContentLongWithAttributes( XmlContentLongWithAttributes xmlContentLongWithAttributes, String tagName, XMLStreamWriter serializer )
1450        throws java.io.IOException, XMLStreamException
1451    {
1452        if ( xmlContentLongWithAttributes != null )
1453        {
1454            serializer.writeStartElement( tagName );
1455            if ( xmlContentLongWithAttributes.getAttr() != null )
1456            {
1457                serializer.writeAttribute( "attr", xmlContentLongWithAttributes.getAttr() );
1458            }
1459            if ( xmlContentLongWithAttributes.getAttr2() != 0 )
1460            {
1461                serializer.writeAttribute( "attr2", String.valueOf( xmlContentLongWithAttributes.getAttr2() ) );
1462            }
1463            serializer.writeCharacters( String.valueOf( xmlContentLongWithAttributes.getContent() ) );
1464            serializer.writeEndElement();
1465        }
1466    } //-- void writeXmlContentLongWithAttributes( XmlContentLongWithAttributes, String, XMLStreamWriter )
1467
1468    /**
1469     * Method writeXmlFeatures.
1470     * 
1471     * @param xmlFeatures
1472     * @param serializer
1473     * @param tagName
1474     * @throws java.io.IOException
1475     * @throws XMLStreamException
1476     */
1477    private void writeXmlFeatures( XmlFeatures xmlFeatures, String tagName, XMLStreamWriter serializer )
1478        throws java.io.IOException, XMLStreamException
1479    {
1480        if ( xmlFeatures != null )
1481        {
1482            serializer.writeStartElement( tagName );
1483            if ( xmlFeatures.getFieldNameAttribute() != null )
1484            {
1485                serializer.writeAttribute( "tag-name.attribute", xmlFeatures.getFieldNameAttribute() );
1486            }
1487            if ( xmlFeatures.getAttributes() != null )
1488            {
1489                writeXmlAttributes( (XmlAttributes) xmlFeatures.getAttributes(), "attributes", serializer );
1490            }
1491            if ( xmlFeatures.getAttributesDefault() != null )
1492            {
1493                writeXmlAttributes( (XmlAttributes) xmlFeatures.getAttributesDefault(), "attributesDefault", serializer );
1494            }
1495            if ( xmlFeatures.getContent() != null )
1496            {
1497                writeXmlContent( (XmlContent) xmlFeatures.getContent(), "content", serializer );
1498            }
1499            if ( xmlFeatures.getFieldTrim() != null )
1500            {
1501                serializer.writeStartElement( "fieldTrim" );
1502                serializer.writeCharacters( xmlFeatures.getFieldTrim() );
1503                serializer.writeEndElement();
1504            }
1505            if ( xmlFeatures.getFieldNoTrim() != null )
1506            {
1507                serializer.writeStartElement( "fieldNoTrim" );
1508                serializer.writeCharacters( xmlFeatures.getFieldNoTrim() );
1509                serializer.writeEndElement();
1510            }
1511            if ( xmlFeatures.getDom() != null )
1512            {
1513                writeDom( (Xpp3Dom) xmlFeatures.getDom(), serializer );
1514            }
1515            if ( xmlFeatures.getDomNoTrim() != null )
1516            {
1517                writeDom( (Xpp3Dom) xmlFeatures.getDomNoTrim(), serializer );
1518            }
1519            if ( xmlFeatures.getFieldName() != null )
1520            {
1521                serializer.writeStartElement( "tag-name" );
1522                serializer.writeCharacters( xmlFeatures.getFieldName() );
1523                serializer.writeEndElement();
1524            }
1525            if ( xmlFeatures.getDateXmlFormat() != null )
1526            {
1527                serializer.writeStartElement( "dateXmlFormat" );
1528                serializer.writeCharacters( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss", java.util.Locale.US ).format( xmlFeatures.getDateXmlFormat() ) );
1529                serializer.writeEndElement();
1530            }
1531            if ( xmlFeatures.getDateLong() != null )
1532            {
1533                serializer.writeStartElement( "dateLong" );
1534                serializer.writeCharacters( String.valueOf( xmlFeatures.getDateLong().getTime() ) );
1535                serializer.writeEndElement();
1536            }
1537            if ( ( xmlFeatures.getXmlItemsStyleFlats() != null ) && ( xmlFeatures.getXmlItemsStyleFlats().size() > 0 ) )
1538            {
1539                for ( Iterator iter = xmlFeatures.getXmlItemsStyleFlats().iterator(); iter.hasNext(); )
1540                {
1541                    Reference o = (Reference) iter.next();
1542                    writeReference( o, "xmlItemsStyleFlat", serializer );
1543                }
1544            }
1545            if ( ( xmlFeatures.getXmlAssociationTagNames() != null ) && ( xmlFeatures.getXmlAssociationTagNames().size() > 0 ) )
1546            {
1547                serializer.writeStartElement( "xmlAssociationTagNames" );
1548                for ( Iterator iter = xmlFeatures.getXmlAssociationTagNames().iterator(); iter.hasNext(); )
1549                {
1550                    Reference o = (Reference) iter.next();
1551                    writeReference( o, "association.tag-name", serializer );
1552                }
1553                serializer.writeEndElement();
1554            }
1555            if ( ( xmlFeatures.getXmlTagNameAssociation() != null ) && ( xmlFeatures.getXmlTagNameAssociation().size() > 0 ) )
1556            {
1557                serializer.writeStartElement( "field.tag-names" );
1558                for ( Iterator iter = xmlFeatures.getXmlTagNameAssociation().iterator(); iter.hasNext(); )
1559                {
1560                    Reference o = (Reference) iter.next();
1561                    writeReference( o, "field.tag-name", serializer );
1562                }
1563                serializer.writeEndElement();
1564            }
1565            if ( ( xmlFeatures.getXmlTagNameAssociationTagNames() != null ) && ( xmlFeatures.getXmlTagNameAssociationTagNames().size() > 0 ) )
1566            {
1567                serializer.writeStartElement( "field.tag-name" );
1568                for ( Iterator iter = xmlFeatures.getXmlTagNameAssociationTagNames().iterator(); iter.hasNext(); )
1569                {
1570                    Reference o = (Reference) iter.next();
1571                    writeReference( o, "association.tag-name", serializer );
1572                }
1573                serializer.writeEndElement();
1574            }
1575            if ( ( xmlFeatures.getXmlFlatAssociationTagNames() != null ) && ( xmlFeatures.getXmlFlatAssociationTagNames().size() > 0 ) )
1576            {
1577                for ( Iterator iter = xmlFeatures.getXmlFlatAssociationTagNames().iterator(); iter.hasNext(); )
1578                {
1579                    Reference o = (Reference) iter.next();
1580                    writeReference( o, "association.tag-name", serializer );
1581                }
1582            }
1583            if ( ( xmlFeatures.getExplodeProperties() != null ) && ( xmlFeatures.getExplodeProperties().size() > 0 ) )
1584            {
1585                serializer.writeStartElement( "explodeProperties" );
1586                for ( Iterator iter = xmlFeatures.getExplodeProperties().keySet().iterator(); iter.hasNext(); )
1587                {
1588                    String key = (String) iter.next();
1589                    String value = (String) xmlFeatures.getExplodeProperties().get( key );
1590                    serializer.writeStartElement( "explodeProperty" );
1591                    serializer.writeStartElement( "key" );
1592                    serializer.writeCharacters( key );
1593                    serializer.writeEndElement();
1594                    serializer.writeStartElement( "value" );
1595                    serializer.writeCharacters( value );
1596                    serializer.writeEndElement();
1597                    serializer.writeEndElement();
1598                }
1599                serializer.writeEndElement();
1600            }
1601            if ( ( xmlFeatures.getInlineProperties() != null ) && ( xmlFeatures.getInlineProperties().size() > 0 ) )
1602            {
1603                serializer.writeStartElement( "inlineProperties" );
1604                for ( Iterator iter = xmlFeatures.getInlineProperties().keySet().iterator(); iter.hasNext(); )
1605                {
1606                    String key = (String) iter.next();
1607                    String value = (String) xmlFeatures.getInlineProperties().get( key );
1608                    serializer.writeStartElement( "" + key + "" );
1609                    serializer.writeCharacters( value );
1610                    serializer.writeEndElement();
1611                }
1612                serializer.writeEndElement();
1613            }
1614            if ( xmlFeatures.getXmlTransientFields() != null )
1615            {
1616                writeXmlTransientFields( (XmlTransientFields) xmlFeatures.getXmlTransientFields(), "xmlTransientFields", serializer );
1617            }
1618            if ( xmlFeatures.getXmlFieldsOrder() != null )
1619            {
1620                writeXmlFieldsOrder( (XmlFieldsOrder) xmlFeatures.getXmlFieldsOrder(), "xmlFieldsOrder", serializer );
1621            }
1622            if ( xmlFeatures.getXsdFeatures() != null )
1623            {
1624                writeXsdFeatures( (XsdFeatures) xmlFeatures.getXsdFeatures(), "xsdFeatures", serializer );
1625            }
1626            serializer.writeEndElement();
1627        }
1628    } //-- void writeXmlFeatures( XmlFeatures, String, XMLStreamWriter )
1629
1630    /**
1631     * Method writeXmlFieldsOrder.
1632     * 
1633     * @param xmlFieldsOrder
1634     * @param serializer
1635     * @param tagName
1636     * @throws java.io.IOException
1637     * @throws XMLStreamException
1638     */
1639    private void writeXmlFieldsOrder( XmlFieldsOrder xmlFieldsOrder, String tagName, XMLStreamWriter serializer )
1640        throws java.io.IOException, XMLStreamException
1641    {
1642        if ( xmlFieldsOrder != null )
1643        {
1644            serializer.writeStartElement( tagName );
1645            if ( xmlFieldsOrder.getField1() != null )
1646            {
1647                serializer.writeStartElement( "field1" );
1648                serializer.writeCharacters( xmlFieldsOrder.getField1() );
1649                serializer.writeEndElement();
1650            }
1651            if ( xmlFieldsOrder.getField() != null )
1652            {
1653                serializer.writeStartElement( "field-2" );
1654                serializer.writeCharacters( xmlFieldsOrder.getField() );
1655                serializer.writeEndElement();
1656            }
1657            if ( xmlFieldsOrder.getField3() != null )
1658            {
1659                serializer.writeStartElement( "field3" );
1660                serializer.writeCharacters( xmlFieldsOrder.getField3() );
1661                serializer.writeEndElement();
1662            }
1663            if ( xmlFieldsOrder.getField4() != null )
1664            {
1665                serializer.writeStartElement( "field4" );
1666                serializer.writeCharacters( xmlFieldsOrder.getField4() );
1667                serializer.writeEndElement();
1668            }
1669            if ( xmlFieldsOrder.getField5() != null )
1670            {
1671                serializer.writeStartElement( "field5" );
1672                serializer.writeCharacters( xmlFieldsOrder.getField5() );
1673                serializer.writeEndElement();
1674            }
1675            if ( xmlFieldsOrder.getField6() != null )
1676            {
1677                serializer.writeStartElement( "field6" );
1678                serializer.writeCharacters( xmlFieldsOrder.getField6() );
1679                serializer.writeEndElement();
1680            }
1681            if ( xmlFieldsOrder.getField7() != null )
1682            {
1683                serializer.writeStartElement( "field7" );
1684                serializer.writeCharacters( xmlFieldsOrder.getField7() );
1685                serializer.writeEndElement();
1686            }
1687            serializer.writeEndElement();
1688        }
1689    } //-- void writeXmlFieldsOrder( XmlFieldsOrder, String, XMLStreamWriter )
1690
1691    /**
1692     * Method writeXmlFieldsOrderParent.
1693     * 
1694     * @param xmlFieldsOrderParent
1695     * @param serializer
1696     * @param tagName
1697     * @throws java.io.IOException
1698     * @throws XMLStreamException
1699     */
1700    private void writeXmlFieldsOrderParent( XmlFieldsOrderParent xmlFieldsOrderParent, String tagName, XMLStreamWriter serializer )
1701        throws java.io.IOException, XMLStreamException
1702    {
1703        if ( xmlFieldsOrderParent != null )
1704        {
1705            serializer.writeStartElement( tagName );
1706            if ( xmlFieldsOrderParent.getField() != null )
1707            {
1708                serializer.writeStartElement( "field-2" );
1709                serializer.writeCharacters( xmlFieldsOrderParent.getField() );
1710                serializer.writeEndElement();
1711            }
1712            if ( xmlFieldsOrderParent.getField4() != null )
1713            {
1714                serializer.writeStartElement( "field4" );
1715                serializer.writeCharacters( xmlFieldsOrderParent.getField4() );
1716                serializer.writeEndElement();
1717            }
1718            if ( xmlFieldsOrderParent.getField5() != null )
1719            {
1720                serializer.writeStartElement( "field5" );
1721                serializer.writeCharacters( xmlFieldsOrderParent.getField5() );
1722                serializer.writeEndElement();
1723            }
1724            if ( xmlFieldsOrderParent.getField7() != null )
1725            {
1726                serializer.writeStartElement( "field7" );
1727                serializer.writeCharacters( xmlFieldsOrderParent.getField7() );
1728                serializer.writeEndElement();
1729            }
1730            serializer.writeEndElement();
1731        }
1732    } //-- void writeXmlFieldsOrderParent( XmlFieldsOrderParent, String, XMLStreamWriter )
1733
1734    /**
1735     * Method writeXmlFieldsOrderParent2.
1736     * 
1737     * @param xmlFieldsOrderParent2
1738     * @param serializer
1739     * @param tagName
1740     * @throws java.io.IOException
1741     * @throws XMLStreamException
1742     */
1743    private void writeXmlFieldsOrderParent2( XmlFieldsOrderParent2 xmlFieldsOrderParent2, String tagName, XMLStreamWriter serializer )
1744        throws java.io.IOException, XMLStreamException
1745    {
1746        if ( xmlFieldsOrderParent2 != null )
1747        {
1748            serializer.writeStartElement( tagName );
1749            if ( xmlFieldsOrderParent2.getField() != null )
1750            {
1751                serializer.writeStartElement( "field-2" );
1752                serializer.writeCharacters( xmlFieldsOrderParent2.getField() );
1753                serializer.writeEndElement();
1754            }
1755            serializer.writeEndElement();
1756        }
1757    } //-- void writeXmlFieldsOrderParent2( XmlFieldsOrderParent2, String, XMLStreamWriter )
1758
1759    /**
1760     * Method writeXmlTransientFields.
1761     * 
1762     * @param xmlTransientFields
1763     * @param serializer
1764     * @param tagName
1765     * @throws java.io.IOException
1766     * @throws XMLStreamException
1767     */
1768    private void writeXmlTransientFields( XmlTransientFields xmlTransientFields, String tagName, XMLStreamWriter serializer )
1769        throws java.io.IOException, XMLStreamException
1770    {
1771        if ( xmlTransientFields != null )
1772        {
1773            serializer.writeStartElement( tagName );
1774            if ( xmlTransientFields.getPersistentField() != null )
1775            {
1776                serializer.writeStartElement( "persistentField" );
1777                serializer.writeCharacters( xmlTransientFields.getPersistentField() );
1778                serializer.writeEndElement();
1779            }
1780            serializer.writeEndElement();
1781        }
1782    } //-- void writeXmlTransientFields( XmlTransientFields, String, XMLStreamWriter )
1783
1784    /**
1785     * Method writeXsdFeatures.
1786     * 
1787     * @param xsdFeatures
1788     * @param serializer
1789     * @param tagName
1790     * @throws java.io.IOException
1791     * @throws XMLStreamException
1792     */
1793    private void writeXsdFeatures( XsdFeatures xsdFeatures, String tagName, XMLStreamWriter serializer )
1794        throws java.io.IOException, XMLStreamException
1795    {
1796        if ( xsdFeatures != null )
1797        {
1798            serializer.writeStartElement( tagName );
1799            if ( xsdFeatures.getAttribute() != null )
1800            {
1801                serializer.writeAttribute( "attribute", xsdFeatures.getAttribute() );
1802            }
1803            serializer.writeEndElement();
1804        }
1805    } //-- void writeXsdFeatures( XsdFeatures, String, XMLStreamWriter )
1806
1807}