Coverage Report - org.apache.maven.archetype.common.MavenJDOMWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
MavenJDOMWriter
37%
348/922
32%
175/540
4.082
MavenJDOMWriter$Counter
100%
8/8
N/A
4.082
 
 1  
 package org.apache.maven.archetype.common;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 /*
 23  
  * $Id$
 24  
  */
 25  
 
 26  
 // ---------------------------------/
 27  
 // - Imported classes and packages -/
 28  
 // ---------------------------------/
 29  
 
 30  
 import org.apache.maven.archetype.common.util.Format;
 31  
 import org.apache.maven.archetype.common.util.XMLOutputter;
 32  
 import org.apache.maven.model.Activation;
 33  
 import org.apache.maven.model.ActivationFile;
 34  
 import org.apache.maven.model.ActivationOS;
 35  
 import org.apache.maven.model.ActivationProperty;
 36  
 import org.apache.maven.model.Build;
 37  
 import org.apache.maven.model.BuildBase;
 38  
 import org.apache.maven.model.CiManagement;
 39  
 import org.apache.maven.model.ConfigurationContainer;
 40  
 import org.apache.maven.model.Contributor;
 41  
 import org.apache.maven.model.Dependency;
 42  
 import org.apache.maven.model.DependencyManagement;
 43  
 import org.apache.maven.model.DeploymentRepository;
 44  
 import org.apache.maven.model.Developer;
 45  
 import org.apache.maven.model.DistributionManagement;
 46  
 import org.apache.maven.model.Exclusion;
 47  
 import org.apache.maven.model.Extension;
 48  
 import org.apache.maven.model.FileSet;
 49  
 import org.apache.maven.model.IssueManagement;
 50  
 import org.apache.maven.model.License;
 51  
 import org.apache.maven.model.MailingList;
 52  
 import org.apache.maven.model.Model;
 53  
 import org.apache.maven.model.ModelBase;
 54  
 import org.apache.maven.model.Notifier;
 55  
 import org.apache.maven.model.Organization;
 56  
 import org.apache.maven.model.Parent;
 57  
 import org.apache.maven.model.PatternSet;
 58  
 import org.apache.maven.model.Plugin;
 59  
 import org.apache.maven.model.PluginConfiguration;
 60  
 import org.apache.maven.model.PluginContainer;
 61  
 import org.apache.maven.model.PluginExecution;
 62  
 import org.apache.maven.model.PluginManagement;
 63  
 import org.apache.maven.model.Prerequisites;
 64  
 import org.apache.maven.model.Profile;
 65  
 import org.apache.maven.model.Relocation;
 66  
 import org.apache.maven.model.ReportPlugin;
 67  
 import org.apache.maven.model.ReportSet;
 68  
 import org.apache.maven.model.Reporting;
 69  
 import org.apache.maven.model.Repository;
 70  
 import org.apache.maven.model.RepositoryBase;
 71  
 import org.apache.maven.model.RepositoryPolicy;
 72  
 import org.apache.maven.model.Resource;
 73  
 import org.apache.maven.model.Scm;
 74  
 import org.apache.maven.model.Site;
 75  
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 76  
 import org.jdom.Content;
 77  
 import org.jdom.DefaultJDOMFactory;
 78  
 import org.jdom.Document;
 79  
 import org.jdom.Element;
 80  
 import org.jdom.Text;
 81  
 
 82  
 import java.io.OutputStream;
 83  
 import java.io.OutputStreamWriter;
 84  
 import java.io.Writer;
 85  
 import java.util.ArrayList;
 86  
 import java.util.Collection;
 87  
 import java.util.Iterator;
 88  
 import java.util.List;
 89  
 import java.util.ListIterator;
 90  
 import java.util.Map;
 91  
 
 92  
 /**
 93  
  * Class MavenJDOMWriter.
 94  
  *
 95  
  * @version $Revision$ $Date$
 96  
  */
 97  
 public class MavenJDOMWriter
 98  
 {
 99  
     // --------------------------/
 100  
     // - Class/Member Variables -/
 101  
     // --------------------------/
 102  
 
 103  
     /**
 104  
      * Field factory.
 105  
      */
 106  
     private DefaultJDOMFactory factory;
 107  
 
 108  
     /**
 109  
      * Field lineSeparator.
 110  
      */
 111  
     private String lineSeparator;
 112  
 
 113  2
     private static final String LS = System.getProperty( "line.separator" );
 114  
 
 115  
     // ----------------/
 116  
     // - Constructors -/
 117  
     // ----------------/
 118  
 
 119  
     public MavenJDOMWriter()
 120  56
     {
 121  56
         factory = new DefaultJDOMFactory();
 122  56
         lineSeparator = "\n";
 123  56
     } // -- org.apache.maven.model.io.jdom.MavenJDOMWriter()
 124  
 
 125  
     /**
 126  
      * Method write.
 127  
      *
 128  
      * @param project
 129  
      * @param stream
 130  
      * @param document
 131  
      * @deprecated
 132  
      */
 133  
     public void write( Model project, Document document, OutputStream stream )
 134  
         throws java.io.IOException
 135  
     {
 136  0
         updateModel( project, "project", new Counter( 0 ), document.getRootElement() );
 137  
 
 138  0
         XMLOutputter outputter = new XMLOutputter();
 139  0
         outputter.setFormat( Format.getPrettyFormat().setIndent( "  " ).setLineSeparator( LS ) );
 140  0
         outputter.output( document, stream );
 141  0
     } // -- void write(Model, Document, OutputStream)
 142  
 
 143  
     /**
 144  
      * Method write.
 145  
      *
 146  
      * @param project
 147  
      * @param writer
 148  
      * @param document
 149  
      */
 150  
     public void write( Model project, Document document, OutputStreamWriter writer )
 151  
         throws java.io.IOException
 152  
     {
 153  0
         Format format = Format.getRawFormat().setEncoding( writer.getEncoding() ).setLineSeparator( LS );
 154  0
         write( project, document, writer, format );
 155  0
     } // -- void write(Model, Document, OutputStreamWriter)
 156  
 
 157  
     /**
 158  
      * Method write.
 159  
      *
 160  
      * @param project
 161  
      * @param jdomFormat
 162  
      * @param writer
 163  
      * @param document
 164  
      */
 165  
     public void write( Model project, Document document, Writer writer, Format jdomFormat )
 166  
         throws java.io.IOException
 167  
     {
 168  56
         updateModel( project, "project", new Counter( 0 ), document.getRootElement() );
 169  
 
 170  56
         XMLOutputter outputter = new XMLOutputter();
 171  56
         outputter.setFormat( jdomFormat );
 172  56
         outputter.output( document, writer );
 173  56
     } // -- void write(Model, Document, Writer, Format)
 174  
 
 175  
     // -----------/
 176  
     // - Methods -/
 177  
     // -----------/
 178  
 
 179  
     /**
 180  
      * Method findAndReplaceProperties.
 181  
      *
 182  
      * @param counter
 183  
      * @param props
 184  
      * @param name
 185  
      * @param parent
 186  
      */
 187  
     protected Element findAndReplaceProperties( Counter counter, Element parent, String name, Map props )
 188  
     {
 189  56
         boolean shouldExist = ( props != null ) && !props.isEmpty();
 190  56
         Element element = updateElement( counter, parent, name, shouldExist );
 191  56
         if ( shouldExist )
 192  
         {
 193  2
             Iterator it = props.keySet().iterator();
 194  2
             Counter innerCounter = new Counter( counter.getDepth() + 1 );
 195  4
             while ( it.hasNext() )
 196  
             {
 197  2
                 String key = (String) it.next();
 198  2
                 findAndReplaceSimpleElement( innerCounter, element, key, (String) props.get( key ), null );
 199  2
             }
 200  
 
 201  2
             List<String> lst = new ArrayList<String>( props.keySet() );
 202  2
             it = element.getChildren().iterator();
 203  2
             while ( it.hasNext() )
 204  
             {
 205  0
                 Element elem = (Element) it.next();
 206  0
                 String key = elem.getName();
 207  0
                 if ( !lst.contains( key ) )
 208  
                 {
 209  0
                     it.remove();
 210  
                 }
 211  0
             }
 212  
         }
 213  56
         return element;
 214  
     } // -- Element findAndReplaceProperties(Counter, Element, String, Map)
 215  
 
 216  
     /**
 217  
      * Method findAndReplaceSimpleElement.
 218  
      *
 219  
      * @param counter
 220  
      * @param defaultValue
 221  
      * @param text
 222  
      * @param name
 223  
      * @param parent
 224  
      */
 225  
     protected Element findAndReplaceSimpleElement( Counter counter, Element parent, String name, String text,
 226  
                                                    String defaultValue )
 227  
     {
 228  1124
         if ( ( defaultValue != null ) && ( text != null ) && defaultValue.equals( text ) )
 229  
         {
 230  108
             Element element = parent.getChild( name, parent.getNamespace() );
 231  
             // if exist and is default value or if doesn't exist.. just keep the way it is..
 232  108
             if ( ( ( element != null ) && defaultValue.equals( element.getText() ) ) || ( element == null ) )
 233  
             {
 234  108
                 return element;
 235  
             }
 236  
         }
 237  
 
 238  1016
         boolean shouldExist = ( text != null ) && ( text.trim().length() > 0 );
 239  1016
         Element element = updateElement( counter, parent, name, shouldExist );
 240  1016
         if ( shouldExist )
 241  
         {
 242  516
             element.setText( text );
 243  
         }
 244  1016
         return element;
 245  
     } // -- Element findAndReplaceSimpleElement(Counter, Element, String, String, String)
 246  
 
 247  
     /**
 248  
      * Method findAndReplaceSimpleLists.
 249  
      *
 250  
      * @param counter
 251  
      * @param childName
 252  
      * @param parentName
 253  
      * @param list
 254  
      * @param parent
 255  
      */
 256  
     protected Element findAndReplaceSimpleLists( Counter counter, Element parent, java.util.Collection list,
 257  
                                                  String parentName, String childName )
 258  
     {
 259  74
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 260  74
         Element element = updateElement( counter, parent, parentName, shouldExist );
 261  74
         if ( shouldExist )
 262  
         {
 263  0
             Iterator it = list.iterator();
 264  0
             Iterator elIt = element.getChildren( childName, element.getNamespace() ).iterator();
 265  0
             if ( !elIt.hasNext() )
 266  
             {
 267  0
                 elIt = null;
 268  
             }
 269  
 
 270  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 271  0
             while ( it.hasNext() )
 272  
             {
 273  0
                 String value = (String) it.next();
 274  
                 Element el;
 275  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 276  
                 {
 277  0
                     el = (Element) elIt.next();
 278  0
                     if ( !elIt.hasNext() )
 279  
                     {
 280  0
                         elIt = null;
 281  
                     }
 282  
                 }
 283  
                 else
 284  
                 {
 285  0
                     el = factory.element( childName, element.getNamespace() );
 286  0
                     insertAtPreferredLocation( element, el, innerCount );
 287  
                 }
 288  0
                 el.setText( value );
 289  0
                 innerCount.increaseCount();
 290  0
             }
 291  0
             if ( elIt != null )
 292  
             {
 293  0
                 while ( elIt.hasNext() )
 294  
                 {
 295  0
                     elIt.next();
 296  0
                     elIt.remove();
 297  
                 }
 298  
             }
 299  
         }
 300  74
         return element;
 301  
     } // -- Element findAndReplaceSimpleLists(Counter, Element, java.util.Collection, String,
 302  
     // String)
 303  
 
 304  
     /**
 305  
      * Method findAndReplaceXpp3DOM.
 306  
      *
 307  
      * @param counter
 308  
      * @param dom
 309  
      * @param name
 310  
      * @param parent
 311  
      */
 312  
     protected Element findAndReplaceXpp3DOM( Counter counter, Element parent, String name, Xpp3Dom dom )
 313  
     {
 314  98
         boolean shouldExist = ( dom != null ) && ( ( dom.getChildCount() > 0 ) || ( dom.getValue() != null ) );
 315  98
         Element element = updateElement( counter, parent, name, shouldExist );
 316  98
         if ( shouldExist )
 317  
         {
 318  0
             replaceXpp3DOM( element, dom, new Counter( counter.getDepth() + 1 ) );
 319  
         }
 320  98
         return element;
 321  
     } // -- Element findAndReplaceXpp3DOM(Counter, Element, String, Xpp3Dom)
 322  
 
 323  
     /**
 324  
      * Method insertAtPreferredLocation.
 325  
      *
 326  
      * @param parent
 327  
      * @param counter
 328  
      * @param child
 329  
      */
 330  
     protected void insertAtPreferredLocation( Element parent, Element child, Counter counter )
 331  
     {
 332  156
         int contentIndex = 0;
 333  156
         int elementCounter = 0;
 334  156
         Iterator it = parent.getContent().iterator();
 335  156
         Text lastText = null;
 336  156
         int offset = 0;
 337  624
         while ( it.hasNext() && ( elementCounter <= counter.getCurrentIndex() ) )
 338  
         {
 339  468
             Object next = it.next();
 340  468
             offset = offset + 1;
 341  468
             if ( next instanceof Element )
 342  
             {
 343  194
                 elementCounter = elementCounter + 1;
 344  194
                 contentIndex = contentIndex + offset;
 345  194
                 offset = 0;
 346  
             }
 347  468
             if ( ( next instanceof Text ) && it.hasNext() )
 348  
             {
 349  194
                 lastText = (Text) next;
 350  
             }
 351  468
         }
 352  156
         if ( ( lastText != null ) && ( lastText.getTextTrim().length() == 0 ) )
 353  
         {
 354  74
             lastText = (Text) lastText.clone();
 355  
         }
 356  
         else
 357  
         {
 358  82
             StringBuilder starter = new StringBuilder( lineSeparator );
 359  370
             for ( int i = 0; i < counter.getDepth(); i++ )
 360  
             {
 361  288
                 starter.append( "  " ); // TODO make settable?
 362  
             }
 363  82
             lastText = factory.text( starter.toString() );
 364  
         }
 365  156
         if ( parent.getContentSize() == 0 )
 366  
         {
 367  58
             Text finalText = (Text) lastText.clone();
 368  58
             finalText.setText( finalText.getText().substring( 0, finalText.getText().length() - "  ".length() ) );
 369  58
             parent.addContent( contentIndex, finalText );
 370  
         }
 371  156
         parent.addContent( contentIndex, child );
 372  156
         parent.addContent( contentIndex, lastText );
 373  156
     } // -- void insertAtPreferredLocation(Element, Element, Counter)
 374  
 
 375  
     /**
 376  
      * Method iterateContributor.
 377  
      *
 378  
      * @param counter
 379  
      * @param childTag
 380  
      * @param parentTag
 381  
      * @param list
 382  
      * @param parent
 383  
      */
 384  
     protected void iterateContributor( Counter counter, Element parent, java.util.Collection list,
 385  
                                        java.lang.String parentTag, java.lang.String childTag )
 386  
     {
 387  56
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 388  56
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 389  56
         if ( shouldExist )
 390  
         {
 391  0
             Iterator it = list.iterator();
 392  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 393  0
             if ( !elIt.hasNext() )
 394  
             {
 395  0
                 elIt = null;
 396  
             }
 397  
 
 398  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 399  0
             while ( it.hasNext() )
 400  
             {
 401  0
                 Contributor value = (Contributor) it.next();
 402  
                 Element el;
 403  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 404  
                 {
 405  0
                     el = (Element) elIt.next();
 406  0
                     if ( !elIt.hasNext() )
 407  
                     {
 408  0
                         elIt = null;
 409  
                     }
 410  
                 }
 411  
                 else
 412  
                 {
 413  0
                     el = factory.element( childTag, element.getNamespace() );
 414  0
                     insertAtPreferredLocation( element, el, innerCount );
 415  
                 }
 416  0
                 updateContributor( value, childTag, innerCount, el );
 417  0
                 innerCount.increaseCount();
 418  0
             }
 419  0
             if ( elIt != null )
 420  
             {
 421  0
                 while ( elIt.hasNext() )
 422  
                 {
 423  0
                     elIt.next();
 424  0
                     elIt.remove();
 425  
                 }
 426  
             }
 427  
         }
 428  56
     } // -- void iterateContributor(Counter, Element, java.util.Collection, java.lang.String,
 429  
     // java.lang.String)
 430  
 
 431  
     /**
 432  
      * Method iterateDependency.
 433  
      *
 434  
      * @param counter
 435  
      * @param childTag
 436  
      * @param parentTag
 437  
      * @param list
 438  
      * @param parent
 439  
      */
 440  
     protected void iterateDependency( Counter counter, Element parent, java.util.Collection list,
 441  
                                       java.lang.String parentTag, java.lang.String childTag )
 442  
     {
 443  74
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 444  74
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 445  74
         if ( shouldExist )
 446  
         {
 447  20
             Iterator it = list.iterator();
 448  20
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 449  20
             if ( !elIt.hasNext() )
 450  
             {
 451  4
                 elIt = null;
 452  
             }
 453  
 
 454  20
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 455  44
             while ( it.hasNext() )
 456  
             {
 457  24
                 Dependency value = (Dependency) it.next();
 458  
                 Element el;
 459  24
                 if ( ( elIt != null ) && elIt.hasNext() )
 460  
                 {
 461  20
                     el = (Element) elIt.next();
 462  20
                     if ( !elIt.hasNext() )
 463  
                     {
 464  16
                         elIt = null;
 465  
                     }
 466  
                 }
 467  
                 else
 468  
                 {
 469  4
                     el = factory.element( childTag, element.getNamespace() );
 470  4
                     insertAtPreferredLocation( element, el, innerCount );
 471  
                 }
 472  24
                 updateDependency( value, childTag, innerCount, el );
 473  24
                 innerCount.increaseCount();
 474  24
             }
 475  20
             if ( elIt != null )
 476  
             {
 477  0
                 while ( elIt.hasNext() )
 478  
                 {
 479  0
                     elIt.next();
 480  0
                     elIt.remove();
 481  
                 }
 482  
             }
 483  
         }
 484  74
     } // -- void iterateDependency(Counter, Element, java.util.Collection, java.lang.String,
 485  
     // java.lang.String)
 486  
 
 487  
     /**
 488  
      * Method iterateDeveloper.
 489  
      *
 490  
      * @param counter
 491  
      * @param childTag
 492  
      * @param parentTag
 493  
      * @param list
 494  
      * @param parent
 495  
      */
 496  
     protected void iterateDeveloper( Counter counter, Element parent, java.util.Collection list,
 497  
                                      java.lang.String parentTag, java.lang.String childTag )
 498  
     {
 499  56
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 500  56
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 501  56
         if ( shouldExist )
 502  
         {
 503  0
             Iterator it = list.iterator();
 504  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 505  0
             if ( !elIt.hasNext() )
 506  
             {
 507  0
                 elIt = null;
 508  
             }
 509  
 
 510  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 511  0
             while ( it.hasNext() )
 512  
             {
 513  0
                 Developer value = (Developer) it.next();
 514  
                 Element el;
 515  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 516  
                 {
 517  0
                     el = (Element) elIt.next();
 518  0
                     if ( !elIt.hasNext() )
 519  
                     {
 520  0
                         elIt = null;
 521  
                     }
 522  
                 }
 523  
                 else
 524  
                 {
 525  0
                     el = factory.element( childTag, element.getNamespace() );
 526  0
                     insertAtPreferredLocation( element, el, innerCount );
 527  
                 }
 528  0
                 updateDeveloper( value, childTag, innerCount, el );
 529  0
                 innerCount.increaseCount();
 530  0
             }
 531  0
             if ( elIt != null )
 532  
             {
 533  0
                 while ( elIt.hasNext() )
 534  
                 {
 535  0
                     elIt.next();
 536  0
                     elIt.remove();
 537  
                 }
 538  
             }
 539  
         }
 540  56
     } // -- void iterateDeveloper(Counter, Element, java.util.Collection, java.lang.String,
 541  
     // java.lang.String)
 542  
 
 543  
     /**
 544  
      * Method iterateExclusion.
 545  
      *
 546  
      * @param counter
 547  
      * @param childTag
 548  
      * @param parentTag
 549  
      * @param list
 550  
      * @param parent
 551  
      */
 552  
     protected void iterateExclusion( Counter counter, Element parent, java.util.Collection list,
 553  
                                      java.lang.String parentTag, java.lang.String childTag )
 554  
     {
 555  24
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 556  24
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 557  24
         if ( shouldExist )
 558  
         {
 559  0
             Iterator it = list.iterator();
 560  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 561  0
             if ( !elIt.hasNext() )
 562  
             {
 563  0
                 elIt = null;
 564  
             }
 565  
 
 566  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 567  0
             while ( it.hasNext() )
 568  
             {
 569  0
                 Exclusion value = (Exclusion) it.next();
 570  
                 Element el;
 571  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 572  
                 {
 573  0
                     el = (Element) elIt.next();
 574  0
                     if ( !elIt.hasNext() )
 575  
                     {
 576  0
                         elIt = null;
 577  
                     }
 578  
                 }
 579  
                 else
 580  
                 {
 581  0
                     el = factory.element( childTag, element.getNamespace() );
 582  0
                     insertAtPreferredLocation( element, el, innerCount );
 583  
                 }
 584  0
                 updateExclusion( value, childTag, innerCount, el );
 585  0
                 innerCount.increaseCount();
 586  0
             }
 587  0
             if ( elIt != null )
 588  
             {
 589  0
                 while ( elIt.hasNext() )
 590  
                 {
 591  0
                     elIt.next();
 592  0
                     elIt.remove();
 593  
                 }
 594  
             }
 595  
         }
 596  24
     } // -- void iterateExclusion(Counter, Element, java.util.Collection, java.lang.String,
 597  
     // java.lang.String)
 598  
 
 599  
     /**
 600  
      * Method iterateExtension.
 601  
      *
 602  
      * @param counter
 603  
      * @param childTag
 604  
      * @param parentTag
 605  
      * @param list
 606  
      * @param parent
 607  
      */
 608  
     protected void iterateExtension( Counter counter, Element parent, java.util.Collection list,
 609  
                                      java.lang.String parentTag, java.lang.String childTag )
 610  
     {
 611  18
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 612  18
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 613  18
         if ( shouldExist )
 614  
         {
 615  12
             Iterator it = list.iterator();
 616  12
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 617  12
             if ( !elIt.hasNext() )
 618  
             {
 619  12
                 elIt = null;
 620  
             }
 621  
 
 622  12
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 623  24
             while ( it.hasNext() )
 624  
             {
 625  12
                 Extension value = (Extension) it.next();
 626  
                 Element el;
 627  12
                 if ( ( elIt != null ) && elIt.hasNext() )
 628  
                 {
 629  0
                     el = (Element) elIt.next();
 630  0
                     if ( !elIt.hasNext() )
 631  
                     {
 632  0
                         elIt = null;
 633  
                     }
 634  
                 }
 635  
                 else
 636  
                 {
 637  12
                     el = factory.element( childTag, element.getNamespace() );
 638  12
                     insertAtPreferredLocation( element, el, innerCount );
 639  
                 }
 640  12
                 updateExtension( value, childTag, innerCount, el );
 641  12
                 innerCount.increaseCount();
 642  12
             }
 643  12
             if ( elIt != null )
 644  
             {
 645  0
                 while ( elIt.hasNext() )
 646  
                 {
 647  0
                     elIt.next();
 648  0
                     elIt.remove();
 649  
                 }
 650  
             }
 651  
         }
 652  18
     } // -- void iterateExtension(Counter, Element, java.util.Collection, java.lang.String,
 653  
     // java.lang.String)
 654  
 
 655  
     /**
 656  
      * Method iterateLicense.
 657  
      *
 658  
      * @param counter
 659  
      * @param childTag
 660  
      * @param parentTag
 661  
      * @param list
 662  
      * @param parent
 663  
      */
 664  
     protected void iterateLicense( Counter counter, Element parent, java.util.Collection list,
 665  
                                    java.lang.String parentTag, java.lang.String childTag )
 666  
     {
 667  56
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 668  56
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 669  56
         if ( shouldExist )
 670  
         {
 671  0
             Iterator it = list.iterator();
 672  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 673  0
             if ( !elIt.hasNext() )
 674  
             {
 675  0
                 elIt = null;
 676  
             }
 677  
 
 678  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 679  0
             while ( it.hasNext() )
 680  
             {
 681  0
                 License value = (License) it.next();
 682  
                 Element el;
 683  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 684  
                 {
 685  0
                     el = (Element) elIt.next();
 686  0
                     if ( !elIt.hasNext() )
 687  
                     {
 688  0
                         elIt = null;
 689  
                     }
 690  
                 }
 691  
                 else
 692  
                 {
 693  0
                     el = factory.element( childTag, element.getNamespace() );
 694  0
                     insertAtPreferredLocation( element, el, innerCount );
 695  
                 }
 696  0
                 updateLicense( value, childTag, innerCount, el );
 697  0
                 innerCount.increaseCount();
 698  0
             }
 699  0
             if ( elIt != null )
 700  
             {
 701  0
                 while ( elIt.hasNext() )
 702  
                 {
 703  0
                     elIt.next();
 704  0
                     elIt.remove();
 705  
                 }
 706  
             }
 707  
         }
 708  56
     } // -- void iterateLicense(Counter, Element, java.util.Collection, java.lang.String,
 709  
     // java.lang.String)
 710  
 
 711  
     /**
 712  
      * Method iterateMailingList.
 713  
      *
 714  
      * @param counter
 715  
      * @param childTag
 716  
      * @param parentTag
 717  
      * @param list
 718  
      * @param parent
 719  
      */
 720  
     protected void iterateMailingList( Counter counter, Element parent, java.util.Collection list,
 721  
                                        java.lang.String parentTag, java.lang.String childTag )
 722  
     {
 723  56
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 724  56
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 725  56
         if ( shouldExist )
 726  
         {
 727  0
             Iterator it = list.iterator();
 728  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 729  0
             if ( !elIt.hasNext() )
 730  
             {
 731  0
                 elIt = null;
 732  
             }
 733  
 
 734  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 735  0
             while ( it.hasNext() )
 736  
             {
 737  0
                 MailingList value = (MailingList) it.next();
 738  
                 Element el;
 739  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 740  
                 {
 741  0
                     el = (Element) elIt.next();
 742  0
                     if ( !elIt.hasNext() )
 743  
                     {
 744  0
                         elIt = null;
 745  
                     }
 746  
                 }
 747  
                 else
 748  
                 {
 749  0
                     el = factory.element( childTag, element.getNamespace() );
 750  0
                     insertAtPreferredLocation( element, el, innerCount );
 751  
                 }
 752  0
                 updateMailingList( value, childTag, innerCount, el );
 753  0
                 innerCount.increaseCount();
 754  0
             }
 755  0
             if ( elIt != null )
 756  
             {
 757  0
                 while ( elIt.hasNext() )
 758  
                 {
 759  0
                     elIt.next();
 760  0
                     elIt.remove();
 761  
                 }
 762  
             }
 763  
         }
 764  56
     } // -- void iterateMailingList(Counter, Element, java.util.Collection, java.lang.String,
 765  
     // java.lang.String)
 766  
 
 767  
     /**
 768  
      * Method iterateNotifier.
 769  
      *
 770  
      * @param counter
 771  
      * @param childTag
 772  
      * @param parentTag
 773  
      * @param list
 774  
      * @param parent
 775  
      */
 776  
     protected void iterateNotifier( Counter counter, Element parent, java.util.Collection list,
 777  
                                     java.lang.String parentTag, java.lang.String childTag )
 778  
     {
 779  0
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 780  0
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 781  0
         if ( shouldExist )
 782  
         {
 783  0
             Iterator it = list.iterator();
 784  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 785  0
             if ( !elIt.hasNext() )
 786  
             {
 787  0
                 elIt = null;
 788  
             }
 789  
 
 790  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 791  0
             while ( it.hasNext() )
 792  
             {
 793  0
                 Notifier value = (Notifier) it.next();
 794  
                 Element el;
 795  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 796  
                 {
 797  0
                     el = (Element) elIt.next();
 798  0
                     if ( !elIt.hasNext() )
 799  
                     {
 800  0
                         elIt = null;
 801  
                     }
 802  
                 }
 803  
                 else
 804  
                 {
 805  0
                     el = factory.element( childTag, element.getNamespace() );
 806  0
                     insertAtPreferredLocation( element, el, innerCount );
 807  
                 }
 808  0
                 updateNotifier( value, childTag, innerCount, el );
 809  0
                 innerCount.increaseCount();
 810  0
             }
 811  0
             if ( elIt != null )
 812  
             {
 813  0
                 while ( elIt.hasNext() )
 814  
                 {
 815  0
                     elIt.next();
 816  0
                     elIt.remove();
 817  
                 }
 818  
             }
 819  
         }
 820  0
     } // -- void iterateNotifier(Counter, Element, java.util.Collection, java.lang.String,
 821  
     // java.lang.String)
 822  
 
 823  
     /**
 824  
      * Method iteratePlugin.
 825  
      *
 826  
      * @param counter
 827  
      * @param childTag
 828  
      * @param parentTag
 829  
      * @param list
 830  
      * @param parent
 831  
      */
 832  
     protected void iteratePlugin( Counter counter, Element parent, java.util.Collection list,
 833  
                                   java.lang.String parentTag, java.lang.String childTag )
 834  
     {
 835  30
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 836  30
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 837  30
         if ( shouldExist )
 838  
         {
 839  18
             Iterator it = list.iterator();
 840  18
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 841  18
             if ( !elIt.hasNext() )
 842  
             {
 843  16
                 elIt = null;
 844  
             }
 845  
 
 846  18
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 847  36
             while ( it.hasNext() )
 848  
             {
 849  18
                 Plugin value = (Plugin) it.next();
 850  
                 Element el;
 851  18
                 if ( ( elIt != null ) && elIt.hasNext() )
 852  
                 {
 853  2
                     el = (Element) elIt.next();
 854  2
                     if ( !elIt.hasNext() )
 855  
                     {
 856  2
                         elIt = null;
 857  
                     }
 858  
                 }
 859  
                 else
 860  
                 {
 861  16
                     el = factory.element( childTag, element.getNamespace() );
 862  16
                     insertAtPreferredLocation( element, el, innerCount );
 863  
                 }
 864  18
                 updatePlugin( value, childTag, innerCount, el );
 865  18
                 innerCount.increaseCount();
 866  18
             }
 867  18
             if ( elIt != null )
 868  
             {
 869  0
                 while ( elIt.hasNext() )
 870  
                 {
 871  0
                     elIt.next();
 872  0
                     elIt.remove();
 873  
                 }
 874  
             }
 875  
         }
 876  30
     } // -- void iteratePlugin(Counter, Element, java.util.Collection, java.lang.String,
 877  
     // java.lang.String)
 878  
 
 879  
     /**
 880  
      * Method iteratePluginExecution.
 881  
      *
 882  
      * @param counter
 883  
      * @param childTag
 884  
      * @param parentTag
 885  
      * @param list
 886  
      * @param parent
 887  
      */
 888  
     protected void iteratePluginExecution( Counter counter, Element parent, java.util.Collection list,
 889  
                                            java.lang.String parentTag, java.lang.String childTag )
 890  
     {
 891  18
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 892  18
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 893  18
         if ( shouldExist )
 894  
         {
 895  0
             Iterator it = list.iterator();
 896  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 897  0
             if ( !elIt.hasNext() )
 898  
             {
 899  0
                 elIt = null;
 900  
             }
 901  
 
 902  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 903  0
             while ( it.hasNext() )
 904  
             {
 905  0
                 PluginExecution value = (PluginExecution) it.next();
 906  
                 Element el;
 907  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 908  
                 {
 909  0
                     el = (Element) elIt.next();
 910  0
                     if ( !elIt.hasNext() )
 911  
                     {
 912  0
                         elIt = null;
 913  
                     }
 914  
                 }
 915  
                 else
 916  
                 {
 917  0
                     el = factory.element( childTag, element.getNamespace() );
 918  0
                     insertAtPreferredLocation( element, el, innerCount );
 919  
                 }
 920  0
                 updatePluginExecution( value, childTag, innerCount, el );
 921  0
                 innerCount.increaseCount();
 922  0
             }
 923  0
             if ( elIt != null )
 924  
             {
 925  0
                 while ( elIt.hasNext() )
 926  
                 {
 927  0
                     elIt.next();
 928  0
                     elIt.remove();
 929  
                 }
 930  
             }
 931  
         }
 932  18
     } // -- void iteratePluginExecution(Counter, Element, java.util.Collection, java.lang.String,
 933  
     // java.lang.String)
 934  
 
 935  
     /**
 936  
      * Method iterateProfile.
 937  
      *
 938  
      * @param counter
 939  
      * @param childTag
 940  
      * @param parentTag
 941  
      * @param list
 942  
      * @param parent
 943  
      */
 944  
     protected void iterateProfile( Counter counter, Element parent, java.util.Collection list,
 945  
                                    java.lang.String parentTag, java.lang.String childTag )
 946  
     {
 947  56
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 948  56
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 949  56
         if ( shouldExist )
 950  
         {
 951  0
             Iterator it = list.iterator();
 952  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 953  0
             if ( !elIt.hasNext() )
 954  
             {
 955  0
                 elIt = null;
 956  
             }
 957  
 
 958  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 959  0
             while ( it.hasNext() )
 960  
             {
 961  0
                 Profile value = (Profile) it.next();
 962  
                 Element el;
 963  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 964  
                 {
 965  0
                     el = (Element) elIt.next();
 966  0
                     if ( !elIt.hasNext() )
 967  
                     {
 968  0
                         elIt = null;
 969  
                     }
 970  
                 }
 971  
                 else
 972  
                 {
 973  0
                     el = factory.element( childTag, element.getNamespace() );
 974  0
                     insertAtPreferredLocation( element, el, innerCount );
 975  
                 }
 976  0
                 updateProfile( value, childTag, innerCount, el );
 977  0
                 innerCount.increaseCount();
 978  0
             }
 979  0
             if ( elIt != null )
 980  
             {
 981  0
                 while ( elIt.hasNext() )
 982  
                 {
 983  0
                     elIt.next();
 984  0
                     elIt.remove();
 985  
                 }
 986  
             }
 987  
         }
 988  56
     } // -- void iterateProfile(Counter, Element, java.util.Collection, java.lang.String,
 989  
     // java.lang.String)
 990  
 
 991  
     /**
 992  
      * Method iterateReportPlugin.
 993  
      *
 994  
      * @param counter
 995  
      * @param childTag
 996  
      * @param parentTag
 997  
      * @param list
 998  
      * @param parent
 999  
      */
 1000  
     protected void iterateReportPlugin( Counter counter, Element parent, java.util.Collection list,
 1001  
                                         java.lang.String parentTag, java.lang.String childTag )
 1002  
     {
 1003  6
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 1004  6
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 1005  6
         if ( shouldExist )
 1006  
         {
 1007  6
             Iterator it = list.iterator();
 1008  6
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 1009  6
             if ( !elIt.hasNext() )
 1010  
             {
 1011  4
                 elIt = null;
 1012  
             }
 1013  
 
 1014  6
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1015  12
             while ( it.hasNext() )
 1016  
             {
 1017  6
                 ReportPlugin value = (ReportPlugin) it.next();
 1018  
                 Element el;
 1019  6
                 if ( ( elIt != null ) && elIt.hasNext() )
 1020  
                 {
 1021  2
                     el = (Element) elIt.next();
 1022  2
                     if ( !elIt.hasNext() )
 1023  
                     {
 1024  2
                         elIt = null;
 1025  
                     }
 1026  
                 }
 1027  
                 else
 1028  
                 {
 1029  4
                     el = factory.element( childTag, element.getNamespace() );
 1030  4
                     insertAtPreferredLocation( element, el, innerCount );
 1031  
                 }
 1032  6
                 updateReportPlugin( value, childTag, innerCount, el );
 1033  6
                 innerCount.increaseCount();
 1034  6
             }
 1035  6
             if ( elIt != null )
 1036  
             {
 1037  0
                 while ( elIt.hasNext() )
 1038  
                 {
 1039  0
                     elIt.next();
 1040  0
                     elIt.remove();
 1041  
                 }
 1042  
             }
 1043  
         }
 1044  6
     } // -- void iterateReportPlugin(Counter, Element, java.util.Collection, java.lang.String,
 1045  
     // java.lang.String)
 1046  
 
 1047  
     /**
 1048  
      * Method iterateReportSet.
 1049  
      *
 1050  
      * @param counter
 1051  
      * @param childTag
 1052  
      * @param parentTag
 1053  
      * @param list
 1054  
      * @param parent
 1055  
      */
 1056  
     protected void iterateReportSet( Counter counter, Element parent, java.util.Collection list,
 1057  
                                      java.lang.String parentTag, java.lang.String childTag )
 1058  
     {
 1059  6
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 1060  6
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 1061  6
         if ( shouldExist )
 1062  
         {
 1063  0
             Iterator it = list.iterator();
 1064  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 1065  0
             if ( !elIt.hasNext() )
 1066  
             {
 1067  0
                 elIt = null;
 1068  
             }
 1069  
 
 1070  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1071  0
             while ( it.hasNext() )
 1072  
             {
 1073  0
                 ReportSet value = (ReportSet) it.next();
 1074  
                 Element el;
 1075  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 1076  
                 {
 1077  0
                     el = (Element) elIt.next();
 1078  0
                     if ( !elIt.hasNext() )
 1079  
                     {
 1080  0
                         elIt = null;
 1081  
                     }
 1082  
                 }
 1083  
                 else
 1084  
                 {
 1085  0
                     el = factory.element( childTag, element.getNamespace() );
 1086  0
                     insertAtPreferredLocation( element, el, innerCount );
 1087  
                 }
 1088  0
                 updateReportSet( value, childTag, innerCount, el );
 1089  0
                 innerCount.increaseCount();
 1090  0
             }
 1091  0
             if ( elIt != null )
 1092  
             {
 1093  0
                 while ( elIt.hasNext() )
 1094  
                 {
 1095  0
                     elIt.next();
 1096  0
                     elIt.remove();
 1097  
                 }
 1098  
             }
 1099  
         }
 1100  6
     } // -- void iterateReportSet(Counter, Element, java.util.Collection, java.lang.String,
 1101  
     // java.lang.String)
 1102  
 
 1103  
     /**
 1104  
      * Method iterateRepository.
 1105  
      *
 1106  
      * @param counter
 1107  
      * @param childTag
 1108  
      * @param parentTag
 1109  
      * @param list
 1110  
      * @param parent
 1111  
      */
 1112  
     protected void iterateRepository( Counter counter, Element parent, java.util.Collection list,
 1113  
                                       java.lang.String parentTag, java.lang.String childTag )
 1114  
     {
 1115  112
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 1116  112
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 1117  112
         if ( shouldExist )
 1118  
         {
 1119  0
             Iterator it = list.iterator();
 1120  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 1121  0
             if ( !elIt.hasNext() )
 1122  
             {
 1123  0
                 elIt = null;
 1124  
             }
 1125  
 
 1126  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1127  0
             while ( it.hasNext() )
 1128  
             {
 1129  0
                 Repository value = (Repository) it.next();
 1130  
                 Element el;
 1131  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 1132  
                 {
 1133  0
                     el = (Element) elIt.next();
 1134  0
                     if ( !elIt.hasNext() )
 1135  
                     {
 1136  0
                         elIt = null;
 1137  
                     }
 1138  
                 }
 1139  
                 else
 1140  
                 {
 1141  0
                     el = factory.element( childTag, element.getNamespace() );
 1142  0
                     insertAtPreferredLocation( element, el, innerCount );
 1143  
                 }
 1144  0
                 updateRepository( value, childTag, innerCount, el );
 1145  0
                 innerCount.increaseCount();
 1146  0
             }
 1147  0
             if ( elIt != null )
 1148  
             {
 1149  0
                 while ( elIt.hasNext() )
 1150  
                 {
 1151  0
                     elIt.next();
 1152  0
                     elIt.remove();
 1153  
                 }
 1154  
             }
 1155  
         }
 1156  112
     } // -- void iterateRepository(Counter, Element, java.util.Collection, java.lang.String,
 1157  
     // java.lang.String)
 1158  
 
 1159  
     /**
 1160  
      * Method iterateResource.
 1161  
      *
 1162  
      * @param counter
 1163  
      * @param childTag
 1164  
      * @param parentTag
 1165  
      * @param list
 1166  
      * @param parent
 1167  
      */
 1168  
     protected void iterateResource( Counter counter, Element parent, java.util.Collection list,
 1169  
                                     java.lang.String parentTag, java.lang.String childTag )
 1170  
     {
 1171  36
         boolean shouldExist = ( list != null ) && ( list.size() > 0 );
 1172  36
         Element element = updateElement( counter, parent, parentTag, shouldExist );
 1173  36
         if ( shouldExist )
 1174  
         {
 1175  0
             Iterator it = list.iterator();
 1176  0
             Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
 1177  0
             if ( !elIt.hasNext() )
 1178  
             {
 1179  0
                 elIt = null;
 1180  
             }
 1181  
 
 1182  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1183  0
             while ( it.hasNext() )
 1184  
             {
 1185  0
                 Resource value = (Resource) it.next();
 1186  
                 Element el;
 1187  0
                 if ( ( elIt != null ) && elIt.hasNext() )
 1188  
                 {
 1189  0
                     el = (Element) elIt.next();
 1190  0
                     if ( !elIt.hasNext() )
 1191  
                     {
 1192  0
                         elIt = null;
 1193  
                     }
 1194  
                 }
 1195  
                 else
 1196  
                 {
 1197  0
                     el = factory.element( childTag, element.getNamespace() );
 1198  0
                     insertAtPreferredLocation( element, el, innerCount );
 1199  
                 }
 1200  0
                 updateResource( value, childTag, innerCount, el );
 1201  0
                 innerCount.increaseCount();
 1202  0
             }
 1203  0
             if ( elIt != null )
 1204  
             {
 1205  0
                 while ( elIt.hasNext() )
 1206  
                 {
 1207  0
                     elIt.next();
 1208  0
                     elIt.remove();
 1209  
                 }
 1210  
             }
 1211  
         }
 1212  36
     } // -- void iterateResource(Counter, Element, java.util.Collection, java.lang.String,
 1213  
     // java.lang.String)
 1214  
 
 1215  
     /**
 1216  
      * Method replaceXpp3DOM.
 1217  
      *
 1218  
      * @param parent
 1219  
      * @param counter
 1220  
      * @param parentDom
 1221  
      */
 1222  
     protected void replaceXpp3DOM( Element parent, Xpp3Dom parentDom, Counter counter )
 1223  
     {
 1224  0
         if ( parentDom.getChildCount() > 0 )
 1225  
         {
 1226  0
             Xpp3Dom[] childs = parentDom.getChildren();
 1227  0
             Collection domChilds = new ArrayList();
 1228  0
             for ( int i = 0; i < childs.length; i++ )
 1229  
             {
 1230  0
                 domChilds.add( childs[i] );
 1231  
             }
 1232  
 
 1233  0
             int domIndex = 0;
 1234  0
             ListIterator it = parent.getChildren().listIterator();
 1235  0
             while ( it.hasNext() )
 1236  
             {
 1237  0
                 Element elem = (Element) it.next();
 1238  0
                 Iterator it2 = domChilds.iterator();
 1239  0
                 Xpp3Dom corrDom = null;
 1240  0
                 while ( it2.hasNext() )
 1241  
                 {
 1242  0
                     Xpp3Dom dm = (Xpp3Dom) it2.next();
 1243  0
                     if ( dm.getName().equals( elem.getName() ) )
 1244  
                     {
 1245  0
                         corrDom = dm;
 1246  0
                         break;
 1247  
                     }
 1248  0
                 }
 1249  0
                 if ( corrDom != null )
 1250  
                 {
 1251  0
                     domChilds.remove( corrDom );
 1252  0
                     replaceXpp3DOM( elem, corrDom, new Counter( counter.getDepth() + 1 ) );
 1253  0
                     counter.increaseCount();
 1254  
                 }
 1255  
                 else
 1256  
                 {
 1257  0
                     parent.removeContent( elem );
 1258  
                 }
 1259  0
             }
 1260  
 
 1261  0
             Iterator it2 = domChilds.iterator();
 1262  0
             while ( it2.hasNext() )
 1263  
             {
 1264  0
                 Xpp3Dom dm = (Xpp3Dom) it2.next();
 1265  0
                 Element elem = factory.element( dm.getName(), parent.getNamespace() );
 1266  0
                 insertAtPreferredLocation( parent, elem, counter );
 1267  0
                 counter.increaseCount();
 1268  0
                 replaceXpp3DOM( elem, dm, new Counter( counter.getDepth() + 1 ) );
 1269  0
             }
 1270  0
         }
 1271  0
         else if ( parentDom.getValue() != null )
 1272  
         {
 1273  0
             parent.setText( parentDom.getValue() );
 1274  
         }
 1275  0
     } // -- void replaceXpp3DOM(Element, Xpp3Dom, Counter)
 1276  
 
 1277  
     /**
 1278  
      * Method updateActivation.
 1279  
      *
 1280  
      * @param value
 1281  
      * @param element
 1282  
      * @param counter
 1283  
      * @param xmlTag
 1284  
      */
 1285  
     protected void updateActivation( Activation value, String xmlTag, Counter counter, Element element )
 1286  
     {
 1287  0
         boolean shouldExist = value != null;
 1288  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1289  0
         if ( shouldExist )
 1290  
         {
 1291  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1292  0
             findAndReplaceSimpleElement( innerCount, root, "activeByDefault", ( value.isActiveByDefault() == false )
 1293  
                 ? null
 1294  
                 : String.valueOf( value.isActiveByDefault() ), "false" );
 1295  0
             findAndReplaceSimpleElement( innerCount, root, "jdk", value.getJdk(), null );
 1296  0
             updateActivationOS( value.getOs(), "os", innerCount, root );
 1297  0
             updateActivationProperty( value.getProperty(), "property", innerCount, root );
 1298  0
             updateActivationFile( value.getFile(), "file", innerCount, root );
 1299  
         }
 1300  0
     } // -- void updateActivation(Activation, String, Counter, Element)
 1301  
 
 1302  
     /**
 1303  
      * Method updateActivationFile.
 1304  
      *
 1305  
      * @param value
 1306  
      * @param element
 1307  
      * @param counter
 1308  
      * @param xmlTag
 1309  
      */
 1310  
     protected void updateActivationFile( ActivationFile value, String xmlTag, Counter counter, Element element )
 1311  
     {
 1312  0
         boolean shouldExist = value != null;
 1313  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1314  0
         if ( shouldExist )
 1315  
         {
 1316  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1317  0
             findAndReplaceSimpleElement( innerCount, root, "missing", value.getMissing(), null );
 1318  0
             findAndReplaceSimpleElement( innerCount, root, "exists", value.getExists(), null );
 1319  
         }
 1320  0
     } // -- void updateActivationFile(ActivationFile, String, Counter, Element)
 1321  
 
 1322  
     /**
 1323  
      * Method updateActivationOS.
 1324  
      *
 1325  
      * @param value
 1326  
      * @param element
 1327  
      * @param counter
 1328  
      * @param xmlTag
 1329  
      */
 1330  
     protected void updateActivationOS( ActivationOS value, String xmlTag, Counter counter, Element element )
 1331  
     {
 1332  0
         boolean shouldExist = value != null;
 1333  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1334  0
         if ( shouldExist )
 1335  
         {
 1336  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1337  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1338  0
             findAndReplaceSimpleElement( innerCount, root, "family", value.getFamily(), null );
 1339  0
             findAndReplaceSimpleElement( innerCount, root, "arch", value.getArch(), null );
 1340  0
             findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1341  
         }
 1342  0
     } // -- void updateActivationOS(ActivationOS, String, Counter, Element)
 1343  
 
 1344  
     /**
 1345  
      * Method updateActivationProperty.
 1346  
      *
 1347  
      * @param value
 1348  
      * @param element
 1349  
      * @param counter
 1350  
      * @param xmlTag
 1351  
      */
 1352  
     protected void updateActivationProperty( ActivationProperty value, String xmlTag, Counter counter, Element element )
 1353  
     {
 1354  0
         boolean shouldExist = value != null;
 1355  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1356  0
         if ( shouldExist )
 1357  
         {
 1358  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1359  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1360  0
             findAndReplaceSimpleElement( innerCount, root, "value", value.getValue(), null );
 1361  
         }
 1362  0
     } // -- void updateActivationProperty(ActivationProperty, String, Counter, Element)
 1363  
 
 1364  
     /**
 1365  
      * Method updateBuild.
 1366  
      *
 1367  
      * @param value
 1368  
      * @param element
 1369  
      * @param counter
 1370  
      * @param xmlTag
 1371  
      */
 1372  
     protected void updateBuild( Build value, String xmlTag, Counter counter, Element element )
 1373  
     {
 1374  56
         boolean shouldExist = value != null;
 1375  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1376  56
         if ( shouldExist )
 1377  
         {
 1378  18
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1379  18
             findAndReplaceSimpleElement( innerCount, root, "sourceDirectory", value.getSourceDirectory(), null );
 1380  18
             findAndReplaceSimpleElement( innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(),
 1381  
                                          null );
 1382  18
             findAndReplaceSimpleElement( innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(),
 1383  
                                          null );
 1384  18
             findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null );
 1385  18
             findAndReplaceSimpleElement( innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(),
 1386  
                                          null );
 1387  18
             iterateExtension( innerCount, root, value.getExtensions(), "extensions", "extension" );
 1388  18
             findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null );
 1389  18
             iterateResource( innerCount, root, value.getResources(), "resources", "resource" );
 1390  18
             iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" );
 1391  18
             findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
 1392  18
             findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null );
 1393  18
             findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" );
 1394  18
             updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
 1395  18
             iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 1396  
         } // end if
 1397  56
     } // -- void updateBuild(Build, String, Counter, Element)
 1398  
 
 1399  
     /**
 1400  
      * Method updateBuildBase.
 1401  
      *
 1402  
      * @param value
 1403  
      * @param element
 1404  
      * @param counter
 1405  
      * @param xmlTag
 1406  
      */
 1407  
     protected void updateBuildBase( BuildBase value, String xmlTag, Counter counter, Element element )
 1408  
     {
 1409  0
         boolean shouldExist = value != null;
 1410  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1411  0
         if ( shouldExist )
 1412  
         {
 1413  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1414  0
             findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null );
 1415  0
             iterateResource( innerCount, root, value.getResources(), "resources", "resource" );
 1416  0
             iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" );
 1417  0
             findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
 1418  0
             findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null );
 1419  0
             findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" );
 1420  0
             updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
 1421  0
             iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 1422  
         }
 1423  0
     } // -- void updateBuildBase(BuildBase, String, Counter, Element)
 1424  
 
 1425  
     /**
 1426  
      * Method updateCiManagement.
 1427  
      *
 1428  
      * @param value
 1429  
      * @param element
 1430  
      * @param counter
 1431  
      * @param xmlTag
 1432  
      */
 1433  
     protected void updateCiManagement( CiManagement value, String xmlTag, Counter counter, Element element )
 1434  
     {
 1435  56
         boolean shouldExist = value != null;
 1436  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1437  56
         if ( shouldExist )
 1438  
         {
 1439  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1440  0
             findAndReplaceSimpleElement( innerCount, root, "system", value.getSystem(), null );
 1441  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1442  0
             iterateNotifier( innerCount, root, value.getNotifiers(), "notifiers", "notifier" );
 1443  
         }
 1444  56
     } // -- void updateCiManagement(CiManagement, String, Counter, Element)
 1445  
 
 1446  
     /**
 1447  
      * Method updateConfigurationContainer.
 1448  
      *
 1449  
      * @param value
 1450  
      * @param element
 1451  
      * @param counter
 1452  
      * @param xmlTag
 1453  
      */
 1454  
     protected void updateConfigurationContainer( ConfigurationContainer value, String xmlTag, Counter counter,
 1455  
                                                  Element element )
 1456  
     {
 1457  0
         boolean shouldExist = value != null;
 1458  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1459  0
         if ( shouldExist )
 1460  
         {
 1461  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1462  0
             findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
 1463  0
             findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
 1464  
         }
 1465  0
     } // -- void updateConfigurationContainer(ConfigurationContainer, String, Counter, Element)
 1466  
 
 1467  
     /**
 1468  
      * Method updateContributor.
 1469  
      *
 1470  
      * @param value
 1471  
      * @param element
 1472  
      * @param counter
 1473  
      * @param xmlTag
 1474  
      */
 1475  
     protected void updateContributor( Contributor value, String xmlTag, Counter counter, Element element )
 1476  
     {
 1477  0
         Element root = element;
 1478  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1479  0
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1480  0
         findAndReplaceSimpleElement( innerCount, root, "email", value.getEmail(), null );
 1481  0
         findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1482  0
         findAndReplaceSimpleElement( innerCount, root, "organization", value.getOrganization(), null );
 1483  0
         findAndReplaceSimpleElement( innerCount, root, "organizationUrl", value.getOrganizationUrl(), null );
 1484  0
         findAndReplaceSimpleLists( innerCount, root, value.getRoles(), "roles", "role" );
 1485  0
         findAndReplaceSimpleElement( innerCount, root, "timezone", value.getTimezone(), null );
 1486  0
         findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
 1487  0
     } // -- void updateContributor(Contributor, String, Counter, Element)
 1488  
 
 1489  
     /**
 1490  
      * Method updateDependency.
 1491  
      *
 1492  
      * @param value
 1493  
      * @param element
 1494  
      * @param counter
 1495  
      * @param xmlTag
 1496  
      */
 1497  
     protected void updateDependency( Dependency value, String xmlTag, Counter counter, Element element )
 1498  
     {
 1499  24
         Element root = element;
 1500  24
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1501  24
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 1502  24
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1503  24
         findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1504  24
         findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "jar" );
 1505  24
         findAndReplaceSimpleElement( innerCount, root, "classifier", value.getClassifier(), null );
 1506  24
         findAndReplaceSimpleElement( innerCount, root, "scope", value.getScope(), null );
 1507  24
         findAndReplaceSimpleElement( innerCount, root, "systemPath", value.getSystemPath(), null );
 1508  24
         iterateExclusion( innerCount, root, value.getExclusions(), "exclusions", "exclusion" );
 1509  24
         findAndReplaceSimpleElement( innerCount, root, "optional",
 1510  
                                      ( value.isOptional() == false ) ? null : String.valueOf( value.isOptional() ),
 1511  
                                      "false" );
 1512  24
     } // -- void updateDependency(Dependency, String, Counter, Element)
 1513  
 
 1514  
     /**
 1515  
      * Method updateDependencyManagement.
 1516  
      *
 1517  
      * @param value
 1518  
      * @param element
 1519  
      * @param counter
 1520  
      * @param xmlTag
 1521  
      */
 1522  
     protected void updateDependencyManagement( DependencyManagement value, String xmlTag, Counter counter,
 1523  
                                                Element element )
 1524  
     {
 1525  56
         boolean shouldExist = value != null;
 1526  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1527  56
         if ( shouldExist )
 1528  
         {
 1529  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1530  0
             iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
 1531  
         }
 1532  56
     } // -- void updateDependencyManagement(DependencyManagement, String, Counter, Element)
 1533  
 
 1534  
     /**
 1535  
      * Method updateDeploymentRepository.
 1536  
      *
 1537  
      * @param value
 1538  
      * @param element
 1539  
      * @param counter
 1540  
      * @param xmlTag
 1541  
      */
 1542  
     protected void updateDeploymentRepository( DeploymentRepository value, String xmlTag, Counter counter,
 1543  
                                                Element element )
 1544  
     {
 1545  0
         boolean shouldExist = value != null;
 1546  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1547  0
         if ( shouldExist )
 1548  
         {
 1549  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1550  0
             findAndReplaceSimpleElement( innerCount, root, "uniqueVersion", ( value.isUniqueVersion() == true )
 1551  
                 ? null
 1552  
                 : String.valueOf( value.isUniqueVersion() ), "true" );
 1553  0
             findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 1554  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1555  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1556  0
             findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" );
 1557  
         }
 1558  0
     } // -- void updateDeploymentRepository(DeploymentRepository, String, Counter, Element)
 1559  
 
 1560  
     /**
 1561  
      * Method updateDeveloper.
 1562  
      *
 1563  
      * @param value
 1564  
      * @param element
 1565  
      * @param counter
 1566  
      * @param xmlTag
 1567  
      */
 1568  
     protected void updateDeveloper( Developer value, String xmlTag, Counter counter, Element element )
 1569  
     {
 1570  0
         Element root = element;
 1571  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1572  0
         findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 1573  0
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1574  0
         findAndReplaceSimpleElement( innerCount, root, "email", value.getEmail(), null );
 1575  0
         findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1576  0
         findAndReplaceSimpleElement( innerCount, root, "organization", value.getOrganization(), null );
 1577  0
         findAndReplaceSimpleElement( innerCount, root, "organizationUrl", value.getOrganizationUrl(), null );
 1578  0
         findAndReplaceSimpleLists( innerCount, root, value.getRoles(), "roles", "role" );
 1579  0
         findAndReplaceSimpleElement( innerCount, root, "timezone", value.getTimezone(), null );
 1580  0
         findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
 1581  0
     } // -- void updateDeveloper(Developer, String, Counter, Element)
 1582  
 
 1583  
     /**
 1584  
      * Method updateDistributionManagement.
 1585  
      *
 1586  
      * @param value
 1587  
      * @param element
 1588  
      * @param counter
 1589  
      * @param xmlTag
 1590  
      */
 1591  
     protected void updateDistributionManagement( DistributionManagement value, String xmlTag, Counter counter,
 1592  
                                                  Element element )
 1593  
     {
 1594  56
         boolean shouldExist = value != null;
 1595  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1596  56
         if ( shouldExist )
 1597  
         {
 1598  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1599  0
             updateDeploymentRepository( value.getRepository(), "repository", innerCount, root );
 1600  0
             updateDeploymentRepository( value.getSnapshotRepository(), "snapshotRepository", innerCount, root );
 1601  0
             updateSite( value.getSite(), "site", innerCount, root );
 1602  0
             findAndReplaceSimpleElement( innerCount, root, "downloadUrl", value.getDownloadUrl(), null );
 1603  0
             updateRelocation( value.getRelocation(), "relocation", innerCount, root );
 1604  0
             findAndReplaceSimpleElement( innerCount, root, "status", value.getStatus(), null );
 1605  
         }
 1606  56
     } // -- void updateDistributionManagement(DistributionManagement, String, Counter, Element)
 1607  
 
 1608  
     /**
 1609  
      * Method updateElement.
 1610  
      *
 1611  
      * @param counter
 1612  
      * @param shouldExist
 1613  
      * @param name
 1614  
      * @param parent
 1615  
      */
 1616  
     protected Element updateElement( Counter counter, Element parent, String name, boolean shouldExist )
 1617  
     {
 1618  2426
         Element element = parent.getChild( name, parent.getNamespace() );
 1619  2426
         if ( ( element != null ) && shouldExist )
 1620  
         {
 1621  520
             counter.increaseCount();
 1622  
         }
 1623  2426
         if ( ( element == null ) && shouldExist )
 1624  
         {
 1625  120
             element = factory.element( name, parent.getNamespace() );
 1626  120
             insertAtPreferredLocation( parent, element, counter );
 1627  120
             counter.increaseCount();
 1628  
         }
 1629  2426
         if ( !shouldExist && ( element != null ) )
 1630  
         {
 1631  14
             int index = parent.indexOf( element );
 1632  14
             if ( index > 0 )
 1633  
             {
 1634  14
                 Content previous = parent.getContent( index - 1 );
 1635  14
                 if ( previous instanceof Text )
 1636  
                 {
 1637  14
                     Text txt = (Text) previous;
 1638  14
                     if ( txt.getTextTrim().length() == 0 )
 1639  
                     {
 1640  14
                         parent.removeContent( txt );
 1641  
                     }
 1642  
                 }
 1643  
             }
 1644  14
             parent.removeContent( element );
 1645  
         }
 1646  2426
         return element;
 1647  
     } // -- Element updateElement(Counter, Element, String, boolean)
 1648  
 
 1649  
     /**
 1650  
      * Method updateExclusion.
 1651  
      *
 1652  
      * @param value
 1653  
      * @param element
 1654  
      * @param counter
 1655  
      * @param xmlTag
 1656  
      */
 1657  
     protected void updateExclusion( Exclusion value, String xmlTag, Counter counter, Element element )
 1658  
     {
 1659  0
         Element root = element;
 1660  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1661  0
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1662  0
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 1663  0
     } // -- void updateExclusion(Exclusion, String, Counter, Element)
 1664  
 
 1665  
     /**
 1666  
      * Method updateExtension.
 1667  
      *
 1668  
      * @param value
 1669  
      * @param element
 1670  
      * @param counter
 1671  
      * @param xmlTag
 1672  
      */
 1673  
     protected void updateExtension( Extension value, String xmlTag, Counter counter, Element element )
 1674  
     {
 1675  12
         Element root = element;
 1676  12
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1677  12
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 1678  12
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1679  12
         findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1680  12
     } // -- void updateExtension(Extension, String, Counter, Element)
 1681  
 
 1682  
     /**
 1683  
      * Method updateFileSet.
 1684  
      *
 1685  
      * @param value
 1686  
      * @param element
 1687  
      * @param counter
 1688  
      * @param xmlTag
 1689  
      */
 1690  
     protected void updateFileSet( FileSet value, String xmlTag, Counter counter, Element element )
 1691  
     {
 1692  0
         boolean shouldExist = value != null;
 1693  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1694  0
         if ( shouldExist )
 1695  
         {
 1696  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1697  0
             findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
 1698  0
             findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" );
 1699  0
             findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" );
 1700  
         }
 1701  0
     } // -- void updateFileSet(FileSet, String, Counter, Element)
 1702  
 
 1703  
     /**
 1704  
      * Method updateIssueManagement.
 1705  
      *
 1706  
      * @param value
 1707  
      * @param element
 1708  
      * @param counter
 1709  
      * @param xmlTag
 1710  
      */
 1711  
     protected void updateIssueManagement( IssueManagement value, String xmlTag, Counter counter, Element element )
 1712  
     {
 1713  56
         boolean shouldExist = value != null;
 1714  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1715  56
         if ( shouldExist )
 1716  
         {
 1717  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1718  0
             findAndReplaceSimpleElement( innerCount, root, "system", value.getSystem(), null );
 1719  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1720  
         }
 1721  56
     } // -- void updateIssueManagement(IssueManagement, String, Counter, Element)
 1722  
 
 1723  
     /**
 1724  
      * Method updateLicense.
 1725  
      *
 1726  
      * @param value
 1727  
      * @param element
 1728  
      * @param counter
 1729  
      * @param xmlTag
 1730  
      */
 1731  
     protected void updateLicense( License value, String xmlTag, Counter counter, Element element )
 1732  
     {
 1733  0
         Element root = element;
 1734  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1735  0
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1736  0
         findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1737  0
         findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null );
 1738  0
         findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null );
 1739  0
     } // -- void updateLicense(License, String, Counter, Element)
 1740  
 
 1741  
     /**
 1742  
      * Method updateMailingList.
 1743  
      *
 1744  
      * @param value
 1745  
      * @param element
 1746  
      * @param counter
 1747  
      * @param xmlTag
 1748  
      */
 1749  
     protected void updateMailingList( MailingList value, String xmlTag, Counter counter, Element element )
 1750  
     {
 1751  0
         Element root = element;
 1752  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1753  0
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1754  0
         findAndReplaceSimpleElement( innerCount, root, "subscribe", value.getSubscribe(), null );
 1755  0
         findAndReplaceSimpleElement( innerCount, root, "unsubscribe", value.getUnsubscribe(), null );
 1756  0
         findAndReplaceSimpleElement( innerCount, root, "post", value.getPost(), null );
 1757  0
         findAndReplaceSimpleElement( innerCount, root, "archive", value.getArchive(), null );
 1758  0
         findAndReplaceSimpleLists( innerCount, root, value.getOtherArchives(), "otherArchives", "otherArchive" );
 1759  0
     } // -- void updateMailingList(MailingList, String, Counter, Element)
 1760  
 
 1761  
     /**
 1762  
      * Method updateModel.
 1763  
      *
 1764  
      * @param value
 1765  
      * @param element
 1766  
      * @param counter
 1767  
      * @param xmlTag
 1768  
      */
 1769  
     protected void updateModel( Model value, String xmlTag, Counter counter, Element element )
 1770  
     {
 1771  56
         Element root = element;
 1772  56
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1773  56
         updateParent( value.getParent(), "parent", innerCount, root );
 1774  56
         findAndReplaceSimpleElement( innerCount, root, "modelVersion", value.getModelVersion(), null );
 1775  56
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 1776  56
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1777  56
         findAndReplaceSimpleElement( innerCount, root, "packaging", value.getPackaging(), "jar" );
 1778  56
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1779  56
         findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1780  56
         findAndReplaceSimpleElement( innerCount, root, "description", value.getDescription(), null );
 1781  56
         findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1782  56
         updatePrerequisites( value.getPrerequisites(), "prerequisites", innerCount, root );
 1783  56
         updateIssueManagement( value.getIssueManagement(), "issueManagement", innerCount, root );
 1784  56
         updateCiManagement( value.getCiManagement(), "ciManagement", innerCount, root );
 1785  56
         findAndReplaceSimpleElement( innerCount, root, "inceptionYear", value.getInceptionYear(), null );
 1786  56
         iterateMailingList( innerCount, root, value.getMailingLists(), "mailingLists", "mailingList" );
 1787  56
         iterateDeveloper( innerCount, root, value.getDevelopers(), "developers", "developer" );
 1788  56
         iterateContributor( innerCount, root, value.getContributors(), "contributors", "contributor" );
 1789  56
         iterateLicense( innerCount, root, value.getLicenses(), "licenses", "license" );
 1790  56
         updateScm( value.getScm(), "scm", innerCount, root );
 1791  56
         updateOrganization( value.getOrganization(), "organization", innerCount, root );
 1792  56
         updateBuild( value.getBuild(), "build", innerCount, root );
 1793  56
         iterateProfile( innerCount, root, value.getProfiles(), "profiles", "profile" );
 1794  56
         findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
 1795  56
         iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
 1796  56
         iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
 1797  56
         iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
 1798  56
         findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
 1799  56
         updateReporting( value.getReporting(), "reporting", innerCount, root );
 1800  56
         updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
 1801  56
         updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
 1802  56
         findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
 1803  56
     } // -- void updateModel(Model, String, Counter, Element)
 1804  
 
 1805  
     /**
 1806  
      * Method updateModelBase.
 1807  
      *
 1808  
      * @param value
 1809  
      * @param element
 1810  
      * @param counter
 1811  
      * @param xmlTag
 1812  
      */
 1813  
     protected void updateModelBase( ModelBase value, String xmlTag, Counter counter, Element element )
 1814  
     {
 1815  0
         boolean shouldExist = value != null;
 1816  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1817  0
         if ( shouldExist )
 1818  
         {
 1819  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1820  0
             findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
 1821  0
             iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
 1822  0
             iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories",
 1823  
                                "pluginRepository" );
 1824  0
             iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
 1825  0
             findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
 1826  0
             updateReporting( value.getReporting(), "reporting", innerCount, root );
 1827  0
             updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
 1828  0
             updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount,
 1829  
                                           root );
 1830  0
             findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
 1831  
         }
 1832  0
     } // -- void updateModelBase(ModelBase, String, Counter, Element)
 1833  
 
 1834  
     /**
 1835  
      * Method updateNotifier.
 1836  
      *
 1837  
      * @param value
 1838  
      * @param element
 1839  
      * @param counter
 1840  
      * @param xmlTag
 1841  
      */
 1842  
     protected void updateNotifier( Notifier value, String xmlTag, Counter counter, Element element )
 1843  
     {
 1844  0
         Element root = element;
 1845  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1846  0
         findAndReplaceSimpleElement( innerCount, root, "type", value.getType(), "mail" );
 1847  0
         findAndReplaceSimpleElement( innerCount, root, "sendOnError",
 1848  
                                      ( value.isSendOnError() == true ) ? null : String.valueOf( value.isSendOnError() ),
 1849  
                                      "true" );
 1850  0
         findAndReplaceSimpleElement( innerCount, root, "sendOnFailure", ( value.isSendOnFailure() == true )
 1851  
             ? null
 1852  
             : String.valueOf( value.isSendOnFailure() ), "true" );
 1853  0
         findAndReplaceSimpleElement( innerCount, root, "sendOnSuccess", ( value.isSendOnSuccess() == true )
 1854  
             ? null
 1855  
             : String.valueOf( value.isSendOnSuccess() ), "true" );
 1856  0
         findAndReplaceSimpleElement( innerCount, root, "sendOnWarning", ( value.isSendOnWarning() == true )
 1857  
             ? null
 1858  
             : String.valueOf( value.isSendOnWarning() ), "true" );
 1859  0
         findAndReplaceSimpleElement( innerCount, root, "address", value.getAddress(), null );
 1860  0
         findAndReplaceProperties( innerCount, root, "configuration", value.getConfiguration() );
 1861  0
     } // -- void updateNotifier(Notifier, String, Counter, Element)
 1862  
 
 1863  
     /**
 1864  
      * Method updateOrganization.
 1865  
      *
 1866  
      * @param value
 1867  
      * @param element
 1868  
      * @param counter
 1869  
      * @param xmlTag
 1870  
      */
 1871  
     protected void updateOrganization( Organization value, String xmlTag, Counter counter, Element element )
 1872  
     {
 1873  56
         boolean shouldExist = value != null;
 1874  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1875  56
         if ( shouldExist )
 1876  
         {
 1877  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1878  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 1879  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 1880  
         }
 1881  56
     } // -- void updateOrganization(Organization, String, Counter, Element)
 1882  
 
 1883  
     /**
 1884  
      * Method updateParent.
 1885  
      *
 1886  
      * @param value
 1887  
      * @param element
 1888  
      * @param counter
 1889  
      * @param xmlTag
 1890  
      */
 1891  
     protected void updateParent( Parent value, String xmlTag, Counter counter, Element element )
 1892  
     {
 1893  56
         boolean shouldExist = value != null;
 1894  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1895  56
         if ( shouldExist )
 1896  
         {
 1897  30
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1898  30
             findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1899  30
             findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 1900  30
             findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1901  30
             findAndReplaceSimpleElement( innerCount, root, "relativePath", value.getRelativePath(), "../pom.xml" );
 1902  
         }
 1903  56
     } // -- void updateParent(Parent, String, Counter, Element)
 1904  
 
 1905  
     /**
 1906  
      * Method updatePatternSet.
 1907  
      *
 1908  
      * @param value
 1909  
      * @param element
 1910  
      * @param counter
 1911  
      * @param xmlTag
 1912  
      */
 1913  
     protected void updatePatternSet( PatternSet value, String xmlTag, Counter counter, Element element )
 1914  
     {
 1915  0
         boolean shouldExist = value != null;
 1916  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1917  0
         if ( shouldExist )
 1918  
         {
 1919  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1920  0
             findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" );
 1921  0
             findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" );
 1922  
         }
 1923  0
     } // -- void updatePatternSet(PatternSet, String, Counter, Element)
 1924  
 
 1925  
     /**
 1926  
      * Method updatePlugin.
 1927  
      *
 1928  
      * @param value
 1929  
      * @param element
 1930  
      * @param counter
 1931  
      * @param xmlTag
 1932  
      */
 1933  
     protected void updatePlugin( Plugin value, String xmlTag, Counter counter, Element element )
 1934  
     {
 1935  18
         Element root = element;
 1936  18
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 1937  18
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins" );
 1938  18
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 1939  18
         findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 1940  18
         findAndReplaceSimpleElement( innerCount, root, "extensions",
 1941  
                                      ( value.isExtensions() == false ) ? null : String.valueOf( value.isExtensions() ),
 1942  
                                      "false" );
 1943  18
         iteratePluginExecution( innerCount, root, value.getExecutions(), "executions", "execution" );
 1944  18
         iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
 1945  18
         findAndReplaceXpp3DOM( innerCount, root, "goals", (Xpp3Dom) value.getGoals() );
 1946  18
         findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
 1947  18
         findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
 1948  18
     } // -- void updatePlugin(Plugin, String, Counter, Element)
 1949  
 
 1950  
     /**
 1951  
      * Method updatePluginConfiguration.
 1952  
      *
 1953  
      * @param value
 1954  
      * @param element
 1955  
      * @param counter
 1956  
      * @param xmlTag
 1957  
      */
 1958  
     protected void updatePluginConfiguration( PluginConfiguration value, String xmlTag, Counter counter,
 1959  
                                               Element element )
 1960  
     {
 1961  0
         boolean shouldExist = value != null;
 1962  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1963  0
         if ( shouldExist )
 1964  
         {
 1965  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1966  0
             updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
 1967  0
             iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 1968  
         }
 1969  0
     } // -- void updatePluginConfiguration(PluginConfiguration, String, Counter, Element)
 1970  
 
 1971  
     /**
 1972  
      * Method updatePluginContainer.
 1973  
      *
 1974  
      * @param value
 1975  
      * @param element
 1976  
      * @param counter
 1977  
      * @param xmlTag
 1978  
      */
 1979  
     protected void updatePluginContainer( PluginContainer value, String xmlTag, Counter counter, Element element )
 1980  
     {
 1981  0
         boolean shouldExist = value != null;
 1982  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 1983  0
         if ( shouldExist )
 1984  
         {
 1985  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 1986  0
             iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 1987  
         }
 1988  0
     } // -- void updatePluginContainer(PluginContainer, String, Counter, Element)
 1989  
 
 1990  
     /**
 1991  
      * Method updatePluginExecution.
 1992  
      *
 1993  
      * @param value
 1994  
      * @param element
 1995  
      * @param counter
 1996  
      * @param xmlTag
 1997  
      */
 1998  
     protected void updatePluginExecution( PluginExecution value, String xmlTag, Counter counter, Element element )
 1999  
     {
 2000  0
         Element root = element;
 2001  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2002  0
         findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" );
 2003  0
         findAndReplaceSimpleElement( innerCount, root, "phase", value.getPhase(), null );
 2004  0
         findAndReplaceSimpleLists( innerCount, root, value.getGoals(), "goals", "goal" );
 2005  0
         findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
 2006  0
         findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
 2007  0
     } // -- void updatePluginExecution(PluginExecution, String, Counter, Element)
 2008  
 
 2009  
     /**
 2010  
      * Method updatePluginManagement.
 2011  
      *
 2012  
      * @param value
 2013  
      * @param element
 2014  
      * @param counter
 2015  
      * @param xmlTag
 2016  
      */
 2017  
     protected void updatePluginManagement( PluginManagement value, String xmlTag, Counter counter, Element element )
 2018  
     {
 2019  18
         boolean shouldExist = value != null;
 2020  18
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2021  18
         if ( shouldExist )
 2022  
         {
 2023  12
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2024  12
             iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 2025  
         }
 2026  18
     } // -- void updatePluginManagement(PluginManagement, String, Counter, Element)
 2027  
 
 2028  
     /**
 2029  
      * Method updatePrerequisites.
 2030  
      *
 2031  
      * @param value
 2032  
      * @param element
 2033  
      * @param counter
 2034  
      * @param xmlTag
 2035  
      */
 2036  
     protected void updatePrerequisites( Prerequisites value, String xmlTag, Counter counter, Element element )
 2037  
     {
 2038  56
         boolean shouldExist = value != null;
 2039  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2040  56
         if ( shouldExist )
 2041  
         {
 2042  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2043  0
             findAndReplaceSimpleElement( innerCount, root, "maven", value.getMaven(), "2.0" );
 2044  
         }
 2045  56
     } // -- void updatePrerequisites(Prerequisites, String, Counter, Element)
 2046  
 
 2047  
     /**
 2048  
      * Method updateProfile.
 2049  
      *
 2050  
      * @param value
 2051  
      * @param element
 2052  
      * @param counter
 2053  
      * @param xmlTag
 2054  
      */
 2055  
     protected void updateProfile( Profile value, String xmlTag, Counter counter, Element element )
 2056  
     {
 2057  0
         Element root = element;
 2058  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2059  0
         findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 2060  0
         updateActivation( value.getActivation(), "activation", innerCount, root );
 2061  0
         updateBuildBase( value.getBuild(), "build", innerCount, root );
 2062  0
         findAndReplaceSimpleLists( innerCount, root, value.getModules(), "modules", "module" );
 2063  0
         iterateRepository( innerCount, root, value.getRepositories(), "repositories", "repository" );
 2064  0
         iterateRepository( innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
 2065  0
         iterateDependency( innerCount, root, value.getDependencies(), "dependencies", "dependency" );
 2066  0
         findAndReplaceXpp3DOM( innerCount, root, "reports", (Xpp3Dom) value.getReports() );
 2067  0
         updateReporting( value.getReporting(), "reporting", innerCount, root );
 2068  0
         updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root );
 2069  0
         updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root );
 2070  0
         findAndReplaceProperties( innerCount, root, "properties", value.getProperties() );
 2071  0
     } // -- void updateProfile(Profile, String, Counter, Element)
 2072  
 
 2073  
     /**
 2074  
      * Method updateRelocation.
 2075  
      *
 2076  
      * @param value
 2077  
      * @param element
 2078  
      * @param counter
 2079  
      * @param xmlTag
 2080  
      */
 2081  
     protected void updateRelocation( Relocation value, String xmlTag, Counter counter, Element element )
 2082  
     {
 2083  0
         boolean shouldExist = value != null;
 2084  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2085  0
         if ( shouldExist )
 2086  
         {
 2087  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2088  0
             findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
 2089  0
             findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 2090  0
             findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 2091  0
             findAndReplaceSimpleElement( innerCount, root, "message", value.getMessage(), null );
 2092  
         }
 2093  0
     } // -- void updateRelocation(Relocation, String, Counter, Element)
 2094  
 
 2095  
     /**
 2096  
      * Method updateReporting.
 2097  
      *
 2098  
      * @param value
 2099  
      * @param element
 2100  
      * @param counter
 2101  
      * @param xmlTag
 2102  
      */
 2103  
     protected void updateReporting( Reporting value, String xmlTag, Counter counter, Element element )
 2104  
     {
 2105  56
         boolean shouldExist = value != null;
 2106  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2107  56
         if ( shouldExist )
 2108  
         {
 2109  6
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2110  6
             findAndReplaceSimpleElement( innerCount, root, "excludeDefaults", ( value.isExcludeDefaults() == false )
 2111  
                 ? null
 2112  
                 : String.valueOf( value.isExcludeDefaults() ), "false" );
 2113  6
             findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null );
 2114  6
             iterateReportPlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
 2115  
         }
 2116  56
     } // -- void updateReporting(Reporting, String, Counter, Element)
 2117  
 
 2118  
     /**
 2119  
      * Method updateReportPlugin.
 2120  
      *
 2121  
      * @param value
 2122  
      * @param element
 2123  
      * @param counter
 2124  
      * @param xmlTag
 2125  
      */
 2126  
     protected void updateReportPlugin( ReportPlugin value, String xmlTag, Counter counter, Element element )
 2127  
     {
 2128  6
         Element root = element;
 2129  6
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2130  6
         findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins" );
 2131  6
         findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
 2132  6
         findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
 2133  6
         findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
 2134  6
         findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
 2135  6
         iterateReportSet( innerCount, root, value.getReportSets(), "reportSets", "reportSet" );
 2136  6
     } // -- void updateReportPlugin(ReportPlugin, String, Counter, Element)
 2137  
 
 2138  
     /**
 2139  
      * Method updateReportSet.
 2140  
      *
 2141  
      * @param value
 2142  
      * @param element
 2143  
      * @param counter
 2144  
      * @param xmlTag
 2145  
      */
 2146  
     protected void updateReportSet( ReportSet value, String xmlTag, Counter counter, Element element )
 2147  
     {
 2148  0
         Element root = element;
 2149  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2150  0
         findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" );
 2151  0
         findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() );
 2152  0
         findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null );
 2153  0
         findAndReplaceSimpleLists( innerCount, root, value.getReports(), "reports", "report" );
 2154  0
     } // -- void updateReportSet(ReportSet, String, Counter, Element)
 2155  
 
 2156  
     /**
 2157  
      * Method updateRepository.
 2158  
      *
 2159  
      * @param value
 2160  
      * @param element
 2161  
      * @param counter
 2162  
      * @param xmlTag
 2163  
      */
 2164  
     protected void updateRepository( Repository value, String xmlTag, Counter counter, Element element )
 2165  
     {
 2166  0
         Element root = element;
 2167  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2168  0
         updateRepositoryPolicy( value.getReleases(), "releases", innerCount, root );
 2169  0
         updateRepositoryPolicy( value.getSnapshots(), "snapshots", innerCount, root );
 2170  0
         findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 2171  0
         findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 2172  0
         findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 2173  0
         findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" );
 2174  0
     } // -- void updateRepository(Repository, String, Counter, Element)
 2175  
 
 2176  
     /**
 2177  
      * Method updateRepositoryBase.
 2178  
      *
 2179  
      * @param value
 2180  
      * @param element
 2181  
      * @param counter
 2182  
      * @param xmlTag
 2183  
      */
 2184  
     protected void updateRepositoryBase( RepositoryBase value, String xmlTag, Counter counter, Element element )
 2185  
     {
 2186  0
         boolean shouldExist = value != null;
 2187  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2188  0
         if ( shouldExist )
 2189  
         {
 2190  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2191  0
             findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 2192  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 2193  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 2194  0
             findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" );
 2195  
         }
 2196  0
     } // -- void updateRepositoryBase(RepositoryBase, String, Counter, Element)
 2197  
 
 2198  
     /**
 2199  
      * Method updateRepositoryPolicy.
 2200  
      *
 2201  
      * @param value
 2202  
      * @param element
 2203  
      * @param counter
 2204  
      * @param xmlTag
 2205  
      */
 2206  
     protected void updateRepositoryPolicy( RepositoryPolicy value, String xmlTag, Counter counter, Element element )
 2207  
     {
 2208  0
         boolean shouldExist = value != null;
 2209  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2210  0
         if ( shouldExist )
 2211  
         {
 2212  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2213  0
             findAndReplaceSimpleElement( innerCount, root, "enabled",
 2214  
                                          ( value.isEnabled() == true ) ? null : String.valueOf( value.isEnabled() ),
 2215  
                                          "true" );
 2216  0
             findAndReplaceSimpleElement( innerCount, root, "updatePolicy", value.getUpdatePolicy(), null );
 2217  0
             findAndReplaceSimpleElement( innerCount, root, "checksumPolicy", value.getChecksumPolicy(), null );
 2218  
         }
 2219  0
     } // -- void updateRepositoryPolicy(RepositoryPolicy, String, Counter, Element)
 2220  
 
 2221  
     /**
 2222  
      * Method updateResource.
 2223  
      *
 2224  
      * @param value
 2225  
      * @param element
 2226  
      * @param counter
 2227  
      * @param xmlTag
 2228  
      */
 2229  
     protected void updateResource( Resource value, String xmlTag, Counter counter, Element element )
 2230  
     {
 2231  0
         Element root = element;
 2232  0
         Counter innerCount = new Counter( counter.getDepth() + 1 );
 2233  0
         findAndReplaceSimpleElement( innerCount, root, "targetPath", value.getTargetPath(), null );
 2234  0
         findAndReplaceSimpleElement( innerCount, root, "filtering",
 2235  
                                      ( value.isFiltering() == false ) ? null : String.valueOf( value.isFiltering() ),
 2236  
                                      "false" );
 2237  0
         findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
 2238  0
         findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" );
 2239  0
         findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" );
 2240  0
     } // -- void updateResource(Resource, String, Counter, Element)
 2241  
 
 2242  
     /**
 2243  
      * Method updateScm.
 2244  
      *
 2245  
      * @param value
 2246  
      * @param element
 2247  
      * @param counter
 2248  
      * @param xmlTag
 2249  
      */
 2250  
     protected void updateScm( Scm value, String xmlTag, Counter counter, Element element )
 2251  
     {
 2252  56
         boolean shouldExist = value != null;
 2253  56
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2254  56
         if ( shouldExist )
 2255  
         {
 2256  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2257  0
             findAndReplaceSimpleElement( innerCount, root, "connection", value.getConnection(), null );
 2258  0
             findAndReplaceSimpleElement( innerCount, root, "developerConnection", value.getDeveloperConnection(),
 2259  
                                          null );
 2260  0
             findAndReplaceSimpleElement( innerCount, root, "tag", value.getTag(), "HEAD" );
 2261  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 2262  
         }
 2263  56
     } // -- void updateScm(Scm, String, Counter, Element)
 2264  
 
 2265  
     /**
 2266  
      * Method updateSite.
 2267  
      *
 2268  
      * @param value
 2269  
      * @param element
 2270  
      * @param counter
 2271  
      * @param xmlTag
 2272  
      */
 2273  
     protected void updateSite( Site value, String xmlTag, Counter counter, Element element )
 2274  
     {
 2275  0
         boolean shouldExist = value != null;
 2276  0
         Element root = updateElement( counter, element, xmlTag, shouldExist );
 2277  0
         if ( shouldExist )
 2278  
         {
 2279  0
             Counter innerCount = new Counter( counter.getDepth() + 1 );
 2280  0
             findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
 2281  0
             findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
 2282  0
             findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
 2283  
         }
 2284  0
     } // -- void updateSite(Site, String, Counter, Element)
 2285  
 
 2286  
     // -----------------/
 2287  
     // - Inner Classes -/
 2288  
     // -----------------/
 2289  
 
 2290  
     /**
 2291  
      * Class Counter.
 2292  
      *
 2293  
      * @version $Revision$ $Date$
 2294  
      */
 2295  
     public class Counter
 2296  
     {
 2297  
         // --------------------------/
 2298  
         // - Class/Member Variables -/
 2299  
         // --------------------------/
 2300  
 
 2301  
         /**
 2302  
          * Field currentIndex.
 2303  
          */
 2304  296
         private int currentIndex = 0;
 2305  
 
 2306  
         /**
 2307  
          * Field level.
 2308  
          */
 2309  
         private int level;
 2310  
 
 2311  
         // ----------------/
 2312  
         // - Constructors -/
 2313  
         // ----------------/
 2314  
 
 2315  
         public Counter( int depthLevel )
 2316  296
         {
 2317  296
             level = depthLevel;
 2318  296
         } // -- org.apache.maven.model.io.jdom.Counter(int)
 2319  
 
 2320  
         // -----------/
 2321  
         // - Methods -/
 2322  
         // -----------/
 2323  
 
 2324  
         /**
 2325  
          * Method getCurrentIndex.
 2326  
          */
 2327  
         public int getCurrentIndex()
 2328  
         {
 2329  486
             return currentIndex;
 2330  
         } // -- int getCurrentIndex()
 2331  
 
 2332  
         /**
 2333  
          * Method getDepth.
 2334  
          */
 2335  
         public int getDepth()
 2336  
         {
 2337  610
             return level;
 2338  
         } // -- int getDepth()
 2339  
 
 2340  
         /**
 2341  
          * Method increaseCount.
 2342  
          */
 2343  
         public void increaseCount()
 2344  
         {
 2345  700
             currentIndex = currentIndex + 1;
 2346  700
         } // -- void increaseCount()
 2347  
     }
 2348  
 }