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