/*
* #%L
* data-exporter
* %%
* Copyright (C) 2012 - 2013 http://www.brsanthu.com
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.brsanthu.dataexporter.output.xml;
import java.io.OutputStream;
import java.io.Writer;
import com.brsanthu.dataexporter.DataExporter;
/**
* Data exporter which exports to XML format. Sample format is as follows.
* <pre>
* <?xml version="1.0" encoding="UTF-8"?>
* <table>
* <row>
* <column name="Line No">1</column>
* <column name="Date Purchased">2011/04/07 08:27:07 AM</column>
* <column name="Item No">1</column>
* <column name="Item Name">Laptop</column>
* <column name="Shipped?">No</column>
* <column name="Quantity">1</column>
* <column name="Unit Price">$799.78</column>
* <column name="Price">$799.78</column>
* </row>
* <row>
* <column name="Line No">2</column>
* <column name="Date Purchased">2011/04/04 04:39:43 PM</column>
* <column name="Item No">2</column>
* <column name="Item Name">Mouse</column>
* <column name="Shipped?">Yes</column>
* <column name="Quantity">2</column>
* <column name="Unit Price">$49.30</column>
* <column name="Price">$98.60</column>
* </row>
* <row>
* <column name="Line No">3</column>
* <column name="Date Purchased">2011/04/04 04:05:41 PM</column>
* <column name="Item No">3</column>
* <column name="Item Name">Keyboard</column>
* <column name="Shipped?">No</column>
* <column name="Quantity">5</column>
* <column name="Unit Price">$75.00</column>
* <column name="Price">$375.00</column>
* </row>
* </table>
* </pre>
*
* @author Santhosh Kumar
*/
public class XmlExporter extends DataExporter {
/**
* Creates exporter with given output stream and default {@link XmlExportOptions}
*
* @param out the output stream to write the output to. Cannot be <code>null</code>
*/
public XmlExporter(OutputStream out) {
this(new XmlExportOptions(), out);
}
/**
* Creates exporter with given options and output stream.
*
* @param options the Xml export options. Cannot be <code>null</code>
* @param out the output stream to write the output to. Cannot be <code>null</code>
*/
public XmlExporter(XmlExportOptions options, OutputStream out) {
super(new XmlWriter(options, out));
}
/**
* Creates exporter with default {@link XmlExportOptions} and given writer.
*
* @param out the writer to write the output to. Cannot be <code>null</code>
*/
public XmlExporter(Writer out) {
this(new XmlExportOptions(), out);
}
/**
* Creates exporter with given options and given writer.
*
* @param options the xml export options. Cannot be <code>null</code>
* @param out the writer to write the output to. Cannot be <code>null</code>
*/
public XmlExporter(XmlExportOptions options, Writer out) {
super(new XmlWriter(options, out));
}
/**
* Creates exporter with default {@link XmlExportOptions} and <code>System.out</code> output stream.
*/
public XmlExporter() {
this(System.out);
}
/**
* Creates exporter with given options and <code>System.out</code> output stream.
*
* @param options the options to use for exporting. Cannot be <code>null</code>.
*/
public XmlExporter(XmlExportOptions options) {
this(options, System.out);
}
/**
* Returns the currently active xml export options.
*
* @return the xml export options.
*/
public XmlExportOptions getXmlExportOptions() {
return (XmlExportOptions) getOptions();
}
}