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 javax.xml.stream.XMLStreamException;
22
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.Reader;
26
27 import org.apache.maven.model.InputSource;
28 import org.apache.maven.model.Model;
29 import org.apache.maven.model.v4.MavenStaxReader;
30 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
31
32
33
34
35 @Deprecated
36 public class MavenXpp3Reader {
37 private MavenStaxReader delegate;
38
39 public MavenXpp3Reader() {
40 this(null, false);
41 }
42
43 public MavenXpp3Reader(ContentTransformer contentTransformer) {
44 this(contentTransformer, false);
45 }
46
47 protected MavenXpp3Reader(ContentTransformer contentTransformer, boolean addLocationInformation) {
48 delegate =
49 contentTransformer != null ? new MavenStaxReader(contentTransformer::transform) : new MavenStaxReader();
50 delegate.setAddLocationInformation(addLocationInformation);
51 }
52
53
54
55
56
57
58 public boolean getAddDefaultEntities() {
59 return delegate.getAddDefaultEntities();
60 }
61
62
63
64
65
66
67 public void setAddDefaultEntities(boolean addDefaultEntities) {
68 delegate.setAddLocationInformation(addDefaultEntities);
69 }
70
71 protected Model read(Reader reader, boolean strict, InputSource source) throws IOException, XmlPullParserException {
72 try {
73 org.apache.maven.api.model.Model model =
74 delegate.read(reader, strict, source != null ? source.toApiSource() : null);
75 return new Model(model);
76 } catch (XMLStreamException e) {
77 throw new XmlPullParserException(e.getMessage(), null, e);
78 }
79 }
80
81
82
83
84
85
86
87
88
89
90 public Model read(Reader reader, boolean strict) throws IOException, XmlPullParserException {
91 return read(reader, strict, null);
92 }
93
94
95
96
97
98
99
100
101
102 public Model read(Reader reader) throws IOException, XmlPullParserException {
103 return read(reader, true);
104 }
105
106 protected Model read(InputStream is, boolean strict, InputSource source)
107 throws IOException, XmlPullParserException {
108 try {
109 org.apache.maven.api.model.Model model =
110 delegate.read(is, strict, source != null ? source.toApiSource() : null);
111 return new Model(model);
112 } catch (XMLStreamException e) {
113 throw new XmlPullParserException(e.getMessage(), null, e);
114 }
115 }
116
117
118
119
120
121
122
123
124
125
126
127 public Model read(InputStream in, boolean strict) throws IOException, XmlPullParserException {
128 return read(in, strict, null);
129 }
130
131
132
133
134
135
136
137
138
139
140 public Model read(InputStream in) throws IOException, XmlPullParserException {
141 return read(in, true);
142 }
143
144 public interface ContentTransformer {
145
146
147
148
149
150
151
152 String transform(String source, String fieldName);
153 }
154 }