Class XmlWriter


public class XmlWriter extends TextWriter
Writes records to an XML stream using a template. See the Write an XML file example.
  • Constructor Details

  • Method Details

    • isPretty

      public boolean isPretty()
      Indicates if line breaks and indentations should be added to output (default false).
    • setPretty

      public XmlWriter setPretty(boolean pretty)
      Indicates if line breaks and indentations should be added to output (default false).
      Example output (pretty = true):
      <?xml version="1.0" ?>
      <records>
        <record>
          <field name="country">Philippines</field>
        </record>
      </records>

      Example output (pretty = false):
      <?xml version="1.0" ?><records><record><field name="country">Philippines</field></record></records>
    • setFieldNamesInFirstRow

      public XmlWriter setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
      Description copied from class: AbstractWriter
      Indicates if a header row of field names is written before the first record (default is true); must be called before AbstractWriter.open().
      Overrides:
      setFieldNamesInFirstRow in class AbstractWriter
    • setAutoCloseWriter

      public XmlWriter setAutoCloseWriter(boolean autoCloseWriter)
      Description copied from class: TextWriter
      Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
      Overrides:
      setAutoCloseWriter in class TextWriter
    • setFlushOnWrite

      public XmlWriter setFlushOnWrite(boolean flushOnWrite)
      Description copied from class: TextWriter
      Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).
      Overrides:
      setFlushOnWrite in class TextWriter
    • open

      public void open()
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class AbstractWriter
    • close

      public void close()
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class TextWriter
    • writeRecord

      protected void writeRecord(Record record) throws Throwable
      Description copied from class: AbstractWriter
      Writes one row; called first for the header row (see AbstractWriter.isHeaderRow()) when field names are written, then for each record.
      Specified by:
      writeRecord in class AbstractWriter
      Throws:
      Throwable