Interface OutputFormatter<T>

Type Parameters:
T - the output format type
All Known Implementing Classes:
DummyFormatter, JsonOutputFormatter, TextLineFormatter

public interface OutputFormatter<T>
Generic output formatter. You may add information to one chunk until chunkCompleted() is called. Custom implementations must have a constructor with a single String argument, the character encoding name. Implementing classes shall use their specific rather than generic return types for getConverter() to reduce dependencies on <T>. Moreover, add(String, Object) shall be directly used in combination with InputParser.InputConverter to avoid exposing <T> unless explicitly necessary. This interface is used to generate connector code against.
Author:
Holger Eichelberger, SSE
  • Field Details

    • SEPARATOR

      static final char SEPARATOR
      Separator for hierarchical names.
      See Also:
  • Method Details

    • add

      void add(String name, T data) throws IOException
      Adds information to one chunk of output. Hierarchical names separated by SEPARATOR can be used, but nested values for the same parent (object) field must be named in sequence.
      Parameters:
      name - optional data name field (may be null for none)
      data - the data to be added
      Throws:
      IOException - if adding the data fails for some reason
    • startArrayStructure

      void startArrayStructure(String name) throws IOException
      Starts an array structure. Following add(String, Object) calls will add elements to the array. Must be closed with endStructure()
      Parameters:
      name - optional data name field holding the array (may be null for none)
      Throws:
      IOException - if starting this structure fails
    • startObjectStructure

      void startObjectStructure(String name) throws IOException
      Starts an object structure. Following add(String, Object) calls will add elements to the object. Must be closed with endStructure()
      Parameters:
      name - optional data name field holding the array (may be null for none)
      Throws:
      IOException - if starting this structure fails
    • endStructure

      void endStructure() throws IOException
      Ends a structure started before.
      Throws:
      IOException - if ending the actual structure fails
    • chunkCompleted

      byte[] chunkCompleted() throws IOException
      Completes a chunk of output data.
      Returns:
      the chunk
      Throws:
      IOException - if creating the chunk fails for some reason
    • getConverter

      Returns the output converter.
      Returns:
      the output converter