Class FlatFileFormatter

  • Direct Known Subclasses:
    CSVFormatter, TabFormatter

    public abstract class FlatFileFormatter
    extends Formatter
    A class to define behaviour common to flat files (csv, tsv)
    Author:
    Alexis Kalderimis
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COLUMN_HEADERS
      The key for the header columns
      static java.lang.String ERROR_INTRO
      The string that begins an error line.
      protected RowFormatter labourer  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String formatFooter​(java.lang.String errorMessage, int errorCode)
      Returns formatted footer.
      java.lang.String formatHeader​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
      Returns formatted header.
      java.lang.String formatResult​(java.util.List<java.lang.String> resultRow)
      Returns formatted result item.
      protected RowFormatter getRowFormatter()
      Get the row formatter
      protected void setRowFormatter​(RowFormatter fmtr)
      Set the row formatter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ERROR_INTRO

        public static final java.lang.String ERROR_INTRO
        The string that begins an error line.
        See Also:
        Constant Field Values
      • COLUMN_HEADERS

        public static final java.lang.String COLUMN_HEADERS
        The key for the header columns
        See Also:
        Constant Field Values
    • Constructor Detail

      • FlatFileFormatter

        public FlatFileFormatter()
    • Method Detail

      • getRowFormatter

        protected RowFormatter getRowFormatter()
        Get the row formatter
        Returns:
        the object that formats the rows
      • setRowFormatter

        protected void setRowFormatter​(RowFormatter fmtr)
        Set the row formatter
        Parameters:
        fmtr - A RowFormatter implementation
      • formatHeader

        public java.lang.String formatHeader​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
        Returns formatted header.}
        Specified by:
        formatHeader in class Formatter
        Parameters:
        attributes - attributes contained in header
        Returns:
        formatted header
      • formatResult

        public java.lang.String formatResult​(java.util.List<java.lang.String> resultRow)
        Description copied from class: Formatter
        Returns formatted result item.
        Specified by:
        formatResult in class Formatter
        Parameters:
        resultRow - result row
        Returns:
        formatted result row
      • formatFooter

        public java.lang.String formatFooter​(java.lang.String errorMessage,
                                             int errorCode)
        Description copied from class: Formatter
        Returns formatted footer.
        Specified by:
        formatFooter in class Formatter
        Parameters:
        errorMessage - The error message, if sth went wrong.
        errorCode - The error code, if sth went wrong.
        Returns:
        formatted footer