Class ResultTable

java.lang.Object
org.dalesbred.result.ResultTable
All Implemented Interfaces:
Iterable<ResultTable.ResultRow>

public final class ResultTable extends Object implements Iterable<ResultTable.ResultRow>
Represents the results of the query along with its metadata. Basically a detached version of ResultSet.
  • Method Details

    • getRowCount

      public int getRowCount()
    • getColumnCount

      public int getColumnCount()
    • get

      public Object get(int row, int column)
      Returns the value of given column of given row. Both indices are zero-based.
    • get

      public Object get(int row, @NotNull @NotNull String column)
      Returns the value of given named column of given row.
    • getRows

      @NotNull public @NotNull List<ResultTable.ResultRow> getRows()
    • getColumns

      @NotNull public @NotNull List<ResultTable.ColumnMetadata> getColumns()
    • getColumnNames

      @NotNull public @NotNull List<String> getColumnNames()
    • getColumnTypes

      @NotNull public @NotNull List<Type> getColumnTypes()
    • getRawColumnTypes

      @NotNull public @NotNull List<Class<?>> getRawColumnTypes()
    • iterator

      @NotNull public @NotNull Iterator<ResultTable.ResultRow> iterator()
      Specified by:
      iterator in interface Iterable<ResultTable.ResultRow>
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • toStringFormatted

      @NotNull public @NotNull String toStringFormatted()
      Returns a formatted representation of this table. See formatTo(Appendable) for details of the format.
      See Also:
    • formatTo

      public void formatTo(@NotNull @NotNull Appendable out) throws IOException
      Pretty prints this table to out in a format suitable for console. Overly long columns are truncated and some effort is taken to make the result readable, but you should not depend on the exact details of the layout, since it might change.

      Hint: the output format is rouhgly that of Markdown tables, so you can use the result in your Markdown-documents. However, data is not escaped, since it's primarily meant to be written to console where escaping would hinder readability. Therefore, you might need to make manual adjustments to output if interpreting it as Markdown.

      Throws:
      IOException
      See Also:
    • builder

      @NotNull public static @NotNull ResultTable.Builder builder(@NotNull @NotNull List<ResultTable.ColumnMetadata> columns)
      Returns a builder for building a ResultTable for given columns.