Class TablePrinter

java.lang.Object
neqsim.thermo.util.readwrite.TablePrinter
All Implemented Interfaces:
Serializable

public class TablePrinter extends Object implements Serializable
A utility class for pretty printing a 2D string table.
Author:
Even Solbraa
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    Serialization version UID.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String[][]
    convertDoubleToString(double[][] doubleArray)
    Returns a 2D string table in a formatted and visually appealing way.
    private static int[]
    Calculates the maximum width of each column in the table.
    private static void
    printHorizontalLine(int[] columnWidths)
    Prints a horizontal line separator based on the column widths.
    private static void
    printRow(String[] row, int[] columnWidths)
    Prints a row of the table with appropriate padding based on column widths.
    static void
    printTable(double[][] table)
    Prints a 2D string table in a formatted and visually appealing way.
    static void
    printTable(String[][] table)
    Prints a 2D string table in a formatted and visually appealing way.

    Methods inherited from class Object

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

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
  • Constructor Details

    • TablePrinter

      public TablePrinter()
  • Method Details

    • printTable

      public static void printTable(String[][] table)
      Prints a 2D string table in a formatted and visually appealing way.
      Parameters:
      table - The 2D string table to be printed.
    • getColumnWidths

      private static int[] getColumnWidths(String[][] table)
      Calculates the maximum width of each column in the table.
      Parameters:
      table - The 2D string table.
      Returns:
      An array containing the maximum width of each column.
    • printHorizontalLine

      private static void printHorizontalLine(int[] columnWidths)
      Prints a horizontal line separator based on the column widths.
      Parameters:
      columnWidths - An array containing the maximum width of each column.
    • printRow

      private static void printRow(String[] row, int[] columnWidths)
      Prints a row of the table with appropriate padding based on column widths.
      Parameters:
      row - The row of data to be printed.
      columnWidths - An array containing the maximum width of each column.
    • printTable

      public static void printTable(double[][] table)
      Prints a 2D string table in a formatted and visually appealing way.
      Parameters:
      table - The 2D double table to be printed.
    • convertDoubleToString

      public static String[][] convertDoubleToString(double[][] doubleArray)
      Returns a 2D string table in a formatted and visually appealing way.
      Parameters:
      doubleArray - The 2D double table to be printed.
      Returns:
      2d string table