Class ReportFormatter<R extends Report>

    • Constructor Detail

      • ReportFormatter

        protected ReportFormatter​(FormatSettings<Object> defaultSettings)
        Creates a new formatter with a set of default format settings.
        Parameters:
        defaultSettings - default format settings, used if there are no settings for a data type.
    • Method Detail

      • writeCsv

        public void writeCsv​(R report,
                             OutputStream out)
        Outputs the report table in CSV format.
        Parameters:
        report - the report
        out - the output stream to write to
      • writeAsciiTable

        public void writeAsciiTable​(R report,
                                    OutputStream out)
        Outputs the report as an ASCII table.
        Parameters:
        report - the report
        out - the output stream to write to
      • getColumnTypes

        protected abstract List<Class<?>> getColumnTypes​(R report)
        Gets the type of the data in each report column.

        If every value in a column is a failure the type will be Object.class.

        Parameters:
        report - the report
        Returns:
        a list of column types
      • formatData

        protected abstract String formatData​(R report,
                                             int rowIdx,
                                             int colIdx,
                                             ReportOutputFormat format)
        Formats a piece of data for display.
        Parameters:
        report - the report containing the data
        rowIdx - the row index of the data
        colIdx - the column index of the data
        format - the report output format
        Returns:
        the formatted data
      • formatValue

        protected String formatValue​(Object value,
                                     ReportOutputFormat format)
        Formats a value into a string.
        Parameters:
        value - the value
        format - the format that controls how the value is formatted
        Returns:
        the formatted value