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