Class DataWriter

Direct Known Subclasses:
AbstractWriter, CollectionWriter, EventBusWriter, FileWriter, IntegrationWriter, JdbcUpsertWriter, JdbcWriter, JmsWriter, MapWriter, MemoryWriter, MultiWriter, NullWriter, PipedWriter, ProxyWriter, SplitWriter, StreamWriter, TailWriter, TextStreamWriter

public abstract class DataWriter extends DataEndpoint
Abstract super-class for writing records. The only method that a subclass must implement is writeImpl(Record), however, most subclasses will also override DataEndpoint.open() and DataEndpoint.close().
  • Constructor Details

    • DataWriter

      public DataWriter()
  • Method Details

    • getNestedEndpoint

      public DataWriter getNestedEndpoint()
      Description copied from class: Endpoint
      Returns the Endpoint held inside this one or null if there isn't one.
      Overrides:
      getNestedEndpoint in class DataEndpoint
    • getRootEndpoint

      public DataWriter getRootEndpoint()
      Description copied from class: Endpoint
      Returns the deepest, nested Endpoint held inside this one, otherwise this instance is returned if there aren't any nested Endpoints.
      Overrides:
      getRootEndpoint in class DataEndpoint
    • getNestedWriter

      public DataWriter getNestedWriter()
      Returns the DataWriter held inside this one or null if there isn't one.
    • getWriter

      public <T extends DataWriter> T getWriter(Class<T> type)
      Returns the first DataWriter of the specified type held inside this one or null if there isn't one.
    • getRootWriter

      public DataWriter getRootWriter()
      Returns the deepest, nested DataWriter held inside this one, otherwise this instance is returned if there aren't any nested DataWriters.
    • available

      public int available() throws DataException
      Returns the number of records that can probably be written without blocking.
      Throws:
      DataException
    • writeImpl

      protected abstract void writeImpl(Record record) throws Throwable
      Overridden by subclasses to write the specified record to this DataWriter.

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

      Throws:
      Throwable
    • write

      public void write(Record record) throws DataException
      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 writeImpl(Record).

      Throws:
      DataException
    • 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 DataEndpoint