1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.io.xpp3;
20
21 import java.io.IOException;
22 import java.io.OutputStream;
23 import java.io.Writer;
24
25 import org.apache.maven.model.InputLocation;
26 import org.apache.maven.model.Model;
27
28 public class MavenXpp3WriterEx {
29
30
31
32
33
34
35
36 private String fileComment = null;
37
38
39
40
41 protected InputLocation.StringFormatter stringFormatter;
42
43
44
45
46
47
48
49
50
51
52 public void setFileComment(String fileComment) {
53 this.fileComment = fileComment;
54 }
55
56
57
58
59
60
61 public void setStringFormatter(InputLocation.StringFormatter stringFormatter) {
62 this.stringFormatter = stringFormatter;
63 }
64
65
66
67
68
69
70
71
72 public void write(Writer writer, Model model) throws IOException {
73 org.apache.maven.model.v4.MavenXpp3WriterEx xw = new org.apache.maven.model.v4.MavenXpp3WriterEx();
74 xw.setFileComment(fileComment);
75 xw.setStringFormatter(
76 stringFormatter != null
77 ? new org.apache.maven.api.model.InputLocation.StringFormatter() {
78 @Override
79 public String toString(org.apache.maven.api.model.InputLocation location) {
80 return stringFormatter.toString(new InputLocation(location));
81 }
82 }
83 : null);
84 xw.write(writer, model.getDelegate());
85 }
86
87
88
89
90
91
92
93
94 public void write(OutputStream stream, Model model) throws IOException {
95 org.apache.maven.model.v4.MavenXpp3WriterEx xw = new org.apache.maven.model.v4.MavenXpp3WriterEx();
96 xw.setFileComment(fileComment);
97 xw.write(stream, model.getDelegate());
98 }
99 }