Class AbstractWriter

Direct Known Subclasses:
BinaryWriter, ExcelWriter, GoogleSheetWriter, TextWriter

public abstract class AbstractWriter extends DataWriter
Abstract super-class, with some common logic, for writing records. The only method subclasses must implement is writeRecord(Record).
  • Field Details

    • currentRecord

      protected Record currentRecord
  • Constructor Details

    • AbstractWriter

      public AbstractWriter()
  • Method Details

    • 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 DataWriter
    • setFieldNamesInFirstRow

      public AbstractWriter setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
      Indicates if a header row of field names is written before the first record (default is true); must be called before open().
    • isFieldNamesInFirstRow

      public boolean isFieldNamesInFirstRow()
      Indicates if a header row of field names is written before the first record (default is true).
    • isHeaderRow

      public boolean isHeaderRow()
      Returns true if the current record being written is the header row. This flag is only useful when called inside of writeRecord(Record), otherwise, it will always return false.
    • open

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

      public void write(Record record) throws DataException
      Description copied from class: DataWriter
      Writes the specified record to this DataWriter and increases the record-count by 1. Any exception raised while writing will be converted to a DataException using DataObject.exception(Throwable).

      Subclasses generally do not need to override this method, instead they should implement DataWriter.writeImpl(Record).

      Overrides:
      write in class DataWriter
      Throws:
      DataException
    • 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
    • createHeaderRecord

      protected Record createHeaderRecord(Record record)
      Builds the header row from the first record: a copy whose field values are the field names, without session properties.
    • writeRecord

      protected abstract void writeRecord(Record record) throws Throwable
      Writes one row; called first for the header row (see isHeaderRow()) when field names are written, then for each record.
      Throws:
      Throwable