View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello 1.1 on 2014-01-07 00:11:23,
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.scm.providers.cvslib.settings.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.scm.providers.cvslib.settings.Settings;
19  import org.codehaus.plexus.util.xml.pull.MXSerializer;
20  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
21  
22  /**
23   * Class CvsXpp3Writer.
24   * 
25   * @version $Revision$ $Date$
26   */
27  @SuppressWarnings( "all" )
28  public class CvsXpp3Writer
29  {
30  
31        //--------------------------/
32       //- Class/Member Variables -/
33      //--------------------------/
34  
35      /**
36       * Field NAMESPACE.
37       */
38      private static final String NAMESPACE = null;
39  
40  
41        //-----------/
42       //- Methods -/
43      //-----------/
44  
45      /**
46       * Method write.
47       * 
48       * @param writer
49       * @param settings
50       * @throws java.io.IOException
51       */
52      public void write( Writer writer, Settings settings )
53          throws java.io.IOException
54      {
55          XmlSerializer serializer = new MXSerializer();
56          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
57          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
58          serializer.setOutput( writer );
59          serializer.startDocument( settings.getModelEncoding(), null );
60          writeSettings( settings, "cvs-settings", serializer );
61          serializer.endDocument();
62      } //-- void write( Writer, Settings )
63  
64      /**
65       * Method writeSettings.
66       * 
67       * @param settings
68       * @param serializer
69       * @param tagName
70       * @throws java.io.IOException
71       */
72      private void writeSettings( Settings settings, String tagName, XmlSerializer serializer )
73          throws java.io.IOException
74      {
75          if ( settings != null )
76          {
77              serializer.setPrefix( "", "http://maven.apache.org/SCM/CVS/1.0.0" );
78              serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
79              serializer.startTag( NAMESPACE, tagName );
80              serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/CVS/1.0.0 http://maven.apache.org/xsd/scm-cvs-1.0.0.xsd" );
81              if ( ( settings.getChangeLogCommandDateFormat() != null ) && !settings.getChangeLogCommandDateFormat().equals( "yyyy-MM-dd HH:mm:ssZ" ) )
82              {
83                  serializer.startTag( NAMESPACE, "changeLogCommandDateFormat" ).text( settings.getChangeLogCommandDateFormat() ).endTag( NAMESPACE, "changeLogCommandDateFormat" );
84              }
85              if ( settings.isUseCvsrc() != false )
86              {
87                  serializer.startTag( NAMESPACE, "useCvsrc" ).text( String.valueOf( settings.isUseCvsrc() ) ).endTag( NAMESPACE, "useCvsrc" );
88              }
89              if ( settings.getCompressionLevel() != 3 )
90              {
91                  serializer.startTag( NAMESPACE, "compressionLevel" ).text( String.valueOf( settings.getCompressionLevel() ) ).endTag( NAMESPACE, "compressionLevel" );
92              }
93              if ( settings.isTraceCvsCommand() != false )
94              {
95                  serializer.startTag( NAMESPACE, "traceCvsCommand" ).text( String.valueOf( settings.isTraceCvsCommand() ) ).endTag( NAMESPACE, "traceCvsCommand" );
96              }
97              if ( settings.getTemporaryFilesDirectory() != null )
98              {
99                  serializer.startTag( NAMESPACE, "temporaryFilesDirectory" ).text( settings.getTemporaryFilesDirectory() ).endTag( NAMESPACE, "temporaryFilesDirectory" );
100             }
101             if ( ( settings.getCvsVariables() != null ) && ( settings.getCvsVariables().size() > 0 ) )
102             {
103                 serializer.startTag( NAMESPACE, "cvsVariables" );
104                 for ( Iterator iter = settings.getCvsVariables().keySet().iterator(); iter.hasNext(); )
105                 {
106                     String key = (String) iter.next();
107                     String value = (String) settings.getCvsVariables().get( key );
108                     serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" );
109                 }
110                 serializer.endTag( NAMESPACE, "cvsVariables" );
111             }
112             if ( settings.isUseForceTag() != true )
113             {
114                 serializer.startTag( NAMESPACE, "useForceTag" ).text( String.valueOf( settings.isUseForceTag() ) ).endTag( NAMESPACE, "useForceTag" );
115             }
116             serializer.endTag( NAMESPACE, tagName );
117         }
118     } //-- void writeSettings( Settings, String, XmlSerializer )
119 
120 }