View Javadoc
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.artifact.repository.metadata.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.artifact.repository.metadata.Metadata;
28  import org.apache.maven.metadata.v4.MetadataStaxWriter;
29  
30  /**
31   * Provide public methods from {@link MetadataStaxWriter}
32   *
33   * @deprecated Maven 3 compatability - please use {@link MetadataStaxWriter}
34   */
35  @Deprecated
36  public class MetadataXpp3Writer {
37  
38      private final MetadataStaxWriter delegate;
39  
40      /**
41       * Default constructor
42       */
43      public MetadataXpp3Writer() {
44          delegate = new MetadataStaxWriter();
45      }
46  
47      /**
48       * Method setFileComment.
49       *
50       * @param fileComment a fileComment object.
51       */
52      public void setFileComment(String fileComment) {
53          delegate.setFileComment(fileComment);
54      }
55  
56      /**
57       * Method write.
58       *
59       * @param writer   a writer object
60       * @param metadata a Metadata object
61       * @throws java.io.IOException java.io.IOException if any
62       */
63      public void write(Writer writer, Metadata metadata) throws java.io.IOException {
64          try {
65              delegate.write(writer, metadata.getDelegate());
66          } catch (XMLStreamException e) {
67              throw new IOException(e);
68          }
69      }
70  
71      /**
72       * Method write.
73       *
74       * @param stream a stream object
75       * @param metadata a Metadata object
76       * @throws java.io.IOException java.io.IOException if any
77       */
78      public void write(OutputStream stream, Metadata metadata) throws java.io.IOException {
79          try {
80              delegate.write(stream, metadata.getDelegate());
81          } catch (XMLStreamException e) {
82              throw new IOException(e);
83          }
84      }
85  }