1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.ear;
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.io.Writer;
24
25 import org.codehaus.plexus.util.WriterFactory;
26 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
27 import org.codehaus.plexus.util.xml.XMLWriter;
28
29
30
31
32
33
34 abstract class AbstractXmlWriter {
35
36 private final String encoding;
37
38 AbstractXmlWriter(String encoding) {
39 this.encoding = encoding;
40 }
41
42 Writer initializeWriter(final File destinationFile) throws EarPluginException {
43 try {
44 return WriterFactory.newXmlWriter(destinationFile);
45 } catch (IOException ex) {
46 throw new EarPluginException("Exception while opening file[" + destinationFile.getAbsolutePath() + "]", ex);
47 }
48 }
49
50 XMLWriter initializeXmlWriter(final Writer writer, final String docType) {
51 return new PrettyPrintXMLWriter(writer, encoding, docType);
52 }
53 }