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