Package org.dalesbred.result
Class ResultTable
- java.lang.Object
-
- org.dalesbred.result.ResultTable
-
- All Implemented Interfaces:
java.lang.Iterable<ResultTable.ResultRow>
public final class ResultTable extends java.lang.Object implements java.lang.Iterable<ResultTable.ResultRow>
Represents the results of the query along with its metadata. Basically a detached version ofResultSet.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResultTable.BuilderA builder for building ResultTables.static classResultTable.ColumnMetadataProvides metadata about a column of the result.static classResultTable.ResultRowRepresents a single row of results.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static @NotNull ResultTable.Builderbuilder(@NotNull java.util.List<ResultTable.ColumnMetadata> columns)Returns a builder for building a ResultTable for given columns.voidformatTo(@NotNull java.lang.Appendable out)Pretty prints this table tooutin a format suitable for console.java.lang.Objectget(int row, int column)Returns the value of given column of given row.java.lang.Objectget(int row, @NotNull java.lang.String column)Returns the value of given named column of given row.intgetColumnCount()@NotNull java.util.List<java.lang.String>getColumnNames()@NotNull java.util.List<ResultTable.ColumnMetadata>getColumns()@NotNull java.util.List<java.lang.reflect.Type>getColumnTypes()@NotNull java.util.List<java.lang.Class<?>>getRawColumnTypes()intgetRowCount()@NotNull java.util.List<ResultTable.ResultRow>getRows()@NotNull java.util.Iterator<ResultTable.ResultRow>iterator()@NotNull java.lang.StringtoString()@NotNull java.lang.StringtoStringFormatted()Returns a formatted representation of this table.
-
-
-
Method Detail
-
getRowCount
public int getRowCount()
-
getColumnCount
public int getColumnCount()
-
get
public java.lang.Object get(int row, int column)Returns the value of given column of given row. Both indices are zero-based.
-
get
public java.lang.Object get(int row, @NotNull @NotNull java.lang.String column)Returns the value of given named column of given row.
-
getRows
@NotNull public @NotNull java.util.List<ResultTable.ResultRow> getRows()
-
getColumns
@NotNull public @NotNull java.util.List<ResultTable.ColumnMetadata> getColumns()
-
getColumnNames
@NotNull public @NotNull java.util.List<java.lang.String> getColumnNames()
-
getColumnTypes
@NotNull public @NotNull java.util.List<java.lang.reflect.Type> getColumnTypes()
-
getRawColumnTypes
@NotNull public @NotNull java.util.List<java.lang.Class<?>> getRawColumnTypes()
-
iterator
@NotNull public @NotNull java.util.Iterator<ResultTable.ResultRow> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<ResultTable.ResultRow>
-
toString
@NotNull public @NotNull java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringFormatted
@NotNull public @NotNull java.lang.String toStringFormatted()
Returns a formatted representation of this table. SeeformatTo(Appendable)for details of the format.- See Also:
formatTo(Appendable)
-
formatTo
public void formatTo(@NotNull @NotNull java.lang.Appendable out) throws java.io.IOExceptionPretty prints this table tooutin 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:
java.io.IOException- See Also:
toStringFormatted()
-
builder
@NotNull public static @NotNull ResultTable.Builder builder(@NotNull @NotNull java.util.List<ResultTable.ColumnMetadata> columns)
Returns a builder for building a ResultTable for given columns.
-
-