1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
package org.apache.maven.plugin.invoker.model.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.plugin.invoker.model.BuildJob; |
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 | 0 | public class BuildJobXpp3Writer |
28 | |
{ |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | private static final String NAMESPACE = null; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
public void write( Writer writer, BuildJob buildJob ) |
52 | |
throws java.io.IOException |
53 | |
{ |
54 | 0 | XmlSerializer serializer = new MXSerializer(); |
55 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); |
56 | 0 | serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); |
57 | 0 | serializer.setOutput( writer ); |
58 | 0 | serializer.startDocument( buildJob.getModelEncoding(), null ); |
59 | 0 | writeBuildJob( buildJob, "build-job", serializer ); |
60 | 0 | serializer.endDocument(); |
61 | 0 | } |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
private void writeBuildJob( BuildJob buildJob, String tagName, XmlSerializer serializer ) |
72 | |
throws java.io.IOException |
73 | |
{ |
74 | 0 | if ( buildJob != null ) |
75 | |
{ |
76 | 0 | serializer.startTag( NAMESPACE, tagName ); |
77 | 0 | if ( buildJob.getProject() != null ) |
78 | |
{ |
79 | 0 | serializer.attribute( NAMESPACE, "project", buildJob.getProject() ); |
80 | |
} |
81 | 0 | if ( buildJob.getName() != null ) |
82 | |
{ |
83 | 0 | serializer.attribute( NAMESPACE, "name", buildJob.getName() ); |
84 | |
} |
85 | 0 | if ( buildJob.getDescription() != null ) |
86 | |
{ |
87 | 0 | serializer.attribute( NAMESPACE, "description", buildJob.getDescription() ); |
88 | |
} |
89 | 0 | if ( buildJob.getResult() != null ) |
90 | |
{ |
91 | 0 | serializer.attribute( NAMESPACE, "result", buildJob.getResult() ); |
92 | |
} |
93 | 0 | if ( buildJob.getTime() != 0.0 ) |
94 | |
{ |
95 | 0 | serializer.attribute( NAMESPACE, "time", String.valueOf( buildJob.getTime() ) ); |
96 | |
} |
97 | 0 | if ( buildJob.getType() != null ) |
98 | |
{ |
99 | 0 | serializer.attribute( NAMESPACE, "type", buildJob.getType() ); |
100 | |
} |
101 | 0 | if ( buildJob.getFailureMessage() != null ) |
102 | |
{ |
103 | 0 | serializer.startTag( NAMESPACE, "failureMessage" ).text( buildJob.getFailureMessage() ).endTag( NAMESPACE, "failureMessage" ); |
104 | |
} |
105 | 0 | serializer.endTag( NAMESPACE, tagName ); |
106 | |
} |
107 | 0 | } |
108 | |
|
109 | |
|
110 | |
} |