Class TsvManager

java.lang.Object
com.smeup.kokos.sdk.rpgle.util.TsvManager
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
StatisticsFunTsvManager

public class TsvManager extends Object implements AutoCloseable
The TsvManager class provides functionality for managing and writing data in a Tab-Separated Values (TSV) format. It allows the initialization of a new TSV with specified headers and appending new rows of data. This class is designed for scenarios where data needs to be represented in a TSV format for easier readability and data manipulation. The underlying mechanism uses a PrintWriter to output data, which is not buffered as a file but can be any Writer implementation.
Author:
Davide Palladino
  • Constructor Details

    • TsvManager

      public TsvManager(Writer writer, ArrayList<String> columns, boolean isNew)
      Constructs a new TsvManager instance.
      Parameters:
      writer - the writer used to output the TSV data, which can be any implementation of Writer, not limited to file buffers
      columns - a list of column headers for the TSV
      isNew - a boolean indicating whether to initialize the TSV with headers
  • Method Details

    • append

      public void append(HashMap<String,String> newRow)
      Appends a new row to the TSV.
      Parameters:
      newRow - a map containing the data for the new row, with column headers as keys
    • close

      public void close() throws Exception
      Closes the TsvManager, releasing any resources associated with it.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception