001/*
002 Licensed to the Apache Software Foundation (ASF) under one
003 or more contributor license agreements.  See the NOTICE file
004 distributed with this work for additional information
005 regarding copyright ownership.  The ASF licenses this file
006 to you under the Apache License, Version 2.0 (the
007 "License"); you may not use this file except in compliance
008 with the License.  You may obtain a copy of the License at
009 
010     http://www.apache.org/licenses/LICENSE-2.0
011 
012 Unless required by applicable law or agreed to in writing,
013 software distributed under the License is distributed on an
014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 KIND, either express or implied.  See the License for the
016 specific language governing permissions and limitations
017 under the License.
018 =================== DO NOT EDIT THIS FILE ====================
019 Generated by Modello 2.5.1,
020 any modifications will be overwritten.
021 ==============================================================
022 */
023
024package org.apache.maven.scm.providers.svn.settings.io.xpp3;
025
026  //---------------------------------/
027 //- Imported classes and packages -/
028//---------------------------------/
029
030import java.io.OutputStream;
031import java.io.Writer;
032import java.util.Iterator;
033import org.apache.maven.scm.providers.svn.settings.Settings;
034import org.codehaus.plexus.util.xml.pull.MXSerializer;
035import org.codehaus.plexus.util.xml.pull.XmlSerializer;
036
037/**
038 * Class SvnXpp3Writer.
039 * 
040 * @version $Revision$ $Date$
041 */
042@SuppressWarnings( "all" )
043public class SvnXpp3Writer
044{
045
046      //--------------------------/
047     //- Class/Member Variables -/
048    //--------------------------/
049
050    /**
051     * Field NAMESPACE.
052     */
053    private static final String NAMESPACE = null;
054
055    /**
056     * Field fileComment.
057     */
058    private String fileComment = null;
059
060
061      //-----------/
062     //- Methods -/
063    //-----------/
064
065    /**
066     * Method setFileComment.
067     * 
068     * @param fileComment a fileComment object.
069     */
070    public void setFileComment( String fileComment )
071    {
072        this.fileComment = fileComment;
073    } //-- void setFileComment( String )
074
075    /**
076     * Method write.
077     * 
078     * @param writer a writer object.
079     * @param settings a settings object.
080     * @throws java.io.IOException java.io.IOException if any.
081     */
082    public void write( Writer writer, Settings settings )
083        throws java.io.IOException
084    {
085        XmlSerializer serializer = new MXSerializer();
086        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
087        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
088        serializer.setOutput( writer );
089        serializer.startDocument( settings.getModelEncoding(), null );
090        writeSettings( settings, "svn-settings", serializer );
091        serializer.endDocument();
092    } //-- void write( Writer, Settings )
093
094    /**
095     * Method write.
096     * 
097     * @param stream a stream object.
098     * @param settings a settings object.
099     * @throws java.io.IOException java.io.IOException if any.
100     */
101    public void write( OutputStream stream, Settings settings )
102        throws java.io.IOException
103    {
104        XmlSerializer serializer = new MXSerializer();
105        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
106        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
107        serializer.setOutput( stream, settings.getModelEncoding() );
108        serializer.startDocument( settings.getModelEncoding(), null );
109        writeSettings( settings, "svn-settings", serializer );
110        serializer.endDocument();
111    } //-- void write( OutputStream, Settings )
112
113    /**
114     * Method writeSettings.
115     * 
116     * @param settings a settings object.
117     * @param serializer a serializer object.
118     * @param tagName a tagName object.
119     * @throws java.io.IOException java.io.IOException if any.
120     */
121    private void writeSettings( Settings settings, String tagName, XmlSerializer serializer )
122        throws java.io.IOException
123    {
124        if ( this.fileComment != null )
125        {
126        serializer.comment(this.fileComment);
127        }
128        serializer.setPrefix( "", "http://maven.apache.org/SCM/SVN/2.1.2" );
129        serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
130        serializer.startTag( NAMESPACE, tagName );
131        serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/SVN/2.1.2 https://maven.apache.org/xsd/svn-settings-2.1.2.xsd" );
132        if ( settings.getConfigDirectory() != null )
133        {
134            serializer.startTag( NAMESPACE, "configDirectory" ).text( settings.getConfigDirectory() ).endTag( NAMESPACE, "configDirectory" );
135        }
136        if ( settings.isUseCygwinPath() != false )
137        {
138            serializer.startTag( NAMESPACE, "useCygwinPath" ).text( String.valueOf( settings.isUseCygwinPath() ) ).endTag( NAMESPACE, "useCygwinPath" );
139        }
140        if ( ( settings.getCygwinMountPath() != null ) && !settings.getCygwinMountPath().equals( "/cygwin" ) )
141        {
142            serializer.startTag( NAMESPACE, "cygwinMountPath" ).text( settings.getCygwinMountPath() ).endTag( NAMESPACE, "cygwinMountPath" );
143        }
144        if ( settings.isUseNonInteractive() != false )
145        {
146            serializer.startTag( NAMESPACE, "useNonInteractive" ).text( String.valueOf( settings.isUseNonInteractive() ) ).endTag( NAMESPACE, "useNonInteractive" );
147        }
148        if ( settings.isUseAuthCache() != false )
149        {
150            serializer.startTag( NAMESPACE, "useAuthCache" ).text( String.valueOf( settings.isUseAuthCache() ) ).endTag( NAMESPACE, "useAuthCache" );
151        }
152        if ( settings.isTrustServerCert() != false )
153        {
154            serializer.startTag( NAMESPACE, "trustServerCert" ).text( String.valueOf( settings.isTrustServerCert() ) ).endTag( NAMESPACE, "trustServerCert" );
155        }
156        serializer.endTag( NAMESPACE, tagName );
157    } //-- void writeSettings( Settings, String, XmlSerializer )
158
159}