View Javadoc
1   /*
2    Licensed to the Apache Software Foundation (ASF) under one
3    or more contributor license agreements.  See the NOTICE file
4    distributed with this work for additional information
5    regarding copyright ownership.  The ASF licenses this file
6    to you under the Apache License, Version 2.0 (the
7    "License"); you may not use this file except in compliance
8    with the License.  You may obtain a copy of the License at
9    
10       http://www.apache.org/licenses/LICENSE-2.0
11   
12   Unless required by applicable law or agreed to in writing,
13   software distributed under the License is distributed on an
14   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   KIND, either express or implied.  See the License for the
16   specific language governing permissions and limitations
17   under the License.
18   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.5.1,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.scm.providers.gitlib.settings.io.xpp3;
25  
26    //---------------------------------/
27   //- Imported classes and packages -/
28  //---------------------------------/
29  
30  import java.io.OutputStream;
31  import java.io.Writer;
32  import java.util.Iterator;
33  import org.apache.maven.scm.providers.gitlib.settings.Settings;
34  import org.codehaus.plexus.util.xml.pull.MXSerializer;
35  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
36  
37  /**
38   * Class GitXpp3Writer.
39   * 
40   * @version $Revision$ $Date$
41   */
42  @SuppressWarnings( "all" )
43  public class GitXpp3Writer
44  {
45  
46        //--------------------------/
47       //- Class/Member Variables -/
48      //--------------------------/
49  
50      /**
51       * Field NAMESPACE.
52       */
53      private static final String NAMESPACE = null;
54  
55      /**
56       * Field fileComment.
57       */
58      private String fileComment = null;
59  
60  
61        //-----------/
62       //- Methods -/
63      //-----------/
64  
65      /**
66       * Method setFileComment.
67       * 
68       * @param fileComment a fileComment object.
69       */
70      public void setFileComment( String fileComment )
71      {
72          this.fileComment = fileComment;
73      } //-- void setFileComment( String )
74  
75      /**
76       * Method write.
77       * 
78       * @param writer a writer object.
79       * @param settings a settings object.
80       * @throws java.io.IOException java.io.IOException if any.
81       */
82      public void write( Writer writer, Settings settings )
83          throws java.io.IOException
84      {
85          XmlSerializer serializer = new MXSerializer();
86          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
87          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
88          serializer.setOutput( writer );
89          serializer.startDocument( settings.getModelEncoding(), null );
90          writeSettings( settings, "git-settings", serializer );
91          serializer.endDocument();
92      } //-- void write( Writer, Settings )
93  
94      /**
95       * Method write.
96       * 
97       * @param stream a stream object.
98       * @param settings a settings object.
99       * @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, "git-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/GIT/1.1.0" );
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/GIT/1.1.0 https://maven.apache.org/xsd/scm-git-1.1.0.xsd" );
132         if ( ( settings.getRevParseDateFormat() != null ) && !settings.getRevParseDateFormat().equals( "yyyy-MM-dd HH:mm:ss" ) )
133         {
134             serializer.startTag( NAMESPACE, "revParseDateFormat" ).text( settings.getRevParseDateFormat() ).endTag( NAMESPACE, "revParseDateFormat" );
135         }
136         if ( ( settings.getTraceGitCommand() != null ) && !settings.getTraceGitCommand().equals( "" ) )
137         {
138             serializer.startTag( NAMESPACE, "traceGitCommand" ).text( settings.getTraceGitCommand() ).endTag( NAMESPACE, "traceGitCommand" );
139         }
140         if ( ( settings.getGitCommand() != null ) && !settings.getGitCommand().equals( "git" ) )
141         {
142             serializer.startTag( NAMESPACE, "gitCommand" ).text( settings.getGitCommand() ).endTag( NAMESPACE, "gitCommand" );
143         }
144         if ( settings.isCommitNoVerify() != false )
145         {
146             serializer.startTag( NAMESPACE, "commitNoVerify" ).text( String.valueOf( settings.isCommitNoVerify() ) ).endTag( NAMESPACE, "commitNoVerify" );
147         }
148         serializer.endTag( NAMESPACE, tagName );
149     } //-- void writeSettings( Settings, String, XmlSerializer )
150 
151 }