1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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.OutputStream;
25 import java.io.Writer;
26
27 import org.apache.maven.model.InputLocation;
28 import org.apache.maven.model.Model;
29 import org.apache.maven.model.v4.MavenStaxWriter;
30
31 /**
32 * @deprecated Use MavenStaxWriter instead
33 */
34 @Deprecated
35 public class MavenXpp3Writer {
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
39
40 private final MavenStaxWriter delegate = new MavenStaxWriter();
41
42 // -----------/
43 // - Methods -/
44 // -----------/
45
46 public MavenXpp3Writer() {
47 this(false);
48 }
49
50 protected MavenXpp3Writer(boolean addLocationInformation) {
51 delegate.setAddLocationInformation(addLocationInformation);
52 }
53
54 /**
55 * Method setFileComment.
56 *
57 * @param fileComment a fileComment object.
58 */
59 public void setFileComment(String fileComment) {
60 delegate.setFileComment(fileComment);
61 } // -- void setFileComment( String )
62
63 /**
64 * Method setStringFormatter.
65 *
66 * @param stringFormatter
67 */
68 public void setStringFormatter(InputLocation.StringFormatter stringFormatter) {
69 delegate.setStringFormatter(
70 stringFormatter != null ? location -> stringFormatter.toString(new InputLocation(location)) : null);
71 } // -- void setStringFormatter( InputLocation.StringFormatter )
72
73 /**
74 * Method write.
75 *
76 * @param writer a writer object.
77 * @param model a model object.
78 * @throws IOException java.io.IOException if any.
79 */
80 public void write(Writer writer, Model model) throws IOException {
81 try {
82 delegate.write(writer, model.getDelegate());
83 } catch (XMLStreamException e) {
84 throw new IOException(e);
85 }
86 } // -- void write( Writer, Model )
87
88 /**
89 * Method write.
90 *
91 * @param stream a stream object.
92 * @param model a model object.
93 * @throws IOException java.io.IOException if any.
94 */
95 public void write(OutputStream stream, Model model) throws IOException {
96 try {
97 delegate.write(stream, model.getDelegate());
98 } catch (XMLStreamException e) {
99 throw new IOException(e);
100 }
101 } // -- void write( OutputStream, Model )
102 }