001/*
002 =================== DO NOT EDIT THIS FILE ====================
003 Generated by Modello 1.1 on 2014-01-07 00:11:24,
004 any modifications will be overwritten.
005 ==============================================================
006 */
007
008package org.apache.maven.scm.providers.gitlib.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.gitlib.settings.Settings;
019import org.codehaus.plexus.util.xml.pull.MXSerializer;
020import org.codehaus.plexus.util.xml.pull.XmlSerializer;
021
022/**
023 * Class GitXpp3Writer.
024 * 
025 * @version $Revision$ $Date$
026 */
027@SuppressWarnings( "all" )
028public class GitXpp3Writer
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, "git-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/GIT/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/GIT/1.0.0 http://maven.apache.org/xsd/scm-git-1.0.0.xsd" );
081            if ( ( settings.getRevParseDateFormat() != null ) && !settings.getRevParseDateFormat().equals( "yyyy-MM-dd HH:mm:ss" ) )
082            {
083                serializer.startTag( NAMESPACE, "revParseDateFormat" ).text( settings.getRevParseDateFormat() ).endTag( NAMESPACE, "revParseDateFormat" );
084            }
085            if ( ( settings.getTraceGitCommand() != null ) && !settings.getTraceGitCommand().equals( "" ) )
086            {
087                serializer.startTag( NAMESPACE, "traceGitCommand" ).text( settings.getTraceGitCommand() ).endTag( NAMESPACE, "traceGitCommand" );
088            }
089            if ( settings.isCommitNoVerify() != false )
090            {
091                serializer.startTag( NAMESPACE, "commitNoVerify" ).text( String.valueOf( settings.isCommitNoVerify() ) ).endTag( NAMESPACE, "commitNoVerify" );
092            }
093            serializer.endTag( NAMESPACE, tagName );
094        }
095    } //-- void writeSettings( Settings, String, XmlSerializer )
096
097}