1
2
3
4
5
6
7
8 package org.apache.maven.scm.providers.svn.settings.io.xpp3;
9
10
11
12
13
14 import java.io.Writer;
15 import java.text.DateFormat;
16 import java.util.Iterator;
17 import java.util.Locale;
18 import org.apache.maven.scm.providers.svn.settings.Settings;
19 import org.codehaus.plexus.util.xml.pull.MXSerializer;
20 import org.codehaus.plexus.util.xml.pull.XmlSerializer;
21
22
23
24
25
26
27 @SuppressWarnings( "all" )
28 public class SvnXpp3Writer
29 {
30
31
32
33
34
35
36
37
38 private static final String NAMESPACE = null;
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public void write( Writer writer, Settings settings )
53 throws java.io.IOException
54 {
55 XmlSerializer serializer = new MXSerializer();
56 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " );
57 serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
58 serializer.setOutput( writer );
59 serializer.startDocument( settings.getModelEncoding(), null );
60 writeSettings( settings, "svn-settings", serializer );
61 serializer.endDocument();
62 }
63
64
65
66
67
68
69
70
71
72 private void writeSettings( Settings settings, String tagName, XmlSerializer serializer )
73 throws java.io.IOException
74 {
75 if ( settings != null )
76 {
77 serializer.setPrefix( "", "http://maven.apache.org/SCM/SVN/1.1.0" );
78 serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
79 serializer.startTag( NAMESPACE, tagName );
80 serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/SVN/1.1.0 http://maven.apache.org/xsd/svn-settings-1.1.0.xsd" );
81 if ( settings.getConfigDirectory() != null )
82 {
83 serializer.startTag( NAMESPACE, "configDirectory" ).text( settings.getConfigDirectory() ).endTag( NAMESPACE, "configDirectory" );
84 }
85 if ( settings.isUseCygwinPath() != false )
86 {
87 serializer.startTag( NAMESPACE, "useCygwinPath" ).text( String.valueOf( settings.isUseCygwinPath() ) ).endTag( NAMESPACE, "useCygwinPath" );
88 }
89 if ( ( settings.getCygwinMountPath() != null ) && !settings.getCygwinMountPath().equals( "/cygwin" ) )
90 {
91 serializer.startTag( NAMESPACE, "cygwinMountPath" ).text( settings.getCygwinMountPath() ).endTag( NAMESPACE, "cygwinMountPath" );
92 }
93 if ( settings.isUseNonInteractive() != true )
94 {
95 serializer.startTag( NAMESPACE, "useNonInteractive" ).text( String.valueOf( settings.isUseNonInteractive() ) ).endTag( NAMESPACE, "useNonInteractive" );
96 }
97 if ( settings.isUseAuthCache() != false )
98 {
99 serializer.startTag( NAMESPACE, "useAuthCache" ).text( String.valueOf( settings.isUseAuthCache() ) ).endTag( NAMESPACE, "useAuthCache" );
100 }
101 if ( settings.isTrustServerCert() != false )
102 {
103 serializer.startTag( NAMESPACE, "trustServerCert" ).text( String.valueOf( settings.isTrustServerCert() ) ).endTag( NAMESPACE, "trustServerCert" );
104 }
105 serializer.endTag( NAMESPACE, tagName );
106 }
107 }
108
109 }