|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.peter.db.DBMatrix
This class creates a data structure (Matrix) from a ResultSet, in order to that data retrieved from a ResultSet can be used after the ResultSet, and its Statement are no longer needed and can be closed. The data structure used is a HashMap that uses the original ResultSet column names as keys, and Vectors containing data objects as values.
| Constructor Summary | |
DBMatrix(java.sql.ResultSet rs)
The constructor creates an instance of the structure given a ResultSet. |
|
| Method Summary | |
java.util.Vector |
getColumn(int column)
Returns a Vector containing all values in a column |
java.util.Vector |
getColumn(java.lang.String column)
Returns a Vector containing all values in a column |
java.util.Vector |
getColumnNames()
Returns a Vector containing all column names |
java.util.HashMap |
getData()
Returns the whole data structure. |
int |
getNoOfColumns()
Returns the number of columns of the matrix |
int |
getNoOfRows()
Returns the number of rows |
java.util.HashMap |
getRowAsHashMap(int row)
Returns a HashMap that contains column names as key, and row data as values, given a row number. |
java.lang.Object |
getValue(int row,
int column)
Returns a single value from the structure given a row number and a column number. |
java.lang.Object |
getValue(int row,
java.lang.String columnName)
Returns a single value from the structure given a row number and a column name. |
boolean |
isEmpty()
Checks if the matrix is empty or not. |
java.lang.String |
toString()
A textual representation of the matrix |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public DBMatrix(java.sql.ResultSet rs)
throws java.sql.SQLException
rs - The ResultSet to convert.java.sql.SQLException - if there is a SQL error| Method Detail |
public java.util.HashMap getRowAsHashMap(int row)
row - The row to retrieve values from.
public java.lang.Object getValue(int row,
int column)
row - The row indexcolumn - The column index
public java.lang.Object getValue(int row,
java.lang.String columnName)
row - The row indexcolumnName - The name of the columnpublic java.util.HashMap getData()
public int getNoOfColumns()
public int getNoOfRows()
public java.util.Vector getColumnNames()
public java.util.Vector getColumn(int column)
column - The column index to returnpublic java.util.Vector getColumn(java.lang.String column)
column - The column name to returnpublic boolean isEmpty()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||