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 import org.apache.maven.model.InputLocation;
25 import org.apache.maven.model.Model;
26
27 public class MavenXpp3WriterEx {
28
29
30
31
32
33
34
35 private String fileComment = null;
36
37
38
39
40 protected InputLocation.StringFormatter stringFormatter;
41
42
43
44
45
46
47
48
49
50
51 public void setFileComment(String fileComment) {
52 this.fileComment = fileComment;
53 }
54
55
56
57
58
59
60 public void setStringFormatter(InputLocation.StringFormatter stringFormatter) {
61 this.stringFormatter = stringFormatter;
62 }
63
64
65
66
67
68
69
70
71 public void write(Writer writer, Model model) throws IOException {
72 org.apache.maven.model.v4.MavenXpp3WriterEx xw = new org.apache.maven.model.v4.MavenXpp3WriterEx();
73 xw.setFileComment(fileComment);
74 xw.setStringFormatter(
75 stringFormatter != null
76 ? new org.apache.maven.api.model.InputLocation.StringFormatter() {
77 @Override
78 public String toString(org.apache.maven.api.model.InputLocation location) {
79 return stringFormatter.toString(new InputLocation(location));
80 }
81 }
82 : null);
83 xw.write(writer, model.getDelegate());
84 }
85
86
87
88
89
90
91
92
93 public void write(OutputStream stream, Model model) throws IOException {
94 org.apache.maven.model.v4.MavenXpp3WriterEx xw = new org.apache.maven.model.v4.MavenXpp3WriterEx();
95 xw.setFileComment(fileComment);
96 xw.write(stream, model.getDelegate());
97 }
98 }