001/*
002 =================== DO NOT EDIT THIS FILE ====================
003 Generated by Modello 1.1 on 2014-01-07 00:11:23,
004 any modifications will be overwritten.
005 ==============================================================
006 */
007
008package org.apache.maven.scm.providers.cvslib.settings.io.xpp3;
009
010  //---------------------------------/
011 //- Imported classes and packages -/
012//---------------------------------/
013
014import java.io.Writer;
015import java.text.DateFormat;
016import java.util.Iterator;
017import java.util.Locale;
018import org.apache.maven.scm.providers.cvslib.settings.Settings;
019import org.codehaus.plexus.util.xml.pull.MXSerializer;
020import org.codehaus.plexus.util.xml.pull.XmlSerializer;
021
022/**
023 * Class CvsXpp3Writer.
024 * 
025 * @version $Revision$ $Date$
026 */
027@SuppressWarnings( "all" )
028public class CvsXpp3Writer
029{
030
031      //--------------------------/
032     //- Class/Member Variables -/
033    //--------------------------/
034
035    /**
036     * Field NAMESPACE.
037     */
038    private static final String NAMESPACE = null;
039
040
041      //-----------/
042     //- Methods -/
043    //-----------/
044
045    /**
046     * Method write.
047     * 
048     * @param writer
049     * @param settings
050     * @throws java.io.IOException
051     */
052    public void write( Writer writer, Settings settings )
053        throws java.io.IOException
054    {
055        XmlSerializer serializer = new MXSerializer();
056        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
057        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
058        serializer.setOutput( writer );
059        serializer.startDocument( settings.getModelEncoding(), null );
060        writeSettings( settings, "cvs-settings", serializer );
061        serializer.endDocument();
062    } //-- void write( Writer, Settings )
063
064    /**
065     * Method writeSettings.
066     * 
067     * @param settings
068     * @param serializer
069     * @param tagName
070     * @throws java.io.IOException
071     */
072    private void writeSettings( Settings settings, String tagName, XmlSerializer serializer )
073        throws java.io.IOException
074    {
075        if ( settings != null )
076        {
077            serializer.setPrefix( "", "http://maven.apache.org/SCM/CVS/1.0.0" );
078            serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
079            serializer.startTag( NAMESPACE, tagName );
080            serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/CVS/1.0.0 http://maven.apache.org/xsd/scm-cvs-1.0.0.xsd" );
081            if ( ( settings.getChangeLogCommandDateFormat() != null ) && !settings.getChangeLogCommandDateFormat().equals( "yyyy-MM-dd HH:mm:ssZ" ) )
082            {
083                serializer.startTag( NAMESPACE, "changeLogCommandDateFormat" ).text( settings.getChangeLogCommandDateFormat() ).endTag( NAMESPACE, "changeLogCommandDateFormat" );
084            }
085            if ( settings.isUseCvsrc() != false )
086            {
087                serializer.startTag( NAMESPACE, "useCvsrc" ).text( String.valueOf( settings.isUseCvsrc() ) ).endTag( NAMESPACE, "useCvsrc" );
088            }
089            if ( settings.getCompressionLevel() != 3 )
090            {
091                serializer.startTag( NAMESPACE, "compressionLevel" ).text( String.valueOf( settings.getCompressionLevel() ) ).endTag( NAMESPACE, "compressionLevel" );
092            }
093            if ( settings.isTraceCvsCommand() != false )
094            {
095                serializer.startTag( NAMESPACE, "traceCvsCommand" ).text( String.valueOf( settings.isTraceCvsCommand() ) ).endTag( NAMESPACE, "traceCvsCommand" );
096            }
097            if ( settings.getTemporaryFilesDirectory() != null )
098            {
099                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}