Class ResultWriter

All Implemented Interfaces:
IResultHandler, FrankElement, HasApplicationContext, HasName, IConfigurable, IScopeProvider, IWithParameters, NameAware, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
Result2Filewriter, Result2LobWriterBase, Result2StringWriter

public abstract class ResultWriter extends AbstractResultHandler
Baseclass for resulthandlers that write the transformed record to a writer.
Since:
4.7
Author:
Gerrit van Brakel
  • Constructor Details

    • ResultWriter

      public ResultWriter()
  • Method Details

    • createWriter

      protected abstract Writer createWriter(PipeLineSession session, String streamId) throws Exception
      Throws:
      Exception
    • openDocument

      public void openDocument(PipeLineSession session, String streamId) throws Exception
      Description copied from interface: IResultHandler
      Called once, before the first record of a stream is presented to handleResult.
      Specified by:
      openDocument in interface IResultHandler
      Overrides:
      openDocument in class AbstractResultHandler
      Parameters:
      session - current PipeLineSession
      streamId - identification of the original file/stream/message
      Throws:
      Exception
    • closeDocument

      public void closeDocument(PipeLineSession session, String streamId)
      Specified by:
      closeDocument in interface IResultHandler
      Overrides:
      closeDocument in class AbstractResultHandler
    • finalizeResult

      public String finalizeResult(PipeLineSession session, String streamId, boolean error) throws Exception
      Description copied from interface: IResultHandler
      Called when all records in the original file are handled.
      Parameters:
      session - current PipeLineSession
      streamId - identification of the original file/stream/message containing the untransformed records
      Returns:
      the name or names of the output files
      Throws:
      Exception
    • handleResult

      public void handleResult(PipeLineSession session, String streamId, String recordKey, String result) throws Exception
      Description copied from interface: IResultHandler
      write a result record.
      Parameters:
      session - current PipeLineSession
      streamId - identification of the original file/stream/message containing the untransformed records
      recordKey - key of the record (describes the record type)
      result - transformed record
      Throws:
      Exception
    • writeNewLine

      protected void writeNewLine(Writer w) throws IOException
      Throws:
      IOException
    • openRecordType

      public void openRecordType(PipeLineSession session, String streamId) throws Exception
      Parameters:
      session - current PipeLineSession
      streamId - identification of the original file/stream/message containing the untransformed records
      Throws:
      Exception
    • closeRecordType

      public void closeRecordType(PipeLineSession session, String streamId) throws Exception
      Parameters:
      session - current PipeLineSession
      streamId - identification of the original file/stream/message containing the untransformed records
      Throws:
      Exception
    • replacePattern

      protected String replacePattern(String target, String blockName)
    • openBlock

      public void openBlock(PipeLineSession session, String streamId, String blockName, Map<String,Object> blocks) throws Exception
      Throws:
      Exception
    • closeBlock

      public void closeBlock(PipeLineSession session, String streamId, String blockName, Map<String,Object> blocks) throws Exception
      Throws:
      Exception
    • getWriter

      protected Writer getWriter(PipeLineSession session, String streamId, boolean create) throws Exception
      Throws:
      Exception
    • setOnOpenDocument

      public void setOnOpenDocument(String line)
      string that is written before any data of results is written
      Default value
      <document name="#name#">
    • setOnCloseDocument

      public void setOnCloseDocument(String line)
      string that is written after all data of results is written
      Default value
      </document>
    • setOnOpenBlock

      public void setOnOpenBlock(String line)
      string that is written before the start of each logical block, as defined in the flow
      Default value
      <#name#>
    • setOnCloseBlock

      public void setOnCloseBlock(String line)
      string that is written after the end of each logical block, as defined in the flow
      Default value
      </#name#>
    • setBlockNamePattern

      public void setBlockNamePattern(String pattern)
      string that is replaced by name of block or name of stream in above strings
      Default value
      #name#