public class DbTable
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.String> |
header
The header.
|
private java.util.List<java.util.List<java.lang.String>> |
table
The table.
|
Constructor and Description |
---|
DbTable()
Instantiates a new db table.
|
DbTable(java.util.List<java.util.List<java.lang.String>> data)
Create a table based on a List
|
DbTable(java.sql.ResultSet rs)
Create a table based on a ResultSet.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.Integer> |
getColumnInt(java.lang.String headerName)
Get the values of a column as a List
|
java.util.List<java.lang.String> |
getColumnNames()
Get all the column names.
|
java.util.List<java.lang.String> |
getColumnString(java.lang.String headerName)
Get the values of a column as a List
|
java.lang.String |
getFirstValue(java.lang.String headerName)
Gets the first value in a column indicated by the header.
|
java.util.List<java.lang.String> |
getHeaders()
Return the names of all the columns.
|
java.util.HashMap<java.lang.String,java.lang.Object> |
getRowAsKeyVal(int row)
Gets the row as Map of key/value pairs.
|
int |
getSize()
Return the number of rows in this table.
|
java.util.List<java.util.List<java.lang.String>> |
getTable()
Get all the rows.
|
static DbTable |
makeErrorTable(java.lang.String headerMsg,
java.lang.String rowMsg)
Make a table that contains an error message.
|
protected void |
parseResultSet(java.sql.ResultSet rs)
Parse the ResultSet into the table structure.
|
java.lang.String |
toString()
Return the entire table as a String.
|
private java.util.List<java.lang.String> header
private java.util.List<java.util.List<java.lang.String>> table
public DbTable()
public DbTable(java.sql.ResultSet rs)
rs
- the ResultSetpublic DbTable(java.util.List<java.util.List<java.lang.String>> data)
data
- the DbTablepublic int getSize()
public java.util.List<java.lang.String> getHeaders()
public java.util.List<java.util.List<java.lang.String>> getTable()
public java.util.List<java.lang.String> getColumnNames()
protected void parseResultSet(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- the ResultSetjava.sql.SQLException
- the SQL exceptionpublic java.util.List<java.lang.String> getColumnString(java.lang.String headerName)
headerName
- the header namepublic java.util.List<java.lang.Integer> getColumnInt(java.lang.String headerName)
headerName
- the header namepublic java.lang.String getFirstValue(java.lang.String headerName)
headerName
- the header namepublic java.util.HashMap<java.lang.String,java.lang.Object> getRowAsKeyVal(int row)
row
- the row (0 - size)public java.lang.String toString()
toString
in class java.lang.Object
public static DbTable makeErrorTable(java.lang.String headerMsg, java.lang.String rowMsg)
headerMsg
- the header msgrowMsg
- the row msg