001// =================== DO NOT EDIT THIS FILE ====================
002// Generated by Modello 1.9.1,
003// any modifications will be overwritten.
004// ==============================================================
005
006package org.apache.maven.scm.providers.cvslib.settings.io.xpp3;
007
008  //---------------------------------/
009 //- Imported classes and packages -/
010//---------------------------------/
011
012import java.io.OutputStream;
013import java.io.Writer;
014import java.util.Iterator;
015import org.apache.maven.scm.providers.cvslib.settings.Settings;
016import org.codehaus.plexus.util.xml.pull.MXSerializer;
017import org.codehaus.plexus.util.xml.pull.XmlSerializer;
018
019/**
020 * Class CvsXpp3Writer.
021 * 
022 * @version $Revision$ $Date$
023 */
024@SuppressWarnings( "all" )
025public class CvsXpp3Writer
026{
027
028      //--------------------------/
029     //- Class/Member Variables -/
030    //--------------------------/
031
032    /**
033     * Field NAMESPACE.
034     */
035    private static final String NAMESPACE = null;
036
037    /**
038     * Field fileComment.
039     */
040    private String fileComment = null;
041
042
043      //-----------/
044     //- Methods -/
045    //-----------/
046
047    /**
048     * Method setFileComment.
049     * 
050     * @param fileComment
051     */
052    public void setFileComment( String fileComment )
053    {
054        this.fileComment = fileComment;
055    } //-- void setFileComment( String )
056
057    /**
058     * Method write.
059     * 
060     * @param writer
061     * @param settings
062     * @throws java.io.IOException
063     */
064    public void write( Writer writer, Settings settings )
065        throws java.io.IOException
066    {
067        XmlSerializer serializer = new MXSerializer();
068        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
069        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
070        serializer.setOutput( writer );
071        serializer.startDocument( settings.getModelEncoding(), null );
072        writeSettings( settings, "cvs-settings", serializer );
073        serializer.endDocument();
074    } //-- void write( Writer, Settings )
075
076    /**
077     * Method write.
078     * 
079     * @param stream
080     * @param settings
081     * @throws java.io.IOException
082     */
083    public void write( OutputStream stream, Settings settings )
084        throws java.io.IOException
085    {
086        XmlSerializer serializer = new MXSerializer();
087        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
088        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
089        serializer.setOutput( stream, settings.getModelEncoding() );
090        serializer.startDocument( settings.getModelEncoding(), null );
091        writeSettings( settings, "cvs-settings", serializer );
092        serializer.endDocument();
093    } //-- void write( OutputStream, Settings )
094
095    /**
096     * Method writeSettings.
097     * 
098     * @param settings
099     * @param serializer
100     * @param tagName
101     * @throws java.io.IOException
102     */
103    private void writeSettings( Settings settings, String tagName, XmlSerializer serializer )
104        throws java.io.IOException
105    {
106        if ( this.fileComment != null )
107        {
108        serializer.comment(this.fileComment);
109        }
110        serializer.setPrefix( "", "http://maven.apache.org/SCM/CVS/1.0.0" );
111        serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
112        serializer.startTag( NAMESPACE, tagName );
113        serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/CVS/1.0.0 http://maven.apache.org/xsd/scm-cvs-1.0.0.xsd" );
114        if ( ( settings.getChangeLogCommandDateFormat() != null ) && !settings.getChangeLogCommandDateFormat().equals( "yyyy-MM-dd HH:mm:ssZ" ) )
115        {
116            serializer.startTag( NAMESPACE, "changeLogCommandDateFormat" ).text( settings.getChangeLogCommandDateFormat() ).endTag( NAMESPACE, "changeLogCommandDateFormat" );
117        }
118        if ( settings.isUseCvsrc() != false )
119        {
120            serializer.startTag( NAMESPACE, "useCvsrc" ).text( String.valueOf( settings.isUseCvsrc() ) ).endTag( NAMESPACE, "useCvsrc" );
121        }
122        if ( settings.getCompressionLevel() != 3 )
123        {
124            serializer.startTag( NAMESPACE, "compressionLevel" ).text( String.valueOf( settings.getCompressionLevel() ) ).endTag( NAMESPACE, "compressionLevel" );
125        }
126        if ( settings.isTraceCvsCommand() != false )
127        {
128            serializer.startTag( NAMESPACE, "traceCvsCommand" ).text( String.valueOf( settings.isTraceCvsCommand() ) ).endTag( NAMESPACE, "traceCvsCommand" );
129        }
130        if ( settings.getTemporaryFilesDirectory() != null )
131        {
132            serializer.startTag( NAMESPACE, "temporaryFilesDirectory" ).text( settings.getTemporaryFilesDirectory() ).endTag( NAMESPACE, "temporaryFilesDirectory" );
133        }
134        if ( ( settings.getCvsVariables() != null ) && ( settings.getCvsVariables().size() > 0 ) )
135        {
136            serializer.startTag( NAMESPACE, "cvsVariables" );
137            for ( Iterator iter = settings.getCvsVariables().keySet().iterator(); iter.hasNext(); )
138            {
139                String key = (String) iter.next();
140                String value = (String) settings.getCvsVariables().get( key );
141                serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" );
142            }
143            serializer.endTag( NAMESPACE, "cvsVariables" );
144        }
145        if ( settings.isUseForceTag() != true )
146        {
147            serializer.startTag( NAMESPACE, "useForceTag" ).text( String.valueOf( settings.isUseForceTag() ) ).endTag( NAMESPACE, "useForceTag" );
148        }
149        serializer.endTag( NAMESPACE, tagName );
150    } //-- void writeSettings( Settings, String, XmlSerializer )
151
152}