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