Coverage Report - org.apache.maven.plugin.javadoc.options.io.xpp3.JavadocOptionsXpp3Writer
 
Classes in this File Line Coverage Branch Coverage Complexity
JavadocOptionsXpp3Writer
67%
116/174
49%
66/134
0
 
 1  
 /*
 2  
  =================== DO NOT EDIT THIS FILE ====================
 3  
  Generated by Modello 1.1 on 2010-04-30 14:55:57,
 4  
  any modifications will be overwritten.
 5  
  ==============================================================
 6  
  */
 7  
 
 8  
 package org.apache.maven.plugin.javadoc.options.io.xpp3;
 9  
 
 10  
   //---------------------------------/
 11  
  //- Imported classes and packages -/
 12  
 //---------------------------------/
 13  
 
 14  
 import java.io.Writer;
 15  
 import java.text.DateFormat;
 16  
 import java.util.Iterator;
 17  
 import java.util.Locale;
 18  
 import org.apache.maven.plugin.javadoc.options.BootclasspathArtifact;
 19  
 import org.apache.maven.plugin.javadoc.options.DocletArtifact;
 20  
 import org.apache.maven.plugin.javadoc.options.Group;
 21  
 import org.apache.maven.plugin.javadoc.options.JavadocOptions;
 22  
 import org.apache.maven.plugin.javadoc.options.JavadocPathArtifact;
 23  
 import org.apache.maven.plugin.javadoc.options.OfflineLink;
 24  
 import org.apache.maven.plugin.javadoc.options.ResourcesArtifact;
 25  
 import org.apache.maven.plugin.javadoc.options.Tag;
 26  
 import org.apache.maven.plugin.javadoc.options.Taglet;
 27  
 import org.apache.maven.plugin.javadoc.options.TagletArtifact;
 28  
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 29  
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
 30  
 
 31  
 /**
 32  
  * Class JavadocOptionsXpp3Writer.
 33  
  * 
 34  
  * @version $Revision: 829396 $ $Date: 2012-08-19 17:35:19 +0000 (Sun, 19 Aug 2012) $
 35  
  */
 36  
 @SuppressWarnings( "all" )
 37  42
 public class JavadocOptionsXpp3Writer
 38  
 {
 39  
 
 40  
       //--------------------------/
 41  
      //- Class/Member Variables -/
 42  
     //--------------------------/
 43  
 
 44  
     /**
 45  
      * Field NAMESPACE.
 46  
      */
 47  1
     private static final String NAMESPACE = null;
 48  
 
 49  
 
 50  
       //-----------/
 51  
      //- Methods -/
 52  
     //-----------/
 53  
 
 54  
     /**
 55  
      * Method write.
 56  
      * 
 57  
      * @param writer
 58  
      * @param javadocOptions
 59  
      * @throws java.io.IOException
 60  
      */
 61  
     public void write( Writer writer, JavadocOptions javadocOptions )
 62  
         throws java.io.IOException
 63  
     {
 64  42
         XmlSerializer serializer = new MXSerializer();
 65  42
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
 66  42
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
 67  42
         serializer.setOutput( writer );
 68  42
         serializer.startDocument( javadocOptions.getModelEncoding(), null );
 69  42
         writeJavadocOptions( javadocOptions, "javadocOptions", serializer );
 70  42
         serializer.endDocument();
 71  42
     } //-- void write( Writer, JavadocOptions )
 72  
 
 73  
     /**
 74  
      * Method writeBootclasspathArtifact.
 75  
      * 
 76  
      * @param bootclasspathArtifact
 77  
      * @param serializer
 78  
      * @param tagName
 79  
      * @throws java.io.IOException
 80  
      */
 81  
     private void writeBootclasspathArtifact( BootclasspathArtifact bootclasspathArtifact, String tagName, XmlSerializer serializer )
 82  
         throws java.io.IOException
 83  
     {
 84  0
         if ( bootclasspathArtifact != null )
 85  
         {
 86  0
             serializer.startTag( NAMESPACE, tagName );
 87  0
             if ( bootclasspathArtifact.getGroupId() != null )
 88  
             {
 89  0
                 serializer.startTag( NAMESPACE, "groupId" ).text( bootclasspathArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
 90  
             }
 91  0
             if ( bootclasspathArtifact.getArtifactId() != null )
 92  
             {
 93  0
                 serializer.startTag( NAMESPACE, "artifactId" ).text( bootclasspathArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
 94  
             }
 95  0
             if ( bootclasspathArtifact.getVersion() != null )
 96  
             {
 97  0
                 serializer.startTag( NAMESPACE, "version" ).text( bootclasspathArtifact.getVersion() ).endTag( NAMESPACE, "version" );
 98  
             }
 99  0
             serializer.endTag( NAMESPACE, tagName );
 100  
         }
 101  0
     } //-- void writeBootclasspathArtifact( BootclasspathArtifact, String, XmlSerializer )
 102  
 
 103  
     /**
 104  
      * Method writeDocletArtifact.
 105  
      * 
 106  
      * @param docletArtifact
 107  
      * @param serializer
 108  
      * @param tagName
 109  
      * @throws java.io.IOException
 110  
      */
 111  
     private void writeDocletArtifact( DocletArtifact docletArtifact, String tagName, XmlSerializer serializer )
 112  
         throws java.io.IOException
 113  
     {
 114  3
         if ( docletArtifact != null )
 115  
         {
 116  3
             serializer.startTag( NAMESPACE, tagName );
 117  3
             if ( docletArtifact.getGroupId() != null )
 118  
             {
 119  3
                 serializer.startTag( NAMESPACE, "groupId" ).text( docletArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
 120  
             }
 121  3
             if ( docletArtifact.getArtifactId() != null )
 122  
             {
 123  3
                 serializer.startTag( NAMESPACE, "artifactId" ).text( docletArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
 124  
             }
 125  3
             if ( docletArtifact.getVersion() != null )
 126  
             {
 127  3
                 serializer.startTag( NAMESPACE, "version" ).text( docletArtifact.getVersion() ).endTag( NAMESPACE, "version" );
 128  
             }
 129  3
             serializer.endTag( NAMESPACE, tagName );
 130  
         }
 131  3
     } //-- void writeDocletArtifact( DocletArtifact, String, XmlSerializer )
 132  
 
 133  
     /**
 134  
      * Method writeGroup.
 135  
      * 
 136  
      * @param group
 137  
      * @param serializer
 138  
      * @param tagName
 139  
      * @throws java.io.IOException
 140  
      */
 141  
     private void writeGroup( Group group, String tagName, XmlSerializer serializer )
 142  
         throws java.io.IOException
 143  
     {
 144  2
         if ( group != null )
 145  
         {
 146  2
             serializer.startTag( NAMESPACE, tagName );
 147  2
             if ( group.getTitle() != null )
 148  
             {
 149  2
                 serializer.startTag( NAMESPACE, "title" ).text( group.getTitle() ).endTag( NAMESPACE, "title" );
 150  
             }
 151  2
             if ( group.getPackages() != null )
 152  
             {
 153  2
                 serializer.startTag( NAMESPACE, "packages" ).text( group.getPackages() ).endTag( NAMESPACE, "packages" );
 154  
             }
 155  2
             serializer.endTag( NAMESPACE, tagName );
 156  
         }
 157  2
     } //-- void writeGroup( Group, String, XmlSerializer )
 158  
 
 159  
     /**
 160  
      * Method writeJavadocOptions.
 161  
      * 
 162  
      * @param javadocOptions
 163  
      * @param serializer
 164  
      * @param tagName
 165  
      * @throws java.io.IOException
 166  
      */
 167  
     private void writeJavadocOptions( JavadocOptions javadocOptions, String tagName, XmlSerializer serializer )
 168  
         throws java.io.IOException
 169  
     {
 170  42
         if ( javadocOptions != null )
 171  
         {
 172  42
             serializer.startTag( NAMESPACE, tagName );
 173  42
             if ( ( javadocOptions.getGroups() != null ) && ( javadocOptions.getGroups().size() > 0 ) )
 174  
             {
 175  1
                 serializer.startTag( NAMESPACE, "groups" );
 176  1
                 for ( Iterator iter = javadocOptions.getGroups().iterator(); iter.hasNext(); )
 177  
                 {
 178  2
                     Group o = (Group) iter.next();
 179  2
                     writeGroup( o, "group", serializer );
 180  2
                 }
 181  1
                 serializer.endTag( NAMESPACE, "groups" );
 182  
             }
 183  42
             if ( ( javadocOptions.getTags() != null ) && ( javadocOptions.getTags().size() > 0 ) )
 184  
             {
 185  2
                 serializer.startTag( NAMESPACE, "tags" );
 186  2
                 for ( Iterator iter = javadocOptions.getTags().iterator(); iter.hasNext(); )
 187  
                 {
 188  6
                     Tag o = (Tag) iter.next();
 189  6
                     writeTag( o, "tag", serializer );
 190  6
                 }
 191  2
                 serializer.endTag( NAMESPACE, "tags" );
 192  
             }
 193  42
             if ( ( javadocOptions.getDocletArtifacts() != null ) && ( javadocOptions.getDocletArtifacts().size() > 0 ) )
 194  
             {
 195  2
                 serializer.startTag( NAMESPACE, "docletArtifacts" );
 196  2
                 for ( Iterator iter = javadocOptions.getDocletArtifacts().iterator(); iter.hasNext(); )
 197  
                 {
 198  3
                     DocletArtifact o = (DocletArtifact) iter.next();
 199  3
                     writeDocletArtifact( o, "docletArtifact", serializer );
 200  3
                 }
 201  2
                 serializer.endTag( NAMESPACE, "docletArtifacts" );
 202  
             }
 203  42
             if ( ( javadocOptions.getTaglets() != null ) && ( javadocOptions.getTaglets().size() > 0 ) )
 204  
             {
 205  0
                 serializer.startTag( NAMESPACE, "taglets" );
 206  0
                 for ( Iterator iter = javadocOptions.getTaglets().iterator(); iter.hasNext(); )
 207  
                 {
 208  0
                     Taglet o = (Taglet) iter.next();
 209  0
                     writeTaglet( o, "taglet", serializer );
 210  0
                 }
 211  0
                 serializer.endTag( NAMESPACE, "taglets" );
 212  
             }
 213  42
             if ( ( javadocOptions.getOfflineLinks() != null ) && ( javadocOptions.getOfflineLinks().size() > 0 ) )
 214  
             {
 215  1
                 serializer.startTag( NAMESPACE, "offlineLinks" );
 216  1
                 for ( Iterator iter = javadocOptions.getOfflineLinks().iterator(); iter.hasNext(); )
 217  
                 {
 218  1
                     OfflineLink o = (OfflineLink) iter.next();
 219  1
                     writeOfflineLink( o, "offlineLink", serializer );
 220  1
                 }
 221  1
                 serializer.endTag( NAMESPACE, "offlineLinks" );
 222  
             }
 223  42
             if ( ( javadocOptions.getTagletArtifacts() != null ) && ( javadocOptions.getTagletArtifacts().size() > 0 ) )
 224  
             {
 225  2
                 serializer.startTag( NAMESPACE, "tagletArtifacts" );
 226  2
                 for ( Iterator iter = javadocOptions.getTagletArtifacts().iterator(); iter.hasNext(); )
 227  
                 {
 228  3
                     TagletArtifact o = (TagletArtifact) iter.next();
 229  3
                     writeTagletArtifact( o, "tagletArtifact", serializer );
 230  3
                 }
 231  2
                 serializer.endTag( NAMESPACE, "tagletArtifacts" );
 232  
             }
 233  42
             if ( ( javadocOptions.getResourcesArtifacts() != null ) && ( javadocOptions.getResourcesArtifacts().size() > 0 ) )
 234  
             {
 235  0
                 serializer.startTag( NAMESPACE, "resourcesArtifacts" );
 236  0
                 for ( Iterator iter = javadocOptions.getResourcesArtifacts().iterator(); iter.hasNext(); )
 237  
                 {
 238  0
                     ResourcesArtifact o = (ResourcesArtifact) iter.next();
 239  0
                     writeResourcesArtifact( o, "resourcesArtifact", serializer );
 240  0
                 }
 241  0
                 serializer.endTag( NAMESPACE, "resourcesArtifacts" );
 242  
             }
 243  42
             if ( ( javadocOptions.getBootclasspathArtifacts() != null ) && ( javadocOptions.getBootclasspathArtifacts().size() > 0 ) )
 244  
             {
 245  0
                 serializer.startTag( NAMESPACE, "bootclasspathArtifacts" );
 246  0
                 for ( Iterator iter = javadocOptions.getBootclasspathArtifacts().iterator(); iter.hasNext(); )
 247  
                 {
 248  0
                     BootclasspathArtifact o = (BootclasspathArtifact) iter.next();
 249  0
                     writeBootclasspathArtifact( o, "bootclasspathArtifact", serializer );
 250  0
                 }
 251  0
                 serializer.endTag( NAMESPACE, "bootclasspathArtifacts" );
 252  
             }
 253  42
             if ( ( javadocOptions.getLinks() != null ) && ( javadocOptions.getLinks().size() > 0 ) )
 254  
             {
 255  17
                 serializer.startTag( NAMESPACE, "links" );
 256  17
                 for ( Iterator iter = javadocOptions.getLinks().iterator(); iter.hasNext(); )
 257  
                 {
 258  17
                     String link = (String) iter.next();
 259  17
                     serializer.startTag( NAMESPACE, "link" ).text( link ).endTag( NAMESPACE, "link" );
 260  17
                 }
 261  17
                 serializer.endTag( NAMESPACE, "links" );
 262  
             }
 263  42
             if ( ( javadocOptions.getExcludePackageNames() != null ) && ( javadocOptions.getExcludePackageNames().size() > 0 ) )
 264  
             {
 265  2
                 serializer.startTag( NAMESPACE, "excludePackageNames" );
 266  2
                 for ( Iterator iter = javadocOptions.getExcludePackageNames().iterator(); iter.hasNext(); )
 267  
                 {
 268  4
                     String excludePackageName = (String) iter.next();
 269  4
                     serializer.startTag( NAMESPACE, "excludePackageName" ).text( excludePackageName ).endTag( NAMESPACE, "excludePackageName" );
 270  4
                 }
 271  2
                 serializer.endTag( NAMESPACE, "excludePackageNames" );
 272  
             }
 273  42
             if ( javadocOptions.isDocfilesSubdirsUsed() != false )
 274  
             {
 275  5
                 serializer.startTag( NAMESPACE, "docfilesSubdirsUsed" ).text( String.valueOf( javadocOptions.isDocfilesSubdirsUsed() ) ).endTag( NAMESPACE, "docfilesSubdirsUsed" );
 276  
             }
 277  42
             if ( javadocOptions.getExcludedDocfilesSubdirs() != null )
 278  
             {
 279  2
                 serializer.startTag( NAMESPACE, "excludedDocfilesSubdirs" ).text( javadocOptions.getExcludedDocfilesSubdirs() ).endTag( NAMESPACE, "excludedDocfilesSubdirs" );
 280  
             }
 281  42
             if ( javadocOptions.getJavadocResourcesDirectory() != null )
 282  
             {
 283  16
                 serializer.startTag( NAMESPACE, "javadocResourcesDirectory" ).text( javadocOptions.getJavadocResourcesDirectory() ).endTag( NAMESPACE, "javadocResourcesDirectory" );
 284  
             }
 285  42
             serializer.endTag( NAMESPACE, tagName );
 286  
         }
 287  42
     } //-- void writeJavadocOptions( JavadocOptions, String, XmlSerializer )
 288  
 
 289  
     /**
 290  
      * Method writeJavadocPathArtifact.
 291  
      * 
 292  
      * @param javadocPathArtifact
 293  
      * @param serializer
 294  
      * @param tagName
 295  
      * @throws java.io.IOException
 296  
      */
 297  
     private void writeJavadocPathArtifact( JavadocPathArtifact javadocPathArtifact, String tagName, XmlSerializer serializer )
 298  
         throws java.io.IOException
 299  
     {
 300  0
         if ( javadocPathArtifact != null )
 301  
         {
 302  0
             serializer.startTag( NAMESPACE, tagName );
 303  0
             if ( javadocPathArtifact.getGroupId() != null )
 304  
             {
 305  0
                 serializer.startTag( NAMESPACE, "groupId" ).text( javadocPathArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
 306  
             }
 307  0
             if ( javadocPathArtifact.getArtifactId() != null )
 308  
             {
 309  0
                 serializer.startTag( NAMESPACE, "artifactId" ).text( javadocPathArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
 310  
             }
 311  0
             if ( javadocPathArtifact.getVersion() != null )
 312  
             {
 313  0
                 serializer.startTag( NAMESPACE, "version" ).text( javadocPathArtifact.getVersion() ).endTag( NAMESPACE, "version" );
 314  
             }
 315  0
             serializer.endTag( NAMESPACE, tagName );
 316  
         }
 317  0
     } //-- void writeJavadocPathArtifact( JavadocPathArtifact, String, XmlSerializer )
 318  
 
 319  
     /**
 320  
      * Method writeOfflineLink.
 321  
      * 
 322  
      * @param offlineLink
 323  
      * @param serializer
 324  
      * @param tagName
 325  
      * @throws java.io.IOException
 326  
      */
 327  
     private void writeOfflineLink( OfflineLink offlineLink, String tagName, XmlSerializer serializer )
 328  
         throws java.io.IOException
 329  
     {
 330  1
         if ( offlineLink != null )
 331  
         {
 332  1
             serializer.startTag( NAMESPACE, tagName );
 333  1
             if ( offlineLink.getUrl() != null )
 334  
             {
 335  1
                 serializer.startTag( NAMESPACE, "url" ).text( offlineLink.getUrl() ).endTag( NAMESPACE, "url" );
 336  
             }
 337  1
             if ( offlineLink.getLocation() != null )
 338  
             {
 339  1
                 serializer.startTag( NAMESPACE, "location" ).text( offlineLink.getLocation() ).endTag( NAMESPACE, "location" );
 340  
             }
 341  1
             serializer.endTag( NAMESPACE, tagName );
 342  
         }
 343  1
     } //-- void writeOfflineLink( OfflineLink, String, XmlSerializer )
 344  
 
 345  
     /**
 346  
      * Method writeResourcesArtifact.
 347  
      * 
 348  
      * @param resourcesArtifact
 349  
      * @param serializer
 350  
      * @param tagName
 351  
      * @throws java.io.IOException
 352  
      */
 353  
     private void writeResourcesArtifact( ResourcesArtifact resourcesArtifact, String tagName, XmlSerializer serializer )
 354  
         throws java.io.IOException
 355  
     {
 356  0
         if ( resourcesArtifact != null )
 357  
         {
 358  0
             serializer.startTag( NAMESPACE, tagName );
 359  0
             if ( resourcesArtifact.getGroupId() != null )
 360  
             {
 361  0
                 serializer.startTag( NAMESPACE, "groupId" ).text( resourcesArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
 362  
             }
 363  0
             if ( resourcesArtifact.getArtifactId() != null )
 364  
             {
 365  0
                 serializer.startTag( NAMESPACE, "artifactId" ).text( resourcesArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
 366  
             }
 367  0
             if ( resourcesArtifact.getVersion() != null )
 368  
             {
 369  0
                 serializer.startTag( NAMESPACE, "version" ).text( resourcesArtifact.getVersion() ).endTag( NAMESPACE, "version" );
 370  
             }
 371  0
             serializer.endTag( NAMESPACE, tagName );
 372  
         }
 373  0
     } //-- void writeResourcesArtifact( ResourcesArtifact, String, XmlSerializer )
 374  
 
 375  
     /**
 376  
      * Method writeTag.
 377  
      * 
 378  
      * @param tag
 379  
      * @param serializer
 380  
      * @param tagName
 381  
      * @throws java.io.IOException
 382  
      */
 383  
     private void writeTag( Tag tag, String tagName, XmlSerializer serializer )
 384  
         throws java.io.IOException
 385  
     {
 386  6
         if ( tag != null )
 387  
         {
 388  6
             serializer.startTag( NAMESPACE, tagName );
 389  6
             if ( tag.getName() != null )
 390  
             {
 391  6
                 serializer.startTag( NAMESPACE, "name" ).text( tag.getName() ).endTag( NAMESPACE, "name" );
 392  
             }
 393  6
             if ( tag.getHead() != null )
 394  
             {
 395  5
                 serializer.startTag( NAMESPACE, "head" ).text( tag.getHead() ).endTag( NAMESPACE, "head" );
 396  
             }
 397  6
             serializer.endTag( NAMESPACE, tagName );
 398  
         }
 399  6
     } //-- void writeTag( Tag, String, XmlSerializer )
 400  
 
 401  
     /**
 402  
      * Method writeTaglet.
 403  
      * 
 404  
      * @param taglet
 405  
      * @param serializer
 406  
      * @param tagName
 407  
      * @throws java.io.IOException
 408  
      */
 409  
     private void writeTaglet( Taglet taglet, String tagName, XmlSerializer serializer )
 410  
         throws java.io.IOException
 411  
     {
 412  0
         if ( taglet != null )
 413  
         {
 414  0
             serializer.startTag( NAMESPACE, tagName );
 415  0
             if ( taglet.getTagletClass() != null )
 416  
             {
 417  0
                 serializer.startTag( NAMESPACE, "tagletClass" ).text( taglet.getTagletClass() ).endTag( NAMESPACE, "tagletClass" );
 418  
             }
 419  0
             if ( taglet.getTagletpath() != null )
 420  
             {
 421  0
                 serializer.startTag( NAMESPACE, "tagletpath" ).text( taglet.getTagletpath() ).endTag( NAMESPACE, "tagletpath" );
 422  
             }
 423  0
             if ( taglet.getTagletArtifact() != null )
 424  
             {
 425  0
                 writeTagletArtifact( (TagletArtifact) taglet.getTagletArtifact(), "tagletArtifact", serializer );
 426  
             }
 427  0
             serializer.endTag( NAMESPACE, tagName );
 428  
         }
 429  0
     } //-- void writeTaglet( Taglet, String, XmlSerializer )
 430  
 
 431  
     /**
 432  
      * Method writeTagletArtifact.
 433  
      * 
 434  
      * @param tagletArtifact
 435  
      * @param serializer
 436  
      * @param tagName
 437  
      * @throws java.io.IOException
 438  
      */
 439  
     private void writeTagletArtifact( TagletArtifact tagletArtifact, String tagName, XmlSerializer serializer )
 440  
         throws java.io.IOException
 441  
     {
 442  3
         if ( tagletArtifact != null )
 443  
         {
 444  3
             serializer.startTag( NAMESPACE, tagName );
 445  3
             if ( tagletArtifact.getGroupId() != null )
 446  
             {
 447  3
                 serializer.startTag( NAMESPACE, "groupId" ).text( tagletArtifact.getGroupId() ).endTag( NAMESPACE, "groupId" );
 448  
             }
 449  3
             if ( tagletArtifact.getArtifactId() != null )
 450  
             {
 451  3
                 serializer.startTag( NAMESPACE, "artifactId" ).text( tagletArtifact.getArtifactId() ).endTag( NAMESPACE, "artifactId" );
 452  
             }
 453  3
             if ( tagletArtifact.getVersion() != null )
 454  
             {
 455  3
                 serializer.startTag( NAMESPACE, "version" ).text( tagletArtifact.getVersion() ).endTag( NAMESPACE, "version" );
 456  
             }
 457  3
             serializer.endTag( NAMESPACE, tagName );
 458  
         }
 459  3
     } //-- void writeTagletArtifact( TagletArtifact, String, XmlSerializer )
 460  
 
 461  
 }