01: package net.xoetrope.xml.jaxp;
02:
03: import net.xoetrope.xml.XmlWriter;
04: import net.xoetrope.xml.XmlElement;
05: import java.io.IOException;
06: import java.io.FileOutputStream;
07: import org.w3c.dom.Element;
08:
09: /**
10: * <p>Title: Xui</p>
11: * <p>Description: Used to save the contents of an Element object to a
12: * FileOutputStream</p>
13: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
14: * <p>Company: Xoetrope Ltd.</p>
15: * @author not attributable
16: * @version 1.0
17: */
18:
19: public class JaxpXmlWriter implements XmlWriter {
20: FileOutputStream stream;
21:
22: public JaxpXmlWriter() {
23: }
24:
25: /**
26: * write the element to the FileOutputStream object
27: * @param xml The XmlElement to be written
28: * @param prettyPrint
29: * @param indent
30: * @throws IOException
31: */
32: public void write(XmlElement xml, boolean prettyPrint, int indent)
33: throws IOException {
34: Element ele = ((JaxpXmlElement) xml).getElement();
35: stream.write(ele.toString().getBytes());
36: stream.flush();
37: stream.close();
38: }
39:
40: /**
41: * Set the outputstream. This has to be set before writing the XML
42: * @param fos the FileOutputStream to which the data will be written.
43: */
44: public void setOutputStream(FileOutputStream fos) {
45: stream = fos;
46: }
47: }
|