1
2
3
4
5
6 package org.codehaus.modello.test.features.io.dom4j;
7
8
9
10
11
12 import java.io.OutputStream;
13 import java.io.Writer;
14 import java.text.DateFormat;
15 import java.util.Arrays;
16 import java.util.Iterator;
17 import java.util.Locale;
18 import org.codehaus.modello.test.features.Action;
19 import org.codehaus.modello.test.features.AnnotationTest;
20 import org.codehaus.modello.test.features.ArrayFeatures;
21 import org.codehaus.modello.test.features.AssociationFeatures;
22 import org.codehaus.modello.test.features.BaseClass;
23 import org.codehaus.modello.test.features.BidiInList;
24 import org.codehaus.modello.test.features.BidiInSet;
25 import org.codehaus.modello.test.features.Bidirectional;
26 import org.codehaus.modello.test.features.ContentTest;
27 import org.codehaus.modello.test.features.DueTo;
28 import org.codehaus.modello.test.features.Features;
29 import org.codehaus.modello.test.features.File;
30 import org.codehaus.modello.test.features.InterfacesFeature;
31 import org.codehaus.modello.test.features.JavaFeatures;
32 import org.codehaus.modello.test.features.NodeItem;
33 import org.codehaus.modello.test.features.Reference;
34 import org.codehaus.modello.test.features.SimpleInterface;
35 import org.codehaus.modello.test.features.SimpleTypes;
36 import org.codehaus.modello.test.features.SubClassLevel1;
37 import org.codehaus.modello.test.features.SubClassLevel2;
38 import org.codehaus.modello.test.features.SubClassLevel3;
39 import org.codehaus.modello.test.features.SubInterface;
40 import org.codehaus.modello.test.features.SuperThing;
41 import org.codehaus.modello.test.features.Thing;
42 import org.codehaus.modello.test.features.Thingy;
43 import org.codehaus.modello.test.features.XdocFeatures;
44 import org.codehaus.modello.test.features.XmlAttributes;
45 import org.codehaus.modello.test.features.XmlContent;
46 import org.codehaus.modello.test.features.XmlContentLong;
47 import org.codehaus.modello.test.features.XmlContentLongWithAttributes;
48 import org.codehaus.modello.test.features.XmlFeatures;
49 import org.codehaus.modello.test.features.XmlFieldsOrder;
50 import org.codehaus.modello.test.features.XmlFieldsOrderParent;
51 import org.codehaus.modello.test.features.XmlFieldsOrderParent2;
52 import org.codehaus.modello.test.features.XmlTransientFields;
53 import org.codehaus.modello.test.features.XsdFeatures;
54 import org.codehaus.modello.test.features.other.PackageNameFeature;
55 import org.codehaus.modello.test.features.other.SubInterfaceInPackage;
56 import org.codehaus.plexus.util.xml.Xpp3Dom;
57 import org.dom4j.Document;
58 import org.dom4j.DocumentException;
59 import org.dom4j.DocumentFactory;
60 import org.dom4j.Element;
61 import org.dom4j.io.OutputFormat;
62 import org.dom4j.io.XMLWriter;
63
64
65
66
67
68
69 @SuppressWarnings( "all" )
70 public class ModelloFeaturesTestDom4jWriter
71 {
72
73
74
75
76
77
78
79
80
81
82
83
84 public void write( Writer writer, Features features )
85 throws java.io.IOException
86 {
87 Document document = new DocumentFactory().createDocument();
88 writeFeatures( features, "features-demo", document );
89 OutputFormat format = OutputFormat.createPrettyPrint();
90 format.setLineSeparator( System.getProperty( "line.separator" ) );
91 XMLWriter serializer = new XMLWriter( writer, format );
92 serializer.write( document );
93 }
94
95
96
97
98
99
100
101
102 public void write( OutputStream stream, Features features )
103 throws java.io.IOException
104 {
105 Document document = new DocumentFactory().createDocument();
106 writeFeatures( features, "features-demo", document );
107 OutputFormat format = OutputFormat.createPrettyPrint();
108 format.setLineSeparator( System.getProperty( "line.separator" ) );
109 format.setEncoding( features.getModelEncoding() );
110 XMLWriter serializer = new XMLWriter( stream, format );
111 serializer.write( document );
112 }
113
114
115
116
117
118
119
120
121
122 private void writeAction( Action action, String tagName, org.dom4j.Branch parentElement )
123 throws java.io.IOException
124 {
125 if ( action != null )
126 {
127 Element element = parentElement.addElement( tagName );
128 if ( action.getDev() != null )
129 {
130 element.addAttribute( "dev", action.getDev() );
131 }
132 element.setText( action.getAction() );
133 }
134 }
135
136
137
138
139
140
141
142
143
144 private void writeAnnotationTest( AnnotationTest annotationTest, String tagName, org.dom4j.Branch parentElement )
145 throws java.io.IOException
146 {
147 if ( annotationTest != null )
148 {
149 Element element = parentElement.addElement( tagName );
150 if ( annotationTest.getAnyField() != null )
151 {
152 element.addElement( "anyField" ).setText( annotationTest.getAnyField() );
153 }
154 }
155 }
156
157
158
159
160
161
162
163
164
165 private void writeArrayFeatures( ArrayFeatures arrayFeatures, String tagName, org.dom4j.Branch parentElement )
166 throws java.io.IOException
167 {
168 if ( arrayFeatures != null )
169 {
170 Element element = parentElement.addElement( tagName );
171 }
172 }
173
174
175
176
177
178
179
180
181
182 private void writeAssociationFeatures( AssociationFeatures associationFeatures, String tagName, org.dom4j.Branch parentElement )
183 throws java.io.IOException
184 {
185 if ( associationFeatures != null )
186 {
187 Element element = parentElement.addElement( tagName );
188 if ( ( associationFeatures.getListReferences() != null ) && ( associationFeatures.getListReferences().size() > 0 ) )
189 {
190 Element listElement = element;
191 listElement = element.addElement( "listReferences" );
192 for ( Iterator iter = associationFeatures.getListReferences().iterator(); iter.hasNext(); )
193 {
194 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
195 writeReference( o, "listReference", listElement );
196 }
197 }
198 if ( ( associationFeatures.getSetReferences() != null ) && ( associationFeatures.getSetReferences().size() > 0 ) )
199 {
200 Element listElement = element;
201 listElement = element.addElement( "setReferences" );
202 for ( Iterator iter = associationFeatures.getSetReferences().iterator(); iter.hasNext(); )
203 {
204 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
205 writeReference( o, "setReference", listElement );
206 }
207 }
208 if ( ( associationFeatures.getListStrings() != null ) && ( associationFeatures.getListStrings().size() > 0 ) )
209 {
210 Element listElement = element;
211 listElement = element.addElement( "listStrings" );
212 for ( Iterator iter = associationFeatures.getListStrings().iterator(); iter.hasNext(); )
213 {
214 String listString = (String) iter.next();
215 listElement.addElement( "listString" ).setText( listString );
216 }
217 }
218 if ( ( associationFeatures.getSetStrings() != null ) && ( associationFeatures.getSetStrings().size() > 0 ) )
219 {
220 Element listElement = element;
221 listElement = element.addElement( "setStrings" );
222 for ( Iterator iter = associationFeatures.getSetStrings().iterator(); iter.hasNext(); )
223 {
224 String setString = (String) iter.next();
225 listElement.addElement( "setString" ).setText( setString );
226 }
227 }
228 if ( ( associationFeatures.getProperties() != null ) && ( associationFeatures.getProperties().size() > 0 ) )
229 {
230 Element listElement = element;
231 listElement = element.addElement( "properties" );
232 for ( Iterator iter = associationFeatures.getProperties().keySet().iterator(); iter.hasNext(); )
233 {
234 String key = (String) iter.next();
235 String value = (String) associationFeatures.getProperties().get( key );
236 listElement.addElement( key ).setText( value );
237 }
238 }
239 if ( associationFeatures.getBidi() != null )
240 {
241 writeBidirectional( associationFeatures.getBidi(), "bidi", element );
242 }
243 if ( ( associationFeatures.getListOfBidis() != null ) && ( associationFeatures.getListOfBidis().size() > 0 ) )
244 {
245 Element listElement = element;
246 listElement = element.addElement( "listOfBidis" );
247 for ( Iterator iter = associationFeatures.getListOfBidis().iterator(); iter.hasNext(); )
248 {
249 BidiInList"../../../../../../../org/codehaus/modello/test/features/BidiInList.html#BidiInList">BidiInList o = (BidiInList) iter.next();
250 writeBidiInList( o, "listOfBidi", listElement );
251 }
252 }
253 if ( ( associationFeatures.getSetOfBidis() != null ) && ( associationFeatures.getSetOfBidis().size() > 0 ) )
254 {
255 Element listElement = element;
256 listElement = element.addElement( "setOfBidis" );
257 for ( Iterator iter = associationFeatures.getSetOfBidis().iterator(); iter.hasNext(); )
258 {
259 BidiInSet="../../../../../../../org/codehaus/modello/test/features/BidiInSet.html#BidiInSet">BidiInSet o = (BidiInSet) iter.next();
260 writeBidiInSet( o, "setOfBidi", listElement );
261 }
262 }
263 }
264 }
265
266
267
268
269
270
271
272
273
274 private void writeBaseClass( BaseClass baseClass, String tagName, org.dom4j.Branch parentElement )
275 throws java.io.IOException
276 {
277 if ( baseClass != null )
278 {
279 Element element = parentElement.addElement( tagName );
280 if ( baseClass.getBaseAttribute() != 0 )
281 {
282 element.addAttribute( "baseAttribute", String.valueOf( baseClass.getBaseAttribute() ) );
283 }
284 if ( baseClass.getBaseElement() != 0 )
285 {
286 element.addElement( "baseElement" ).setText( String.valueOf( baseClass.getBaseElement() ) );
287 }
288 }
289 }
290
291
292
293
294
295
296
297
298
299 private void writeBidiInList( BidiInList bidiInList, String tagName, org.dom4j.Branch parentElement )
300 throws java.io.IOException
301 {
302 if ( bidiInList != null )
303 {
304 Element element = parentElement.addElement( tagName );
305 if ( bidiInList.getParent() != null )
306 {
307 writeAssociationFeatures( bidiInList.getParent(), "parent", element );
308 }
309 }
310 }
311
312
313
314
315
316
317
318
319
320 private void writeBidiInSet( BidiInSet bidiInSet, String tagName, org.dom4j.Branch parentElement )
321 throws java.io.IOException
322 {
323 if ( bidiInSet != null )
324 {
325 Element element = parentElement.addElement( tagName );
326 if ( bidiInSet.getParent() != null )
327 {
328 writeAssociationFeatures( bidiInSet.getParent(), "parent", element );
329 }
330 }
331 }
332
333
334
335
336
337
338
339
340
341 private void writeBidirectional( Bidirectional bidirectional, String tagName, org.dom4j.Branch parentElement )
342 throws java.io.IOException
343 {
344 if ( bidirectional != null )
345 {
346 Element element = parentElement.addElement( tagName );
347 if ( bidirectional.getParent() != null )
348 {
349 writeAssociationFeatures( bidirectional.getParent(), "parent", element );
350 }
351 }
352 }
353
354
355
356
357
358
359
360
361
362 private void writeContentTest( ContentTest contentTest, String tagName, org.dom4j.Branch parentElement )
363 throws java.io.IOException
364 {
365 if ( contentTest != null )
366 {
367 Element element = parentElement.addElement( tagName );
368 if ( contentTest.getAttr() != null )
369 {
370 element.addAttribute( "attr", contentTest.getAttr() );
371 }
372 if ( contentTest.getAttr2() != 0 )
373 {
374 element.addAttribute( "attr2", String.valueOf( contentTest.getAttr2() ) );
375 }
376 element.setText( contentTest.getContent() );
377 }
378 }
379
380
381
382
383
384
385
386
387
388 private void writeDueTo( DueTo dueTo, String tagName, org.dom4j.Branch parentElement )
389 throws java.io.IOException
390 {
391 if ( dueTo != null )
392 {
393 Element element = parentElement.addElement( tagName );
394 if ( dueTo.getName() != null )
395 {
396 element.addAttribute( "name", dueTo.getName() );
397 }
398 if ( dueTo.getEmail() != null )
399 {
400 element.addAttribute( "email", dueTo.getEmail() );
401 }
402 }
403 }
404
405
406
407
408
409
410
411
412
413 private void writeFeatures( Features features, String tagName, org.dom4j.Branch parentElement )
414 throws java.io.IOException
415 {
416 if ( features != null )
417 {
418 Element element = parentElement.addElement( tagName, "http://codehaus-plexus.github.io/FEATURES/1.0.0" );
419 element.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
420 element.addAttribute( "xsi:schemaLocation", "http://codehaus-plexus.github.io/FEATURES/1.0.0 http://codehaus-plexus.github.io/features-1.0.0.xsd" );
421 if ( features.getVersionField() != null )
422 {
423 element.addElement( "versionField" ).setText( features.getVersionField() );
424 }
425 if ( features.getComment() != null )
426 {
427 element.addElement( "comment" ).setText( features.getComment() );
428 }
429 if ( features.getDescription() != null )
430 {
431 element.addElement( "description" ).setText( features.getDescription() );
432 }
433 if ( features.getRequired() != null )
434 {
435 element.addElement( "required" ).setText( features.getRequired() );
436 }
437 if ( features.getIdentifier() != null )
438 {
439 element.addElement( "identifier" ).setText( features.getIdentifier() );
440 }
441 if ( features.getIdentifierPart2() != null )
442 {
443 writeReference( features.getIdentifierPart2(), "identifierPart2", element );
444 }
445 if ( features.getSimpleTypes() != null )
446 {
447 writeSimpleTypes( features.getSimpleTypes(), "simpleTypes", element );
448 }
449 if ( features.getDefaultValues() != null )
450 {
451 writeSimpleTypes( features.getDefaultValues(), "defaultValues", element );
452 }
453 if ( features.getArrays() != null )
454 {
455 writeArrayFeatures( features.getArrays(), "arrays", element );
456 }
457 if ( features.getAssociationFeatures() != null )
458 {
459 writeAssociationFeatures( features.getAssociationFeatures(), "associationFeatures", element );
460 }
461 if ( features.getJavaFeatures() != null )
462 {
463 writeJavaFeatures( features.getJavaFeatures(), "javaFeatures", element );
464 }
465 if ( features.getXmlFeatures() != null )
466 {
467 writeXmlFeatures( features.getXmlFeatures(), "xmlFeatures", element );
468 }
469 if ( features.getXdocFeatures() != null )
470 {
471 writeXdocFeatures( features.getXdocFeatures(), "xdocFeatures", element );
472 }
473 if ( features.getNode() != null )
474 {
475 writeNodeItem( features.getNode(), "node", element );
476 }
477 if ( features.getCloneable() != null )
478 {
479 writeThing( features.getCloneable(), "cloneable", element );
480 }
481 if ( features.getFile() != null )
482 {
483 writeFile( features.getFile(), "file", element );
484 }
485 if ( features.getAction() != null )
486 {
487 writeAction( features.getAction(), "action", element );
488 }
489 }
490 }
491
492
493
494
495
496
497
498
499
500 private void writeFile( File file, String tagName, org.dom4j.Branch parentElement )
501 throws java.io.IOException
502 {
503 if ( file != null )
504 {
505 Element element = parentElement.addElement( tagName );
506 if ( file.getFile() != null )
507 {
508 element.addElement( "file" ).setText( file.getFile() );
509 }
510 }
511 }
512
513
514
515
516
517
518
519
520
521 private void writeInterfacesFeature( InterfacesFeature interfacesFeature, String tagName, org.dom4j.Branch parentElement )
522 throws java.io.IOException
523 {
524 if ( interfacesFeature != null )
525 {
526 Element element = parentElement.addElement( tagName );
527 if ( interfacesFeature.getId() != null )
528 {
529 element.addElement( "id" ).setText( interfacesFeature.getId() );
530 }
531 }
532 }
533
534
535
536
537
538
539
540
541
542 private void writeJavaFeatures( JavaFeatures javaFeatures, String tagName, org.dom4j.Branch parentElement )
543 throws java.io.IOException
544 {
545 if ( javaFeatures != null )
546 {
547 Element element = parentElement.addElement( tagName );
548 if ( javaFeatures.getInterfaces() != null )
549 {
550 writeInterfacesFeature( javaFeatures.getInterfaces(), "interfaces", element );
551 }
552 if ( javaFeatures.getPackageName() != null )
553 {
554 writePackageNameFeature( javaFeatures.getPackageName(), "packageName", element );
555 }
556 if ( javaFeatures.getBase() != null )
557 {
558 writeBaseClass( javaFeatures.getBase(), "base", element );
559 }
560 if ( javaFeatures.getSubClass() != null )
561 {
562 writeSubClassLevel1( javaFeatures.getSubClass(), "subClass", element );
563 }
564 if ( javaFeatures.getSubClass2() != null )
565 {
566 writeSubClassLevel2( javaFeatures.getSubClass2(), "subClass2", element );
567 }
568 if ( javaFeatures.getSubClass3() != null )
569 {
570 writeSubClassLevel3( javaFeatures.getSubClass3(), "subClass3", element );
571 }
572 if ( javaFeatures.getAnnotation() != null )
573 {
574 writeAnnotationTest( javaFeatures.getAnnotation(), "annotation", element );
575 }
576 }
577 }
578
579
580
581
582
583
584
585
586
587 private void writeNodeItem( NodeItem nodeItem, String tagName, org.dom4j.Branch parentElement )
588 throws java.io.IOException
589 {
590 if ( nodeItem != null )
591 {
592 Element element = parentElement.addElement( tagName );
593 if ( nodeItem.getValue() != null )
594 {
595 element.addElement( "value" ).setText( nodeItem.getValue() );
596 }
597 if ( nodeItem.getChild() != null )
598 {
599 writeNodeItem( nodeItem.getChild(), "child", element );
600 }
601 }
602 }
603
604
605
606
607
608
609
610
611
612 private void writePackageNameFeature( PackageNameFeature packageNameFeature, String tagName, org.dom4j.Branch parentElement )
613 throws java.io.IOException
614 {
615 if ( packageNameFeature != null )
616 {
617 Element element = parentElement.addElement( tagName );
618 if ( packageNameFeature.getReference() != null )
619 {
620 writeReference( packageNameFeature.getReference(), "reference", element );
621 }
622 }
623 }
624
625
626
627
628
629
630
631
632
633 private void writeReference( Reference reference, String tagName, org.dom4j.Branch parentElement )
634 throws java.io.IOException
635 {
636 if ( reference != null )
637 {
638 Element element = parentElement.addElement( tagName );
639 if ( reference.getId() != null )
640 {
641 element.addElement( "id" ).setText( reference.getId() );
642 }
643 }
644 }
645
646
647
648
649
650
651
652
653
654 private void writeSimpleTypes( SimpleTypes simpleTypes, String tagName, org.dom4j.Branch parentElement )
655 throws java.io.IOException
656 {
657 if ( simpleTypes != null )
658 {
659 Element element = parentElement.addElement( tagName );
660 if ( simpleTypes.isPrimitiveBoolean() != true )
661 {
662 element.addElement( "primitiveBoolean" ).setText( String.valueOf( simpleTypes.isPrimitiveBoolean() ) );
663 }
664 if ( simpleTypes.getPrimitiveChar() != 'H' )
665 {
666 element.addElement( "primitiveChar" ).setText( String.valueOf( simpleTypes.getPrimitiveChar() ) );
667 }
668 if ( simpleTypes.getPrimitiveByte() != 12 )
669 {
670 element.addElement( "primitiveByte" ).setText( String.valueOf( simpleTypes.getPrimitiveByte() ) );
671 }
672 if ( simpleTypes.getPrimitiveShort() != 1212 )
673 {
674 element.addElement( "primitiveShort" ).setText( String.valueOf( simpleTypes.getPrimitiveShort() ) );
675 }
676 if ( simpleTypes.getPrimitiveInt() != 121212 )
677 {
678 element.addElement( "primitiveInt" ).setText( String.valueOf( simpleTypes.getPrimitiveInt() ) );
679 }
680 if ( simpleTypes.getPrimitiveLong() != 1234567890123L )
681 {
682 element.addElement( "primitiveLong" ).setText( String.valueOf( simpleTypes.getPrimitiveLong() ) );
683 }
684 if ( simpleTypes.getPrimitiveFloat() != 12.12f )
685 {
686 element.addElement( "primitiveFloat" ).setText( String.valueOf( simpleTypes.getPrimitiveFloat() ) );
687 }
688 if ( simpleTypes.getPrimitiveDouble() != 12.12 )
689 {
690 element.addElement( "primitiveDouble" ).setText( String.valueOf( simpleTypes.getPrimitiveDouble() ) );
691 }
692 if ( ( simpleTypes.getObjectString() != null ) && !simpleTypes.getObjectString().equals( "default value" ) )
693 {
694 element.addElement( "objectString" ).setText( simpleTypes.getObjectString() );
695 }
696 if ( ( simpleTypes.getObjectDate() != null ) && !simpleTypes.getObjectDate().equals( new java.util.Date( 1356383532012L ) ) )
697 {
698 element.addElement( "objectDate" ).setText( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( simpleTypes.getObjectDate() ) );
699 }
700 if ( simpleTypes.isPrimitiveBooleanNoDefault() != false )
701 {
702 element.addElement( "primitiveBooleanNoDefault" ).setText( String.valueOf( simpleTypes.isPrimitiveBooleanNoDefault() ) );
703 }
704 if ( simpleTypes.getPrimitiveCharNoDefault() != '\0' )
705 {
706 element.addElement( "primitiveCharNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveCharNoDefault() ) );
707 }
708 if ( simpleTypes.getPrimitiveByteNoDefault() != 0 )
709 {
710 element.addElement( "primitiveByteNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveByteNoDefault() ) );
711 }
712 if ( simpleTypes.getPrimitiveShortNoDefault() != 0 )
713 {
714 element.addElement( "primitiveShortNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveShortNoDefault() ) );
715 }
716 if ( simpleTypes.getPrimitiveIntNoDefault() != 0 )
717 {
718 element.addElement( "primitiveIntNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveIntNoDefault() ) );
719 }
720 if ( simpleTypes.getPrimitiveLongNoDefault() != 0L )
721 {
722 element.addElement( "primitiveLongNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveLongNoDefault() ) );
723 }
724 if ( simpleTypes.getPrimitiveFloatNoDefault() != 0.0f )
725 {
726 element.addElement( "primitiveFloatNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveFloatNoDefault() ) );
727 }
728 if ( simpleTypes.getPrimitiveDoubleNoDefault() != 0.0 )
729 {
730 element.addElement( "primitiveDoubleNoDefault" ).setText( String.valueOf( simpleTypes.getPrimitiveDoubleNoDefault() ) );
731 }
732 if ( simpleTypes.getObjectStringNoDefault() != null )
733 {
734 element.addElement( "objectStringNoDefault" ).setText( simpleTypes.getObjectStringNoDefault() );
735 }
736 if ( simpleTypes.getObjectDateNoDefault() != null )
737 {
738 element.addElement( "objectDateNoDefault" ).setText( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( simpleTypes.getObjectDateNoDefault() ) );
739 }
740 if ( simpleTypes.getDom() != null )
741 {
742 writeXpp3DomToElement( (Xpp3Dom) simpleTypes.getDom(), element );
743 }
744 if ( simpleTypes.getContent() != null )
745 {
746 writeContentTest( simpleTypes.getContent(), "content", element );
747 }
748 }
749 }
750
751
752
753
754
755
756
757
758
759 private void writeSubClassLevel1( SubClassLevel1 subClassLevel1, String tagName, org.dom4j.Branch parentElement )
760 throws java.io.IOException
761 {
762 if ( subClassLevel1 != null )
763 {
764 Element element = parentElement.addElement( tagName );
765 if ( subClassLevel1.getSubAttribute1() != 0L )
766 {
767 element.addAttribute( "subAttribute1", String.valueOf( subClassLevel1.getSubAttribute1() ) );
768 }
769 if ( subClassLevel1.getBaseAttribute() != 0 )
770 {
771 element.addAttribute( "baseAttribute", String.valueOf( subClassLevel1.getBaseAttribute() ) );
772 }
773 if ( subClassLevel1.getSubElement1() != 0L )
774 {
775 element.addElement( "subElement1" ).setText( String.valueOf( subClassLevel1.getSubElement1() ) );
776 }
777 if ( subClassLevel1.getBaseElement() != 0 )
778 {
779 element.addElement( "baseElement" ).setText( String.valueOf( subClassLevel1.getBaseElement() ) );
780 }
781 }
782 }
783
784
785
786
787
788
789
790
791
792 private void writeSubClassLevel2( SubClassLevel2 subClassLevel2, String tagName, org.dom4j.Branch parentElement )
793 throws java.io.IOException
794 {
795 if ( subClassLevel2 != null )
796 {
797 Element element = parentElement.addElement( tagName );
798 if ( subClassLevel2.getSubAttribute2() != 0.0f )
799 {
800 element.addAttribute( "subAttribute2", String.valueOf( subClassLevel2.getSubAttribute2() ) );
801 }
802 if ( subClassLevel2.getSubAttribute1() != 0L )
803 {
804 element.addAttribute( "subAttribute1", String.valueOf( subClassLevel2.getSubAttribute1() ) );
805 }
806 if ( subClassLevel2.getBaseAttribute() != 0 )
807 {
808 element.addAttribute( "baseAttribute", String.valueOf( subClassLevel2.getBaseAttribute() ) );
809 }
810 if ( subClassLevel2.getSubElement2() != 0.0f )
811 {
812 element.addElement( "subElement2" ).setText( String.valueOf( subClassLevel2.getSubElement2() ) );
813 }
814 if ( subClassLevel2.getSubElement1() != 0L )
815 {
816 element.addElement( "subElement1" ).setText( String.valueOf( subClassLevel2.getSubElement1() ) );
817 }
818 if ( subClassLevel2.getBaseElement() != 0 )
819 {
820 element.addElement( "baseElement" ).setText( String.valueOf( subClassLevel2.getBaseElement() ) );
821 }
822 }
823 }
824
825
826
827
828
829
830
831
832
833 private void writeSubClassLevel3( SubClassLevel3 subClassLevel3, String tagName, org.dom4j.Branch parentElement )
834 throws java.io.IOException
835 {
836 if ( subClassLevel3 != null )
837 {
838 Element element = parentElement.addElement( tagName );
839 if ( subClassLevel3.getSubAttribute3() != 0.0 )
840 {
841 element.addAttribute( "subAttribute3", String.valueOf( subClassLevel3.getSubAttribute3() ) );
842 }
843 if ( subClassLevel3.getSubAttribute2() != 0.0f )
844 {
845 element.addAttribute( "subAttribute2", String.valueOf( subClassLevel3.getSubAttribute2() ) );
846 }
847 if ( subClassLevel3.getSubAttribute1() != 0L )
848 {
849 element.addAttribute( "subAttribute1", String.valueOf( subClassLevel3.getSubAttribute1() ) );
850 }
851 if ( subClassLevel3.getBaseAttribute() != 0 )
852 {
853 element.addAttribute( "baseAttribute", String.valueOf( subClassLevel3.getBaseAttribute() ) );
854 }
855 if ( subClassLevel3.getSubElement3() != 0.0 )
856 {
857 element.addElement( "subElement3" ).setText( String.valueOf( subClassLevel3.getSubElement3() ) );
858 }
859 if ( subClassLevel3.getSubElement2() != 0.0f )
860 {
861 element.addElement( "subElement2" ).setText( String.valueOf( subClassLevel3.getSubElement2() ) );
862 }
863 if ( subClassLevel3.getSubElement1() != 0L )
864 {
865 element.addElement( "subElement1" ).setText( String.valueOf( subClassLevel3.getSubElement1() ) );
866 }
867 if ( subClassLevel3.getBaseElement() != 0 )
868 {
869 element.addElement( "baseElement" ).setText( String.valueOf( subClassLevel3.getBaseElement() ) );
870 }
871 }
872 }
873
874
875
876
877
878
879
880
881
882 private void writeSuperThing( SuperThing superThing, String tagName, org.dom4j.Branch parentElement )
883 throws java.io.IOException
884 {
885 if ( superThing != null )
886 {
887 Element element = parentElement.addElement( tagName );
888 }
889 }
890
891
892
893
894
895
896
897
898
899 private void writeThing( Thing thing, String tagName, org.dom4j.Branch parentElement )
900 throws java.io.IOException
901 {
902 if ( thing != null )
903 {
904 Element element = parentElement.addElement( tagName );
905 if ( thing.isSomeBoolean() != false )
906 {
907 element.addElement( "someBoolean" ).setText( String.valueOf( thing.isSomeBoolean() ) );
908 }
909 if ( thing.getSomeChar() != '\0' )
910 {
911 element.addElement( "someChar" ).setText( String.valueOf( thing.getSomeChar() ) );
912 }
913 if ( thing.getSomeByte() != 0 )
914 {
915 element.addElement( "someByte" ).setText( String.valueOf( thing.getSomeByte() ) );
916 }
917 if ( thing.getSomeShort() != 0 )
918 {
919 element.addElement( "someShort" ).setText( String.valueOf( thing.getSomeShort() ) );
920 }
921 if ( thing.getSomeInt() != 0 )
922 {
923 element.addElement( "someInt" ).setText( String.valueOf( thing.getSomeInt() ) );
924 }
925 if ( thing.getSomeLong() != 0L )
926 {
927 element.addElement( "someLong" ).setText( String.valueOf( thing.getSomeLong() ) );
928 }
929 if ( thing.getSomeFloat() != 0.0f )
930 {
931 element.addElement( "someFloat" ).setText( String.valueOf( thing.getSomeFloat() ) );
932 }
933 if ( thing.getSomeDouble() != 0.0 )
934 {
935 element.addElement( "someDouble" ).setText( String.valueOf( thing.getSomeDouble() ) );
936 }
937 if ( thing.getSomeString() != null )
938 {
939 element.addElement( "someString" ).setText( thing.getSomeString() );
940 }
941 if ( thing.getSomeDate() != null )
942 {
943 element.addElement( "someDate" ).setText( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( thing.getSomeDate() ) );
944 }
945 if ( thing.getSomeDom() != null )
946 {
947 writeXpp3DomToElement( (Xpp3Dom) thing.getSomeDom(), element );
948 }
949 if ( ( thing.getSomeProperties() != null ) && ( thing.getSomeProperties().size() > 0 ) )
950 {
951 Element listElement = element;
952 listElement = element.addElement( "someProperties" );
953 for ( Iterator iter = thing.getSomeProperties().keySet().iterator(); iter.hasNext(); )
954 {
955 String key = (String) iter.next();
956 String value = (String) thing.getSomeProperties().get( key );
957 listElement.addElement( key ).setText( value );
958 }
959 }
960 if ( ( thing.getSomeStringList() != null ) && ( thing.getSomeStringList().size() > 0 ) )
961 {
962 Element listElement = element;
963 listElement = element.addElement( "someStringList" );
964 for ( Iterator iter = thing.getSomeStringList().iterator(); iter.hasNext(); )
965 {
966 String someStringList = (String) iter.next();
967 listElement.addElement( "someStringList" ).setText( someStringList );
968 }
969 }
970 if ( ( thing.getSomeStringSet() != null ) && ( thing.getSomeStringSet().size() > 0 ) )
971 {
972 Element listElement = element;
973 listElement = element.addElement( "someStringSet" );
974 for ( Iterator iter = thing.getSomeStringSet().iterator(); iter.hasNext(); )
975 {
976 String someStringSet = (String) iter.next();
977 listElement.addElement( "someStringSet" ).setText( someStringSet );
978 }
979 }
980 if ( thing.getDeepThingy() != null )
981 {
982 writeThingy( thing.getDeepThingy(), "deepThingy", element );
983 }
984 if ( ( thing.getDeepThingyList() != null ) && ( thing.getDeepThingyList().size() > 0 ) )
985 {
986 Element listElement = element;
987 listElement = element.addElement( "deepThingyList" );
988 for ( Iterator iter = thing.getDeepThingyList().iterator(); iter.hasNext(); )
989 {
990 Thingyref="../../../../../../../org/codehaus/modello/test/features/Thingy.html#Thingy">Thingy o = (Thingy) iter.next();
991 writeThingy( o, "deepThingyList", listElement );
992 }
993 }
994 if ( ( thing.getDeepThingySet() != null ) && ( thing.getDeepThingySet().size() > 0 ) )
995 {
996 Element listElement = element;
997 listElement = element.addElement( "deepThingySet" );
998 for ( Iterator iter = thing.getDeepThingySet().iterator(); iter.hasNext(); )
999 {
1000 Thingyref="../../../../../../../org/codehaus/modello/test/features/Thingy.html#Thingy">Thingy o = (Thingy) iter.next();
1001 writeThingy( o, "deepThingySet", listElement );
1002 }
1003 }
1004 if ( thing.getShallowThingy() != null )
1005 {
1006 writeThingy( thing.getShallowThingy(), "shallowThingy", element );
1007 }
1008 if ( ( thing.getShallowThingyList() != null ) && ( thing.getShallowThingyList().size() > 0 ) )
1009 {
1010 Element listElement = element;
1011 listElement = element.addElement( "shallowThingyList" );
1012 for ( Iterator iter = thing.getShallowThingyList().iterator(); iter.hasNext(); )
1013 {
1014 Thingyref="../../../../../../../org/codehaus/modello/test/features/Thingy.html#Thingy">Thingy o = (Thingy) iter.next();
1015 writeThingy( o, "shallowThingyList", listElement );
1016 }
1017 }
1018 if ( ( thing.getShallowThingySet() != null ) && ( thing.getShallowThingySet().size() > 0 ) )
1019 {
1020 Element listElement = element;
1021 listElement = element.addElement( "shallowThingySet" );
1022 for ( Iterator iter = thing.getShallowThingySet().iterator(); iter.hasNext(); )
1023 {
1024 Thingyref="../../../../../../../org/codehaus/modello/test/features/Thingy.html#Thingy">Thingy o = (Thingy) iter.next();
1025 writeThingy( o, "shallowThingySet", listElement );
1026 }
1027 }
1028 }
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039 private void writeThingy( Thingy thingy, String tagName, org.dom4j.Branch parentElement )
1040 throws java.io.IOException
1041 {
1042 if ( thingy != null )
1043 {
1044 Element element = parentElement.addElement( tagName );
1045 element.setText( thingy.getSomeContent() );
1046 }
1047 }
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057 private void writeXdocFeatures( XdocFeatures xdocFeatures, String tagName, org.dom4j.Branch parentElement )
1058 throws java.io.IOException
1059 {
1060 if ( xdocFeatures != null )
1061 {
1062 Element element = parentElement.addElement( tagName );
1063 if ( xdocFeatures.getField() != null )
1064 {
1065 element.addElement( "field" ).setText( xdocFeatures.getField() );
1066 }
1067 if ( xdocFeatures.getXdocSeparatorNone() != null )
1068 {
1069 element.addElement( "xdocSeparatorNone" ).setText( xdocFeatures.getXdocSeparatorNone() );
1070 }
1071 if ( xdocFeatures.getXdocSeparatorBlank() != null )
1072 {
1073 element.addElement( "xdocSeparatorBlank" ).setText( xdocFeatures.getXdocSeparatorBlank() );
1074 }
1075 }
1076 }
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086 private void writeXmlAttributes( XmlAttributes xmlAttributes, String tagName, org.dom4j.Branch parentElement )
1087 throws java.io.IOException
1088 {
1089 if ( xmlAttributes != null )
1090 {
1091 Element element = parentElement.addElement( tagName );
1092 if ( xmlAttributes.isPrimitiveBoolean() != true )
1093 {
1094 element.addAttribute( "primitiveBoolean", String.valueOf( xmlAttributes.isPrimitiveBoolean() ) );
1095 }
1096 if ( xmlAttributes.getPrimitiveChar() != 'H' )
1097 {
1098 element.addAttribute( "primitiveChar", String.valueOf( xmlAttributes.getPrimitiveChar() ) );
1099 }
1100 if ( xmlAttributes.getPrimitiveByte() != 12 )
1101 {
1102 element.addAttribute( "primitiveByte", String.valueOf( xmlAttributes.getPrimitiveByte() ) );
1103 }
1104 if ( xmlAttributes.getPrimitiveShort() != 1212 )
1105 {
1106 element.addAttribute( "primitiveShort", String.valueOf( xmlAttributes.getPrimitiveShort() ) );
1107 }
1108 if ( xmlAttributes.getPrimitiveInt() != 121212 )
1109 {
1110 element.addAttribute( "primitiveInt", String.valueOf( xmlAttributes.getPrimitiveInt() ) );
1111 }
1112 if ( xmlAttributes.getPrimitiveLong() != 1234567890123L )
1113 {
1114 element.addAttribute( "primitiveLong", String.valueOf( xmlAttributes.getPrimitiveLong() ) );
1115 }
1116 if ( xmlAttributes.getPrimitiveFloat() != 12.12f )
1117 {
1118 element.addAttribute( "primitiveFloat", String.valueOf( xmlAttributes.getPrimitiveFloat() ) );
1119 }
1120 if ( xmlAttributes.getPrimitiveDouble() != 12.12 )
1121 {
1122 element.addAttribute( "primitiveDouble", String.valueOf( xmlAttributes.getPrimitiveDouble() ) );
1123 }
1124 if ( ( xmlAttributes.getObjectString() != null ) && !xmlAttributes.getObjectString().equals( "default value" ) )
1125 {
1126 element.addAttribute( "objectString", xmlAttributes.getObjectString() );
1127 }
1128 if ( xmlAttributes.getObjectDate() != null )
1129 {
1130 element.addAttribute( "objectDate", new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( xmlAttributes.getObjectDate() ) );
1131 }
1132 if ( ( xmlAttributes.getAttribute() != null ) && !xmlAttributes.getAttribute().equals( "default" ) )
1133 {
1134 element.addAttribute( "tag-name", xmlAttributes.getAttribute() );
1135 }
1136 }
1137 }
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147 private void writeXmlContent( XmlContent xmlContent, String tagName, org.dom4j.Branch parentElement )
1148 throws java.io.IOException
1149 {
1150 if ( xmlContent != null )
1151 {
1152 Element element = parentElement.addElement( tagName );
1153 if ( xmlContent.getLongContent() != null )
1154 {
1155 writeXmlContentLong( xmlContent.getLongContent(), "content.long", element );
1156 }
1157 if ( xmlContent.getLongContentWithAttributes() != null )
1158 {
1159 writeXmlContentLongWithAttributes( xmlContent.getLongContentWithAttributes(), "content.long-with-attributes", element );
1160 }
1161 }
1162 }
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172 private void writeXmlContentLong( XmlContentLong xmlContentLong, String tagName, org.dom4j.Branch parentElement )
1173 throws java.io.IOException
1174 {
1175 if ( xmlContentLong != null )
1176 {
1177 Element element = parentElement.addElement( tagName );
1178 element.setText( String.valueOf( xmlContentLong.getContent() ) );
1179 }
1180 }
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191 private void writeXmlContentLongWithAttributes( XmlContentLongWithAttributes xmlContentLongWithAttributes, String tagName, org.dom4j.Branch parentElement )
1192 throws java.io.IOException
1193 {
1194 if ( xmlContentLongWithAttributes != null )
1195 {
1196 Element element = parentElement.addElement( tagName );
1197 if ( xmlContentLongWithAttributes.getAttr() != null )
1198 {
1199 element.addAttribute( "attr", xmlContentLongWithAttributes.getAttr() );
1200 }
1201 if ( xmlContentLongWithAttributes.getAttr2() != 0 )
1202 {
1203 element.addAttribute( "attr2", String.valueOf( xmlContentLongWithAttributes.getAttr2() ) );
1204 }
1205 element.setText( String.valueOf( xmlContentLongWithAttributes.getContent() ) );
1206 }
1207 }
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217 private void writeXmlFeatures( XmlFeatures xmlFeatures, String tagName, org.dom4j.Branch parentElement )
1218 throws java.io.IOException
1219 {
1220 if ( xmlFeatures != null )
1221 {
1222 Element element = parentElement.addElement( tagName );
1223 if ( xmlFeatures.getFieldNameAttribute() != null )
1224 {
1225 element.addAttribute( "tag-name.attribute", xmlFeatures.getFieldNameAttribute() );
1226 }
1227 if ( xmlFeatures.getAttributes() != null )
1228 {
1229 writeXmlAttributes( xmlFeatures.getAttributes(), "attributes", element );
1230 }
1231 if ( xmlFeatures.getAttributesDefault() != null )
1232 {
1233 writeXmlAttributes( xmlFeatures.getAttributesDefault(), "attributesDefault", element );
1234 }
1235 if ( xmlFeatures.getContent() != null )
1236 {
1237 writeXmlContent( xmlFeatures.getContent(), "content", element );
1238 }
1239 if ( xmlFeatures.getFieldTrim() != null )
1240 {
1241 element.addElement( "fieldTrim" ).setText( xmlFeatures.getFieldTrim() );
1242 }
1243 if ( xmlFeatures.getFieldNoTrim() != null )
1244 {
1245 element.addElement( "fieldNoTrim" ).setText( xmlFeatures.getFieldNoTrim() );
1246 }
1247 if ( xmlFeatures.getDom() != null )
1248 {
1249 writeXpp3DomToElement( (Xpp3Dom) xmlFeatures.getDom(), element );
1250 }
1251 if ( xmlFeatures.getDomNoTrim() != null )
1252 {
1253 writeXpp3DomToElement( (Xpp3Dom) xmlFeatures.getDomNoTrim(), element );
1254 }
1255 if ( xmlFeatures.getFieldName() != null )
1256 {
1257 element.addElement( "tag-name" ).setText( xmlFeatures.getFieldName() );
1258 }
1259 if ( xmlFeatures.getDateXmlFormat() != null )
1260 {
1261 element.addElement( "dateXmlFormat" ).setText( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss", java.util.Locale.US ).format( xmlFeatures.getDateXmlFormat() ) );
1262 }
1263 if ( xmlFeatures.getDateLong() != null )
1264 {
1265 element.addElement( "dateLong" ).setText( String.valueOf( xmlFeatures.getDateLong().getTime() ) );
1266 }
1267 if ( ( xmlFeatures.getXmlItemsStyleFlats() != null ) && ( xmlFeatures.getXmlItemsStyleFlats().size() > 0 ) )
1268 {
1269 Element listElement = element;
1270 for ( Iterator iter = xmlFeatures.getXmlItemsStyleFlats().iterator(); iter.hasNext(); )
1271 {
1272 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
1273 writeReference( o, "xmlItemsStyleFlat", listElement );
1274 }
1275 }
1276 if ( ( xmlFeatures.getXmlAssociationTagNames() != null ) && ( xmlFeatures.getXmlAssociationTagNames().size() > 0 ) )
1277 {
1278 Element listElement = element;
1279 listElement = element.addElement( "xmlAssociationTagNames" );
1280 for ( Iterator iter = xmlFeatures.getXmlAssociationTagNames().iterator(); iter.hasNext(); )
1281 {
1282 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
1283 writeReference( o, "association.tag-name", listElement );
1284 }
1285 }
1286 if ( ( xmlFeatures.getXmlTagNameAssociation() != null ) && ( xmlFeatures.getXmlTagNameAssociation().size() > 0 ) )
1287 {
1288 Element listElement = element;
1289 listElement = element.addElement( "field.tag-names" );
1290 for ( Iterator iter = xmlFeatures.getXmlTagNameAssociation().iterator(); iter.hasNext(); )
1291 {
1292 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
1293 writeReference( o, "field.tag-name", listElement );
1294 }
1295 }
1296 if ( ( xmlFeatures.getXmlTagNameAssociationTagNames() != null ) && ( xmlFeatures.getXmlTagNameAssociationTagNames().size() > 0 ) )
1297 {
1298 Element listElement = element;
1299 listElement = element.addElement( "field.tag-name" );
1300 for ( Iterator iter = xmlFeatures.getXmlTagNameAssociationTagNames().iterator(); iter.hasNext(); )
1301 {
1302 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
1303 writeReference( o, "association.tag-name", listElement );
1304 }
1305 }
1306 if ( ( xmlFeatures.getXmlFlatAssociationTagNames() != null ) && ( xmlFeatures.getXmlFlatAssociationTagNames().size() > 0 ) )
1307 {
1308 Element listElement = element;
1309 for ( Iterator iter = xmlFeatures.getXmlFlatAssociationTagNames().iterator(); iter.hasNext(); )
1310 {
1311 Reference="../../../../../../../org/codehaus/modello/test/features/Reference.html#Reference">Reference o = (Reference) iter.next();
1312 writeReference( o, "association.tag-name", listElement );
1313 }
1314 }
1315 if ( ( xmlFeatures.getExplodeProperties() != null ) && ( xmlFeatures.getExplodeProperties().size() > 0 ) )
1316 {
1317 Element listElement = element;
1318 listElement = element.addElement( "explodeProperties" );
1319 for ( Iterator iter = xmlFeatures.getExplodeProperties().keySet().iterator(); iter.hasNext(); )
1320 {
1321 String key = (String) iter.next();
1322 String value = (String) xmlFeatures.getExplodeProperties().get( key );
1323 Element assocElement = listElement.addElement( "explodeProperty" );
1324 assocElement.addElement( "key" ).setText( key );
1325 assocElement.addElement( "value" ).setText( value );
1326 }
1327 }
1328 if ( ( xmlFeatures.getInlineProperties() != null ) && ( xmlFeatures.getInlineProperties().size() > 0 ) )
1329 {
1330 Element listElement = element;
1331 listElement = element.addElement( "inlineProperties" );
1332 for ( Iterator iter = xmlFeatures.getInlineProperties().keySet().iterator(); iter.hasNext(); )
1333 {
1334 String key = (String) iter.next();
1335 String value = (String) xmlFeatures.getInlineProperties().get( key );
1336 listElement.addElement( key ).setText( value );
1337 }
1338 }
1339 if ( xmlFeatures.getXmlTransientFields() != null )
1340 {
1341 writeXmlTransientFields( xmlFeatures.getXmlTransientFields(), "xmlTransientFields", element );
1342 }
1343 if ( xmlFeatures.getXmlFieldsOrder() != null )
1344 {
1345 writeXmlFieldsOrder( xmlFeatures.getXmlFieldsOrder(), "xmlFieldsOrder", element );
1346 }
1347 if ( xmlFeatures.getXsdFeatures() != null )
1348 {
1349 writeXsdFeatures( xmlFeatures.getXsdFeatures(), "xsdFeatures", element );
1350 }
1351 }
1352 }
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362 private void writeXmlFieldsOrder( XmlFieldsOrder xmlFieldsOrder, String tagName, org.dom4j.Branch parentElement )
1363 throws java.io.IOException
1364 {
1365 if ( xmlFieldsOrder != null )
1366 {
1367 Element element = parentElement.addElement( tagName );
1368 if ( xmlFieldsOrder.getField1() != null )
1369 {
1370 element.addElement( "field1" ).setText( xmlFieldsOrder.getField1() );
1371 }
1372 if ( xmlFieldsOrder.getField() != null )
1373 {
1374 element.addElement( "field-2" ).setText( xmlFieldsOrder.getField() );
1375 }
1376 if ( xmlFieldsOrder.getField3() != null )
1377 {
1378 element.addElement( "field3" ).setText( xmlFieldsOrder.getField3() );
1379 }
1380 if ( xmlFieldsOrder.getField4() != null )
1381 {
1382 element.addElement( "field4" ).setText( xmlFieldsOrder.getField4() );
1383 }
1384 if ( xmlFieldsOrder.getField5() != null )
1385 {
1386 element.addElement( "field5" ).setText( xmlFieldsOrder.getField5() );
1387 }
1388 if ( xmlFieldsOrder.getField6() != null )
1389 {
1390 element.addElement( "field6" ).setText( xmlFieldsOrder.getField6() );
1391 }
1392 if ( xmlFieldsOrder.getField7() != null )
1393 {
1394 element.addElement( "field7" ).setText( xmlFieldsOrder.getField7() );
1395 }
1396 }
1397 }
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407 private void writeXmlFieldsOrderParent( XmlFieldsOrderParent xmlFieldsOrderParent, String tagName, org.dom4j.Branch parentElement )
1408 throws java.io.IOException
1409 {
1410 if ( xmlFieldsOrderParent != null )
1411 {
1412 Element element = parentElement.addElement( tagName );
1413 if ( xmlFieldsOrderParent.getField() != null )
1414 {
1415 element.addElement( "field-2" ).setText( xmlFieldsOrderParent.getField() );
1416 }
1417 if ( xmlFieldsOrderParent.getField4() != null )
1418 {
1419 element.addElement( "field4" ).setText( xmlFieldsOrderParent.getField4() );
1420 }
1421 if ( xmlFieldsOrderParent.getField5() != null )
1422 {
1423 element.addElement( "field5" ).setText( xmlFieldsOrderParent.getField5() );
1424 }
1425 if ( xmlFieldsOrderParent.getField7() != null )
1426 {
1427 element.addElement( "field7" ).setText( xmlFieldsOrderParent.getField7() );
1428 }
1429 }
1430 }
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440 private void writeXmlFieldsOrderParent2( XmlFieldsOrderParent2 xmlFieldsOrderParent2, String tagName, org.dom4j.Branch parentElement )
1441 throws java.io.IOException
1442 {
1443 if ( xmlFieldsOrderParent2 != null )
1444 {
1445 Element element = parentElement.addElement( tagName );
1446 if ( xmlFieldsOrderParent2.getField() != null )
1447 {
1448 element.addElement( "field-2" ).setText( xmlFieldsOrderParent2.getField() );
1449 }
1450 }
1451 }
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461 private void writeXmlTransientFields( XmlTransientFields xmlTransientFields, String tagName, org.dom4j.Branch parentElement )
1462 throws java.io.IOException
1463 {
1464 if ( xmlTransientFields != null )
1465 {
1466 Element element = parentElement.addElement( tagName );
1467 if ( xmlTransientFields.getPersistentField() != null )
1468 {
1469 element.addElement( "persistentField" ).setText( xmlTransientFields.getPersistentField() );
1470 }
1471 }
1472 }
1473
1474
1475
1476
1477
1478
1479
1480 private void writeXpp3DomToElement( Xpp3Dom xpp3Dom, Element parentElement )
1481 {
1482 Element element = parentElement.addElement( xpp3Dom.getName() );
1483 if ( xpp3Dom.getValue() != null )
1484 {
1485 element.setText( xpp3Dom.getValue() );
1486 }
1487 for ( Iterator i = Arrays.asList( xpp3Dom.getAttributeNames() ).iterator(); i.hasNext(); )
1488 {
1489 String name = (String) i.next();
1490 element.addAttribute( name, xpp3Dom.getAttribute( name ) );
1491 }
1492 for ( Iterator i = Arrays.asList( xpp3Dom.getChildren() ).iterator(); i.hasNext(); )
1493 {
1494 Xpp3Dom child = (Xpp3Dom) i.next();
1495 writeXpp3DomToElement( child, element );
1496 }
1497 }
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507 private void writeXsdFeatures( XsdFeatures xsdFeatures, String tagName, org.dom4j.Branch parentElement )
1508 throws java.io.IOException
1509 {
1510 if ( xsdFeatures != null )
1511 {
1512 Element element = parentElement.addElement( tagName );
1513 if ( xsdFeatures.getAttribute() != null )
1514 {
1515 element.addAttribute( "attribute", xsdFeatures.getAttribute() );
1516 }
1517 }
1518 }
1519
1520 }