Coverage Report - org.apache.maven.plugin.resources.remote.io.xpp3.RemoteResourcesBundleXpp3Writer
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteResourcesBundleXpp3Writer
76%
25/33
75%
6/8
0
 
 1  
 /*
 2  
  =================== DO NOT EDIT THIS FILE ====================
 3  
  Generated by Modello 1.4.1 on 2011-06-14 21:26:10,
 4  
  any modifications will be overwritten.
 5  
  ==============================================================
 6  
  */
 7  
 
 8  
 package org.apache.maven.plugin.resources.remote.io.xpp3;
 9  
 
 10  
   //---------------------------------/
 11  
  //- Imported classes and packages -/
 12  
 //---------------------------------/
 13  
 
 14  
 import java.io.OutputStream;
 15  
 import java.io.Writer;
 16  
 import java.text.DateFormat;
 17  
 import java.util.Iterator;
 18  
 import java.util.Locale;
 19  
 import org.apache.maven.plugin.resources.remote.RemoteResourcesBundle;
 20  
 import org.codehaus.plexus.util.xml.pull.MXSerializer;
 21  
 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
 22  
 
 23  
 /**
 24  
  * Class RemoteResourcesBundleXpp3Writer.
 25  
  * 
 26  
  * @version $Revision: 816514 $ $Date: 2012-05-08 11:24:24 +0000 (Tue, 08 May 2012) $
 27  
  */
 28  
 @SuppressWarnings( "all" )
 29  6
 public class RemoteResourcesBundleXpp3Writer
 30  
 {
 31  
 
 32  
       //--------------------------/
 33  
      //- Class/Member Variables -/
 34  
     //--------------------------/
 35  
 
 36  
     /**
 37  
      * Field NAMESPACE.
 38  
      */
 39  1
     private static final String NAMESPACE = null;
 40  
 
 41  
 
 42  
       //-----------/
 43  
      //- Methods -/
 44  
     //-----------/
 45  
 
 46  
     /**
 47  
      * Method write.
 48  
      * 
 49  
      * @param writer
 50  
      * @param remoteResourcesBundle
 51  
      * @throws java.io.IOException
 52  
      */
 53  
     public void write( Writer writer, RemoteResourcesBundle remoteResourcesBundle )
 54  
         throws java.io.IOException
 55  
     {
 56  6
         XmlSerializer serializer = new MXSerializer();
 57  6
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
 58  6
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
 59  6
         serializer.setOutput( writer );
 60  6
         serializer.startDocument( remoteResourcesBundle.getModelEncoding(), null );
 61  6
         writeRemoteResourcesBundle( remoteResourcesBundle, "remoteResourcesBundle", serializer );
 62  6
         serializer.endDocument();
 63  6
     } //-- void write( Writer, RemoteResourcesBundle )
 64  
 
 65  
     /**
 66  
      * Method write.
 67  
      * 
 68  
      * @param stream
 69  
      * @param remoteResourcesBundle
 70  
      * @throws java.io.IOException
 71  
      */
 72  
     public void write( OutputStream stream, RemoteResourcesBundle remoteResourcesBundle )
 73  
         throws java.io.IOException
 74  
     {
 75  0
         XmlSerializer serializer = new MXSerializer();
 76  0
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
 77  0
         serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
 78  0
         serializer.setOutput( stream, remoteResourcesBundle.getModelEncoding() );
 79  0
         serializer.startDocument( remoteResourcesBundle.getModelEncoding(), null );
 80  0
         writeRemoteResourcesBundle( remoteResourcesBundle, "remoteResourcesBundle", serializer );
 81  0
         serializer.endDocument();
 82  0
     } //-- void write( OutputStream, RemoteResourcesBundle )
 83  
 
 84  
     /**
 85  
      * Method writeRemoteResourcesBundle.
 86  
      * 
 87  
      * @param remoteResourcesBundle
 88  
      * @param serializer
 89  
      * @param tagName
 90  
      * @throws java.io.IOException
 91  
      */
 92  
     private void writeRemoteResourcesBundle( RemoteResourcesBundle remoteResourcesBundle, String tagName, XmlSerializer serializer )
 93  
         throws java.io.IOException
 94  
     {
 95  6
         serializer.setPrefix( "", "http://maven.apache.org/remote-resources/1.1.0" );
 96  6
         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
 97  6
         serializer.startTag( NAMESPACE, tagName );
 98  6
         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/remote-resources/1.1.0 http://maven.apache.org/xsd/remote-resources-1.1.0.xsd" );
 99  6
         if ( ( remoteResourcesBundle.getRemoteResources() != null ) && ( remoteResourcesBundle.getRemoteResources().size() > 0 ) )
 100  
         {
 101  6
             serializer.startTag( NAMESPACE, "remoteResources" );
 102  6
             for ( Iterator iter = remoteResourcesBundle.getRemoteResources().iterator(); iter.hasNext(); )
 103  
             {
 104  6
                 String remoteResource = (String) iter.next();
 105  6
                 serializer.startTag( NAMESPACE, "remoteResource" ).text( remoteResource ).endTag( NAMESPACE, "remoteResource" );
 106  6
             }
 107  6
             serializer.endTag( NAMESPACE, "remoteResources" );
 108  
         }
 109  6
         if ( remoteResourcesBundle.getSourceEncoding() != null )
 110  
         {
 111  2
             serializer.startTag( NAMESPACE, "sourceEncoding" ).text( remoteResourcesBundle.getSourceEncoding() ).endTag( NAMESPACE, "sourceEncoding" );
 112  
         }
 113  6
         serializer.endTag( NAMESPACE, tagName );
 114  6
     } //-- void writeRemoteResourcesBundle( RemoteResourcesBundle, String, XmlSerializer )
 115  
 
 116  
 }