Class XmlRecordWriter


public class XmlRecordWriter extends TextStreamWriter
Writes XML using the structure of each record's natural representation.
  • Constructor Details

    • XmlRecordWriter

      public XmlRecordWriter(File file)
    • XmlRecordWriter

      public XmlRecordWriter(Writer writer)
  • Method Details

    • isPretty

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

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

      public String getRootTagName()
      Returns the name of the root element wrapping all records, or null/empty for none (defaults to document).
    • setRootTagName

      public XmlRecordWriter setRootTagName(String rootTagName)
      Sets the name of the root element wrapping all records, or null/empty for none (defaults to document).
    • getRecordTagName

      public String getRecordTagName()
      Returns the name of the element written for each record (defaults to record); it must not be null or empty.
    • setRecordTagName

      public XmlRecordWriter setRecordTagName(String recordTagName)
      Sets the name of the element written for each record (defaults to record); it must not be null or empty.
    • isWriteXmlDeclaration

      public boolean isWriteXmlDeclaration()
      Indicates if the output starts with an XML declaration (default is false).
    • setWriteXmlDeclaration

      public XmlRecordWriter setWriteXmlDeclaration(boolean writeXmlDeclaration)
      Indicates if the output starts with an XML declaration (default is false).
    • isWriteFieldsAsAttributes

      public boolean isWriteFieldsAsAttributes()
      Indicates if null and single-valued fields are written as attributes of their element instead of child elements (default is true).
    • setWriteFieldsAsAttributes

      public XmlRecordWriter setWriteFieldsAsAttributes(boolean writeFieldsAsAttributes)
      Indicates if null and single-valued fields are written as attributes of their element instead of child elements (default is true).
    • open

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

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

      protected void writeImpl(Record record) throws Throwable
      Description copied from class: DataWriter
      Overridden by subclasses to write the specified record to this DataWriter.

      Contract for subclasses (see also docs/authoring/DataWriter.md):

      Specified by:
      writeImpl in class DataWriter
      Throws:
      Throwable
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class TextStreamWriter