1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.scm.provider.local.metadata.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.provider.local.metadata.LocalScmMetadata; |
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 | 0 | public class LocalScmMetadataXpp3Writer |
29 | |
{ |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | 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, LocalScmMetadata localScmMetadata ) |
53 | |
throws java.io.IOException |
54 | |
{ |
55 | 0 | XmlSerializer serializer = new MXSerializer(); |
56 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); |
57 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); |
58 | 0 | serializer.setOutput( writer ); |
59 | 0 | serializer.startDocument( localScmMetadata.getModelEncoding(), null ); |
60 | 0 | writeLocalScmMetadata( localScmMetadata, "localScmMetadata", serializer ); |
61 | 0 | serializer.endDocument(); |
62 | 0 | } |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
private void writeLocalScmMetadata( LocalScmMetadata localScmMetadata, String tagName, XmlSerializer serializer ) |
73 | |
throws java.io.IOException |
74 | |
{ |
75 | 0 | if ( localScmMetadata != null ) |
76 | |
{ |
77 | 0 | serializer.setPrefix( "", "http://maven.apache.org/SCM/LOCAL/1.0.0" ); |
78 | 0 | serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); |
79 | 0 | serializer.startTag( NAMESPACE, tagName ); |
80 | 0 | serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/SCM/LOCAL/1.0.0 http://maven.apache.org/xsd/scm-local-1.0.0.xsd" ); |
81 | 0 | if ( ( localScmMetadata.getRepositoryFileNames() != null ) && ( localScmMetadata.getRepositoryFileNames().size() > 0 ) ) |
82 | |
{ |
83 | 0 | serializer.startTag( NAMESPACE, "repositoryFileNames" ); |
84 | 0 | for ( Iterator iter = localScmMetadata.getRepositoryFileNames().iterator(); iter.hasNext(); ) |
85 | |
{ |
86 | 0 | String repositoryFileName = (String) iter.next(); |
87 | 0 | serializer.startTag( NAMESPACE, "repositoryFileName" ).text( repositoryFileName ).endTag( NAMESPACE, "repositoryFileName" ); |
88 | 0 | } |
89 | 0 | serializer.endTag( NAMESPACE, "repositoryFileNames" ); |
90 | |
} |
91 | 0 | serializer.endTag( NAMESPACE, tagName ); |
92 | |
} |
93 | 0 | } |
94 | |
|
95 | |
} |