001// =================== DO NOT EDIT THIS FILE ==================== 002// Generated by Modello 2.3.0, 003// any modifications will be overwritten. 004// ============================================================== 005 006package org.codehaus.modello.test.features.io.dom4j; 007 008 //---------------------------------/ 009 //- Imported classes and packages -/ 010//---------------------------------/ 011 012import java.io.OutputStream; 013import java.io.Writer; 014import java.text.DateFormat; 015import java.util.Arrays; 016import java.util.Iterator; 017import java.util.Locale; 018import org.codehaus.modello.test.features.Action; 019import org.codehaus.modello.test.features.AnnotationTest; 020import org.codehaus.modello.test.features.ArrayFeatures; 021import org.codehaus.modello.test.features.AssociationFeatures; 022import org.codehaus.modello.test.features.BaseClass; 023import org.codehaus.modello.test.features.BidiInList; 024import org.codehaus.modello.test.features.BidiInSet; 025import org.codehaus.modello.test.features.Bidirectional; 026import org.codehaus.modello.test.features.ContentTest; 027import org.codehaus.modello.test.features.DueTo; 028import org.codehaus.modello.test.features.Features; 029import org.codehaus.modello.test.features.File; 030import org.codehaus.modello.test.features.InterfacesFeature; 031import org.codehaus.modello.test.features.JavaFeatures; 032import org.codehaus.modello.test.features.NodeItem; 033import org.codehaus.modello.test.features.Reference; 034import org.codehaus.modello.test.features.SimpleInterface; 035import org.codehaus.modello.test.features.SimpleTypes; 036import org.codehaus.modello.test.features.SubClassLevel1; 037import org.codehaus.modello.test.features.SubClassLevel2; 038import org.codehaus.modello.test.features.SubClassLevel3; 039import org.codehaus.modello.test.features.SubInterface; 040import org.codehaus.modello.test.features.SuperThing; 041import org.codehaus.modello.test.features.Thing; 042import org.codehaus.modello.test.features.Thingy; 043import org.codehaus.modello.test.features.XdocFeatures; 044import org.codehaus.modello.test.features.XmlAttributes; 045import org.codehaus.modello.test.features.XmlContent; 046import org.codehaus.modello.test.features.XmlContentLong; 047import org.codehaus.modello.test.features.XmlContentLongWithAttributes; 048import org.codehaus.modello.test.features.XmlFeatures; 049import org.codehaus.modello.test.features.XmlFieldsOrder; 050import org.codehaus.modello.test.features.XmlFieldsOrderParent; 051import org.codehaus.modello.test.features.XmlFieldsOrderParent2; 052import org.codehaus.modello.test.features.XmlTransientFields; 053import org.codehaus.modello.test.features.XsdFeatures; 054import org.codehaus.modello.test.features.other.PackageNameFeature; 055import org.codehaus.modello.test.features.other.SubInterfaceInPackage; 056import org.codehaus.plexus.util.xml.Xpp3Dom; 057import org.dom4j.Document; 058import org.dom4j.DocumentException; 059import org.dom4j.DocumentFactory; 060import org.dom4j.Element; 061import org.dom4j.io.OutputFormat; 062import org.dom4j.io.XMLWriter; 063 064/** 065 * Class ModelloFeaturesTestDom4jWriter. 066 * 067 * @version $Revision$ $Date$ 068 */ 069@SuppressWarnings( "all" ) 070public class ModelloFeaturesTestDom4jWriter 071{ 072 073 //-----------/ 074 //- Methods -/ 075 //-----------/ 076 077 /** 078 * Method write. 079 * 080 * @param writer a writer object. 081 * @param features a features object. 082 * @throws java.io.IOException java.io.IOException if any. 083 */ 084 public void write( Writer writer, Features features ) 085 throws java.io.IOException 086 { 087 Document document = new DocumentFactory().createDocument(); 088 writeFeatures( features, "features-demo", document ); 089 OutputFormat format = OutputFormat.createPrettyPrint(); 090 format.setLineSeparator( System.getProperty( "line.separator" ) ); 091 XMLWriter serializer = new XMLWriter( writer, format ); 092 serializer.write( document ); 093 } //-- void write( Writer, Features ) 094 095 /** 096 * Method write. 097 * 098 * @param stream a stream object. 099 * @param features a features object. 100 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void write( OutputStream, Features ) 113 114 /** 115 * Method writeAction. 116 * 117 * @param action a action object. 118 * @param parentElement a parentElement object. 119 * @param tagName a tagName object. 120 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeAction( Action, String, org.dom4j.Branch ) 135 136 /** 137 * Method writeAnnotationTest. 138 * 139 * @param annotationTest a annotationTest object. 140 * @param parentElement a parentElement object. 141 * @param tagName a tagName object. 142 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeAnnotationTest( AnnotationTest, String, org.dom4j.Branch ) 156 157 /** 158 * Method writeArrayFeatures. 159 * 160 * @param arrayFeatures a arrayFeatures object. 161 * @param parentElement a parentElement object. 162 * @param tagName a tagName object. 163 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeArrayFeatures( ArrayFeatures, String, org.dom4j.Branch ) 173 174 /** 175 * Method writeAssociationFeatures. 176 * 177 * @param associationFeatures a associationFeatures object. 178 * @param parentElement a parentElement object. 179 * @param tagName a tagName object. 180 * @throws java.io.IOException java.io.IOException if any. 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 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 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 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 o = (BidiInSet) iter.next(); 260 writeBidiInSet( o, "setOfBidi", listElement ); 261 } 262 } 263 } 264 } //-- void writeAssociationFeatures( AssociationFeatures, String, org.dom4j.Branch ) 265 266 /** 267 * Method writeBaseClass. 268 * 269 * @param baseClass a baseClass object. 270 * @param parentElement a parentElement object. 271 * @param tagName a tagName object. 272 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeBaseClass( BaseClass, String, org.dom4j.Branch ) 290 291 /** 292 * Method writeBidiInList. 293 * 294 * @param bidiInList a bidiInList object. 295 * @param parentElement a parentElement object. 296 * @param tagName a tagName object. 297 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeBidiInList( BidiInList, String, org.dom4j.Branch ) 311 312 /** 313 * Method writeBidiInSet. 314 * 315 * @param bidiInSet a bidiInSet object. 316 * @param parentElement a parentElement object. 317 * @param tagName a tagName object. 318 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeBidiInSet( BidiInSet, String, org.dom4j.Branch ) 332 333 /** 334 * Method writeBidirectional. 335 * 336 * @param bidirectional a bidirectional object. 337 * @param parentElement a parentElement object. 338 * @param tagName a tagName object. 339 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeBidirectional( Bidirectional, String, org.dom4j.Branch ) 353 354 /** 355 * Method writeContentTest. 356 * 357 * @param contentTest a contentTest object. 358 * @param parentElement a parentElement object. 359 * @param tagName a tagName object. 360 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeContentTest( ContentTest, String, org.dom4j.Branch ) 379 380 /** 381 * Method writeDueTo. 382 * 383 * @param dueTo a dueTo object. 384 * @param parentElement a parentElement object. 385 * @param tagName a tagName object. 386 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeDueTo( DueTo, String, org.dom4j.Branch ) 404 405 /** 406 * Method writeFeatures. 407 * 408 * @param features a features object. 409 * @param parentElement a parentElement object. 410 * @param tagName a tagName object. 411 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeFeatures( Features, String, org.dom4j.Branch ) 491 492 /** 493 * Method writeFile. 494 * 495 * @param file a file object. 496 * @param parentElement a parentElement object. 497 * @param tagName a tagName object. 498 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeFile( File, String, org.dom4j.Branch ) 512 513 /** 514 * Method writeInterfacesFeature. 515 * 516 * @param interfacesFeature a interfacesFeature object. 517 * @param parentElement a parentElement object. 518 * @param tagName a tagName object. 519 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeInterfacesFeature( InterfacesFeature, String, org.dom4j.Branch ) 533 534 /** 535 * Method writeJavaFeatures. 536 * 537 * @param javaFeatures a javaFeatures object. 538 * @param parentElement a parentElement object. 539 * @param tagName a tagName object. 540 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeJavaFeatures( JavaFeatures, String, org.dom4j.Branch ) 578 579 /** 580 * Method writeNodeItem. 581 * 582 * @param nodeItem a nodeItem object. 583 * @param parentElement a parentElement object. 584 * @param tagName a tagName object. 585 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeNodeItem( NodeItem, String, org.dom4j.Branch ) 603 604 /** 605 * Method writePackageNameFeature. 606 * 607 * @param packageNameFeature a packageNameFeature object. 608 * @param parentElement a parentElement object. 609 * @param tagName a tagName object. 610 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writePackageNameFeature( PackageNameFeature, String, org.dom4j.Branch ) 624 625 /** 626 * Method writeReference. 627 * 628 * @param reference a reference object. 629 * @param parentElement a parentElement object. 630 * @param tagName a tagName object. 631 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeReference( Reference, String, org.dom4j.Branch ) 645 646 /** 647 * Method writeSimpleTypes. 648 * 649 * @param simpleTypes a simpleTypes object. 650 * @param parentElement a parentElement object. 651 * @param tagName a tagName object. 652 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeSimpleTypes( SimpleTypes, String, org.dom4j.Branch ) 750 751 /** 752 * Method writeSubClassLevel1. 753 * 754 * @param subClassLevel1 a subClassLevel1 object. 755 * @param parentElement a parentElement object. 756 * @param tagName a tagName object. 757 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeSubClassLevel1( SubClassLevel1, String, org.dom4j.Branch ) 783 784 /** 785 * Method writeSubClassLevel2. 786 * 787 * @param subClassLevel2 a subClassLevel2 object. 788 * @param parentElement a parentElement object. 789 * @param tagName a tagName object. 790 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeSubClassLevel2( SubClassLevel2, String, org.dom4j.Branch ) 824 825 /** 826 * Method writeSubClassLevel3. 827 * 828 * @param subClassLevel3 a subClassLevel3 object. 829 * @param parentElement a parentElement object. 830 * @param tagName a tagName object. 831 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeSubClassLevel3( SubClassLevel3, String, org.dom4j.Branch ) 873 874 /** 875 * Method writeSuperThing. 876 * 877 * @param superThing a superThing object. 878 * @param parentElement a parentElement object. 879 * @param tagName a tagName object. 880 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeSuperThing( SuperThing, String, org.dom4j.Branch ) 890 891 /** 892 * Method writeThing. 893 * 894 * @param thing a thing object. 895 * @param parentElement a parentElement object. 896 * @param tagName a tagName object. 897 * @throws java.io.IOException java.io.IOException if any. 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 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 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 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 Thingy o = (Thingy) iter.next(); 1025 writeThingy( o, "shallowThingySet", listElement ); 1026 } 1027 } 1028 } 1029 } //-- void writeThing( Thing, String, org.dom4j.Branch ) 1030 1031 /** 1032 * Method writeThingy. 1033 * 1034 * @param thingy a thingy object. 1035 * @param parentElement a parentElement object. 1036 * @param tagName a tagName object. 1037 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeThingy( Thingy, String, org.dom4j.Branch ) 1048 1049 /** 1050 * Method writeXdocFeatures. 1051 * 1052 * @param xdocFeatures a xdocFeatures object. 1053 * @param parentElement a parentElement object. 1054 * @param tagName a tagName object. 1055 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXdocFeatures( XdocFeatures, String, org.dom4j.Branch ) 1077 1078 /** 1079 * Method writeXmlAttributes. 1080 * 1081 * @param xmlAttributes a xmlAttributes object. 1082 * @param parentElement a parentElement object. 1083 * @param tagName a tagName object. 1084 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlAttributes( XmlAttributes, String, org.dom4j.Branch ) 1138 1139 /** 1140 * Method writeXmlContent. 1141 * 1142 * @param xmlContent a xmlContent object. 1143 * @param parentElement a parentElement object. 1144 * @param tagName a tagName object. 1145 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlContent( XmlContent, String, org.dom4j.Branch ) 1163 1164 /** 1165 * Method writeXmlContentLong. 1166 * 1167 * @param xmlContentLong a xmlContentLong object. 1168 * @param parentElement a parentElement object. 1169 * @param tagName a tagName object. 1170 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlContentLong( XmlContentLong, String, org.dom4j.Branch ) 1181 1182 /** 1183 * Method writeXmlContentLongWithAttributes. 1184 * 1185 * @param xmlContentLongWithAttributes a 1186 * xmlContentLongWithAttributes object. 1187 * @param parentElement a parentElement object. 1188 * @param tagName a tagName object. 1189 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlContentLongWithAttributes( XmlContentLongWithAttributes, String, org.dom4j.Branch ) 1208 1209 /** 1210 * Method writeXmlFeatures. 1211 * 1212 * @param xmlFeatures a xmlFeatures object. 1213 * @param parentElement a parentElement object. 1214 * @param tagName a tagName object. 1215 * @throws java.io.IOException java.io.IOException if any. 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 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 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 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 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 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 } //-- void writeXmlFeatures( XmlFeatures, String, org.dom4j.Branch ) 1353 1354 /** 1355 * Method writeXmlFieldsOrder. 1356 * 1357 * @param xmlFieldsOrder a xmlFieldsOrder object. 1358 * @param parentElement a parentElement object. 1359 * @param tagName a tagName object. 1360 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlFieldsOrder( XmlFieldsOrder, String, org.dom4j.Branch ) 1398 1399 /** 1400 * Method writeXmlFieldsOrderParent. 1401 * 1402 * @param xmlFieldsOrderParent a xmlFieldsOrderParent object. 1403 * @param parentElement a parentElement object. 1404 * @param tagName a tagName object. 1405 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlFieldsOrderParent( XmlFieldsOrderParent, String, org.dom4j.Branch ) 1431 1432 /** 1433 * Method writeXmlFieldsOrderParent2. 1434 * 1435 * @param xmlFieldsOrderParent2 a xmlFieldsOrderParent2 object. 1436 * @param parentElement a parentElement object. 1437 * @param tagName a tagName object. 1438 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlFieldsOrderParent2( XmlFieldsOrderParent2, String, org.dom4j.Branch ) 1452 1453 /** 1454 * Method writeXmlTransientFields. 1455 * 1456 * @param xmlTransientFields a xmlTransientFields object. 1457 * @param parentElement a parentElement object. 1458 * @param tagName a tagName object. 1459 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXmlTransientFields( XmlTransientFields, String, org.dom4j.Branch ) 1473 1474 /** 1475 * Method writeXpp3DomToElement. 1476 * 1477 * @param xpp3Dom a xpp3Dom object. 1478 * @param parentElement a parentElement object. 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 } //-- void writeXpp3DomToElement( Xpp3Dom, Element ) 1498 1499 /** 1500 * Method writeXsdFeatures. 1501 * 1502 * @param xsdFeatures a xsdFeatures object. 1503 * @param parentElement a parentElement object. 1504 * @param tagName a tagName object. 1505 * @throws java.io.IOException java.io.IOException if any. 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 } //-- void writeXsdFeatures( XsdFeatures, String, org.dom4j.Branch ) 1519 1520}