Coverage Report - org.apache.maven.plugins.changes.model.io.xpp3.ChangesXpp3Writer
 
Classes in this File Line Coverage Branch Coverage Complexity
ChangesXpp3Writer
0%
0/115
0%
0/88
5.4
 
 1  
 /*
 2  
  =================== DO NOT EDIT THIS FILE ====================
 3  
  Generated by Modello 1.0.1 on 2012-05-10 17:27:31,
 4  
  any modifications will be overwritten.
 5  
  ==============================================================
 6  
  */
 7  
 
 8  
 package org.apache.maven.plugins.changes.model.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.plugins.changes.model.Action;
 19  
 import org.apache.maven.plugins.changes.model.Author;
 20  
 import org.apache.maven.plugins.changes.model.Body;
 21  
 import org.apache.maven.plugins.changes.model.ChangesDocument;
 22  
 import org.apache.maven.plugins.changes.model.Component;
 23  
 import org.apache.maven.plugins.changes.model.DueTo;
 24  
 import org.apache.maven.plugins.changes.model.FixedIssue;
 25  
 import org.apache.maven.plugins.changes.model.Properties;
 26  
 import org.apache.maven.plugins.changes.model.Release;
 27  
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 28  
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
 29  
 
 30  
 /**
 31  
  * Class ChangesXpp3Writer.
 32  
  * 
 33  
  * @version $Revision$ $Date$
 34  
  */
 35  0
 public class ChangesXpp3Writer
 36  
 {
 37  
 
 38  
       //--------------------------/
 39  
      //- Class/Member Variables -/
 40  
     //--------------------------/
 41  
 
 42  
     /**
 43  
      * Field NAMESPACE.
 44  
      */
 45  0
     private static final String NAMESPACE = null;
 46  
 
 47  
 
 48  
       //-----------/
 49  
      //- Methods -/
 50  
     //-----------/
 51  
 
 52  
     /**
 53  
      * Method write.
 54  
      * 
 55  
      * @param writer
 56  
      * @param changesDocument
 57  
      * @throws java.io.IOException
 58  
      */
 59  
     public void write( Writer writer, ChangesDocument changesDocument )
 60  
         throws java.io.IOException
 61  
     {
 62  0
         XmlSerializer serializer = new MXSerializer();
 63  0
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
 64  0
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
 65  0
         serializer.setOutput( writer );
 66  0
         serializer.startDocument( changesDocument.getModelEncoding(), null );
 67  0
         writeChangesDocument( changesDocument, "document", serializer );
 68  0
         serializer.endDocument();
 69  0
     } //-- void write( Writer, ChangesDocument )
 70  
 
 71  
     /**
 72  
      * Method writeAction.
 73  
      * 
 74  
      * @param action
 75  
      * @param serializer
 76  
      * @param tagName
 77  
      * @throws java.io.IOException
 78  
      */
 79  
     private void writeAction( Action action, String tagName, XmlSerializer serializer )
 80  
         throws java.io.IOException
 81  
     {
 82  0
         if ( action != null )
 83  
         {
 84  0
             serializer.startTag( NAMESPACE, tagName );
 85  0
             if ( action.getDev() != null )
 86  
             {
 87  0
                 serializer.attribute( NAMESPACE, "dev", action.getDev() );
 88  
             }
 89  0
             if ( action.getDueTo() != null )
 90  
             {
 91  0
                 serializer.attribute( NAMESPACE, "due-to", action.getDueTo() );
 92  
             }
 93  0
             if ( action.getDueToEmail() != null )
 94  
             {
 95  0
                 serializer.attribute( NAMESPACE, "due-to-email", action.getDueToEmail() );
 96  
             }
 97  0
             if ( action.getIssue() != null )
 98  
             {
 99  0
                 serializer.attribute( NAMESPACE, "issue", action.getIssue() );
 100  
             }
 101  0
             if ( action.getType() != null )
 102  
             {
 103  0
                 serializer.attribute( NAMESPACE, "type", action.getType() );
 104  
             }
 105  0
             if ( action.getSystem() != null )
 106  
             {
 107  0
                 serializer.attribute( NAMESPACE, "system", action.getSystem() );
 108  
             }
 109  0
             if ( action.getDate() != null )
 110  
             {
 111  0
                 serializer.attribute( NAMESPACE, "date", action.getDate() );
 112  
             }
 113  0
             serializer.text( String.valueOf( action.getAction() ));
 114  0
             if ( ( action.getFixedIssues() != null ) && ( action.getFixedIssues().size() > 0 ) )
 115  
             {
 116  0
                 for ( Iterator iter = action.getFixedIssues().iterator(); iter.hasNext(); )
 117  
                 {
 118  0
                     FixedIssue o = (FixedIssue) iter.next();
 119  0
                     writeFixedIssue( o, "fixes", serializer );
 120  0
                 }
 121  
             }
 122  0
             if ( ( action.getDueTos() != null ) && ( action.getDueTos().size() > 0 ) )
 123  
             {
 124  0
                 for ( Iterator iter = action.getDueTos().iterator(); iter.hasNext(); )
 125  
                 {
 126  0
                     DueTo o = (DueTo) iter.next();
 127  0
                     writeDueTo( o, "dueto", serializer );
 128  0
                 }
 129  
             }
 130  0
             serializer.endTag( NAMESPACE, tagName );
 131  
         }
 132  0
     } //-- void writeAction( Action, String, XmlSerializer )
 133  
 
 134  
     /**
 135  
      * Method writeAuthor.
 136  
      * 
 137  
      * @param author
 138  
      * @param serializer
 139  
      * @param tagName
 140  
      * @throws java.io.IOException
 141  
      */
 142  
     private void writeAuthor( Author author, String tagName, XmlSerializer serializer )
 143  
         throws java.io.IOException
 144  
     {
 145  0
         if ( author != null )
 146  
         {
 147  0
             serializer.startTag( NAMESPACE, tagName );
 148  0
             if ( author.getAuthorEmail() != null )
 149  
             {
 150  0
                 serializer.attribute( NAMESPACE, "email", author.getAuthorEmail() );
 151  
             }
 152  0
             serializer.text( String.valueOf( author.getName() ));
 153  0
             serializer.endTag( NAMESPACE, tagName );
 154  
         }
 155  0
     } //-- void writeAuthor( Author, String, XmlSerializer )
 156  
 
 157  
     /**
 158  
      * Method writeBody.
 159  
      * 
 160  
      * @param body
 161  
      * @param serializer
 162  
      * @param tagName
 163  
      * @throws java.io.IOException
 164  
      */
 165  
     private void writeBody( Body body, String tagName, XmlSerializer serializer )
 166  
         throws java.io.IOException
 167  
     {
 168  0
         if ( body != null )
 169  
         {
 170  0
             serializer.startTag( NAMESPACE, tagName );
 171  0
             if ( ( body.getReleases() != null ) && ( body.getReleases().size() > 0 ) )
 172  
             {
 173  0
                 for ( Iterator iter = body.getReleases().iterator(); iter.hasNext(); )
 174  
                 {
 175  0
                     Release o = (Release) iter.next();
 176  0
                     writeRelease( o, "release", serializer );
 177  0
                 }
 178  
             }
 179  0
             serializer.endTag( NAMESPACE, tagName );
 180  
         }
 181  0
     } //-- void writeBody( Body, String, XmlSerializer )
 182  
 
 183  
     /**
 184  
      * Method writeChangesDocument.
 185  
      * 
 186  
      * @param changesDocument
 187  
      * @param serializer
 188  
      * @param tagName
 189  
      * @throws java.io.IOException
 190  
      */
 191  
     private void writeChangesDocument( ChangesDocument changesDocument, String tagName, XmlSerializer serializer )
 192  
         throws java.io.IOException
 193  
     {
 194  0
         if ( changesDocument != null )
 195  
         {
 196  0
             serializer.startTag( NAMESPACE, tagName );
 197  0
             if ( changesDocument.getProperties() != null )
 198  
             {
 199  0
                 writeProperties( (Properties) changesDocument.getProperties(), "properties", serializer );
 200  
             }
 201  0
             if ( changesDocument.getBody() != null )
 202  
             {
 203  0
                 writeBody( (Body) changesDocument.getBody(), "body", serializer );
 204  
             }
 205  0
             serializer.endTag( NAMESPACE, tagName );
 206  
         }
 207  0
     } //-- void writeChangesDocument( ChangesDocument, String, XmlSerializer )
 208  
 
 209  
     /**
 210  
      * Method writeComponent.
 211  
      * 
 212  
      * @param component
 213  
      * @param serializer
 214  
      * @param tagName
 215  
      * @throws java.io.IOException
 216  
      */
 217  
     private void writeComponent( Component component, String tagName, XmlSerializer serializer )
 218  
         throws java.io.IOException
 219  
     {
 220  0
         if ( component != null )
 221  
         {
 222  0
             serializer.startTag( NAMESPACE, tagName );
 223  0
             if ( component.getName() != null )
 224  
             {
 225  0
                 serializer.startTag( NAMESPACE, "name" ).text( component.getName() ).endTag( NAMESPACE, "name" );
 226  
             }
 227  0
             if ( component.getDescription() != null )
 228  
             {
 229  0
                 serializer.startTag( NAMESPACE, "description" ).text( component.getDescription() ).endTag( NAMESPACE, "description" );
 230  
             }
 231  0
             if ( ( component.getActions() != null ) && ( component.getActions().size() > 0 ) )
 232  
             {
 233  0
                 serializer.startTag( NAMESPACE, "actions" );
 234  0
                 for ( Iterator iter = component.getActions().iterator(); iter.hasNext(); )
 235  
                 {
 236  0
                     Action o = (Action) iter.next();
 237  0
                     writeAction( o, "action", serializer );
 238  0
                 }
 239  0
                 serializer.endTag( NAMESPACE, "actions" );
 240  
             }
 241  0
             serializer.endTag( NAMESPACE, tagName );
 242  
         }
 243  0
     } //-- void writeComponent( Component, String, XmlSerializer )
 244  
 
 245  
     /**
 246  
      * Method writeDueTo.
 247  
      * 
 248  
      * @param dueTo
 249  
      * @param serializer
 250  
      * @param tagName
 251  
      * @throws java.io.IOException
 252  
      */
 253  
     private void writeDueTo( DueTo dueTo, String tagName, XmlSerializer serializer )
 254  
         throws java.io.IOException
 255  
     {
 256  0
         if ( dueTo != null )
 257  
         {
 258  0
             serializer.startTag( NAMESPACE, tagName );
 259  0
             if ( dueTo.getName() != null )
 260  
             {
 261  0
                 serializer.attribute( NAMESPACE, "name", dueTo.getName() );
 262  
             }
 263  0
             if ( dueTo.getEmail() != null )
 264  
             {
 265  0
                 serializer.attribute( NAMESPACE, "email", dueTo.getEmail() );
 266  
             }
 267  0
             serializer.endTag( NAMESPACE, tagName );
 268  
         }
 269  0
     } //-- void writeDueTo( DueTo, String, XmlSerializer )
 270  
 
 271  
     /**
 272  
      * Method writeFixedIssue.
 273  
      * 
 274  
      * @param fixedIssue
 275  
      * @param serializer
 276  
      * @param tagName
 277  
      * @throws java.io.IOException
 278  
      */
 279  
     private void writeFixedIssue( FixedIssue fixedIssue, String tagName, XmlSerializer serializer )
 280  
         throws java.io.IOException
 281  
     {
 282  0
         if ( fixedIssue != null )
 283  
         {
 284  0
             serializer.startTag( NAMESPACE, tagName );
 285  0
             if ( fixedIssue.getIssue() != null )
 286  
             {
 287  0
                 serializer.attribute( NAMESPACE, "issue", fixedIssue.getIssue() );
 288  
             }
 289  0
             serializer.endTag( NAMESPACE, tagName );
 290  
         }
 291  0
     } //-- void writeFixedIssue( FixedIssue, String, XmlSerializer )
 292  
 
 293  
     /**
 294  
      * Method writeProperties.
 295  
      * 
 296  
      * @param properties
 297  
      * @param serializer
 298  
      * @param tagName
 299  
      * @throws java.io.IOException
 300  
      */
 301  
     private void writeProperties( Properties properties, String tagName, XmlSerializer serializer )
 302  
         throws java.io.IOException
 303  
     {
 304  0
         if ( properties != null )
 305  
         {
 306  0
             serializer.startTag( NAMESPACE, tagName );
 307  0
             if ( properties.getTitle() != null )
 308  
             {
 309  0
                 serializer.startTag( NAMESPACE, "title" ).text( properties.getTitle() ).endTag( NAMESPACE, "title" );
 310  
             }
 311  0
             if ( properties.getAuthor() != null )
 312  
             {
 313  0
                 writeAuthor( (Author) properties.getAuthor(), "author", serializer );
 314  
             }
 315  0
             serializer.endTag( NAMESPACE, tagName );
 316  
         }
 317  0
     } //-- void writeProperties( Properties, String, XmlSerializer )
 318  
 
 319  
     /**
 320  
      * Method writeRelease.
 321  
      * 
 322  
      * @param release
 323  
      * @param serializer
 324  
      * @param tagName
 325  
      * @throws java.io.IOException
 326  
      */
 327  
     private void writeRelease( Release release, String tagName, XmlSerializer serializer )
 328  
         throws java.io.IOException
 329  
     {
 330  0
         if ( release != null )
 331  
         {
 332  0
             serializer.startTag( NAMESPACE, tagName );
 333  0
             if ( release.getVersion() != null )
 334  
             {
 335  0
                 serializer.attribute( NAMESPACE, "version", release.getVersion() );
 336  
             }
 337  0
             if ( release.getDateRelease() != null )
 338  
             {
 339  0
                 serializer.attribute( NAMESPACE, "date", release.getDateRelease() );
 340  
             }
 341  0
             if ( release.getDescription() != null )
 342  
             {
 343  0
                 serializer.attribute( NAMESPACE, "description", release.getDescription() );
 344  
             }
 345  0
             if ( ( release.getActions() != null ) && ( release.getActions().size() > 0 ) )
 346  
             {
 347  0
                 for ( Iterator iter = release.getActions().iterator(); iter.hasNext(); )
 348  
                 {
 349  0
                     Action o = (Action) iter.next();
 350  0
                     writeAction( o, "action", serializer );
 351  0
                 }
 352  
             }
 353  0
             serializer.endTag( NAMESPACE, tagName );
 354  
         }
 355  0
     } //-- void writeRelease( Release, String, XmlSerializer )
 356  
 
 357  
 
 358  
 }