| java.lang.Object com.mockrunner.mock.jdbc.MockResultSet
MockResultSet | public class MockResultSet implements ResultSet,Cloneable(Code) | | Mock implementation of ResultSet .
Can be used to add simulated database entries.
You can add Java objects of any type. This
mock implementation does not care about SQL
data types. It tries to perform the necessary
type conversions for the Java objects (e.g. it will convert a
String "1" to int 1).
Please check out the documentation of ResultSet
for the description of the methods in this interface.
The additional methods are described here.
|
Method Summary | |
public boolean | absolute(int row) | public void | addColumn() Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index. | public void | addColumn(String columnName) Adds a column to the simulated database table. | public void | addColumn(Object[] values) Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index. | public void | addColumn(List values) Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index. | public void | addColumn(String columnName, Object[] values) Adds a column to the simulated database table.
The column will get the specified name.
The specified data will be stored in the new column. | public void | addColumn(String columnName, List values) Adds a column to the simulated database table.
The column will get the specified name.
The specified data will be stored in the new column. | public void | addRow(Object[] values) Adds a row to the simulated database table.
If there are not enough columns (initially there
are no columns, you have to specify them with the
addColumn methods) the missing columns will
be added automatically. | public void | addRow(List values) Adds a row to the simulated database table.
If there are not enough columns (initially there
are no columns, you have to specify them with the
addColumn methods) the missing columns will
be added automatically. | public void | afterLast() | public void | beforeFirst() | public void | cancelRowUpdates() | public void | clearWarnings() | public Object | clone() Copies this ResultSet . | public void | close() | public void | deleteRow() | public int | findColumn(String columnName) | public boolean | first() | public Array | getArray(int columnIndex) | public Array | getArray(String columnName) | public InputStream | getAsciiStream(int columnIndex) | public InputStream | getAsciiStream(String columnName) | public BigDecimal | getBigDecimal(int columnIndex, int scale) | public BigDecimal | getBigDecimal(String columnName, int scale) | public BigDecimal | getBigDecimal(int columnIndex) | public BigDecimal | getBigDecimal(String columnName) | public InputStream | getBinaryStream(int columnIndex) | public InputStream | getBinaryStream(String columnName) | public Blob | getBlob(int columnIndex) | public Blob | getBlob(String columnName) | public boolean | getBoolean(int columnIndex) | public boolean | getBoolean(String columnName) | public byte | getByte(int columnIndex) | public byte | getByte(String columnName) | public byte[] | getBytes(int columnIndex) | public byte[] | getBytes(String columnName) | public Reader | getCharacterStream(int columnIndex) | public Reader | getCharacterStream(String columnName) | public Clob | getClob(int columnIndex) | public Clob | getClob(String columnName) | public List | getColumn(int number) Returns the column with the specified number. | public List | getColumn(String name) Returns the column with the specified name. | public int | getColumnCount() Returns the current number of columns. | public int | getConcurrency() | public String | getCursorName() | public Date | getDate(int columnIndex) | public Date | getDate(String columnName) | public Date | getDate(int columnIndex, Calendar calendar) | public Date | getDate(String columnName, Calendar calendar) | public double | getDouble(int columnIndex) | public double | getDouble(String columnName) | public int | getFetchDirection() | public int | getFetchSize() | public float | getFloat(int columnIndex) | public float | getFloat(String columnName) | public int | getHoldability() | public String | getId() Returns the id of this ResultSet . | public int | getInt(int columnIndex) | public int | getInt(String columnName) | public long | getLong(int columnIndex) | public long | getLong(String columnName) | public ResultSetMetaData | getMetaData() | public Reader | getNCharacterStream(int columnIndex) | public Reader | getNCharacterStream(String columnLabel) | public String | getNString(int columnIndex) | public String | getNString(String columnLabel) | public Object | getObject(int columnIndex) | public Object | getObject(String columnName) | public Object | getObject(int columnIndex, Map map) | public Object | getObject(String colName, Map map) | public Ref | getRef(int columnIndex) | public Ref | getRef(String columnName) | public List | getRow(int number) Returns the row with the specified number.
The first row has the number 1.
If number is less than 1 or higher than the
current row count, null will
be returned. | public int | getRow() | public int | getRowCount() Returns the current number of rows. | public short | getShort(int columnIndex) | public short | getShort(String columnName) | public Statement | getStatement() | public String | getString(int columnIndex) | public String | getString(String columnName) | public Time | getTime(int columnIndex) | public Time | getTime(String columnName) | public Time | getTime(int columnIndex, Calendar calendar) | public Time | getTime(String columnName, Calendar calendar) | public Timestamp | getTimestamp(int columnIndex) | public Timestamp | getTimestamp(String columnName) | public Timestamp | getTimestamp(int columnIndex, Calendar calendar) | public Timestamp | getTimestamp(String columnName, Calendar calendar) | public int | getType() | public URL | getURL(int columnIndex) | public URL | getURL(String columnName) | public InputStream | getUnicodeStream(int columnIndex) | public InputStream | getUnicodeStream(String columnName) | public SQLWarning | getWarnings() | public void | insertRow() | public boolean | isAfterLast() | public boolean | isBeforeFirst() | public boolean | isClosed() Returns if this ResultSet is closed. | public boolean | isColumnEqual(int number, List columnData) Returns if the column with the specified number is
equal to the specified data. | public boolean | isColumnEqual(String name, List columnData) Returns if the column with the specified name is
equal to the specified data. | public boolean | isEqual(MockResultSet resultSet) Returns if the specified ResultSet is equal to
this ResultSet . | public boolean | isFirst() | public boolean | isLast() | public boolean | isRowEqual(int number, List rowData) Returns if the row with the specified number is
equal to the specified data. | public boolean | isWrapperFor(Class iface) | public boolean | last() | public void | moveToCurrentRow() | public void | moveToInsertRow() | public boolean | next() | public boolean | previous() | public void | refreshRow() | public boolean | relative(int rows) | public boolean | rowDeleted(int number) Returns if the row with the specified number was deleted
The first row has the number 1. | public boolean | rowDeleted() | public boolean | rowInserted(int number) Returns if the row with the specified number was inserted
The first row has the number 1. | public boolean | rowInserted() | public boolean | rowUpdated(int number) Returns if the row with the specified number was updated
The first row has the number 1. | public boolean | rowUpdated() | public void | setColumnsCaseSensitive(boolean columnsCaseSensitive) Set if column names are case sensitive. | public void | setCursorName(String cursorName) Sets the cursor name. | public void | setDatabaseView(boolean databaseView) The MockResultSet keeps the data that's
stored in the simulated database and a copy of the data
that represents the current ResultSet data.
The update methods only update the
ResultSet data. | public void | setFetchDirection(int fetchDirection) | public void | setFetchSize(int fetchSize) | public void | setResultSetConcurrency(int resultSetConcurrency) Sets the result set concurrency. | public void | setResultSetHoldability(int resultSetHoldability) Sets the result set holdability. | public void | setResultSetMetaData(ResultSetMetaData resultSetMetaData) Sets the ResultSetMetaData for this ResultSet .
The specified object will be returned when calling
MockResultSet.getMetaData .
If no ResultSetMetaData is set, the method
MockResultSet.getMetaData will return an object of
MockResultSetMetaData . | public void | setResultSetType(int resultSetType) Sets the result set type. | public void | setStatement(Statement statement) Sets the Statement for this ResultSet . | public String | toString() | public Object | unwrap(Class iface) | public void | updateArray(int columnIndex, Array array) | public void | updateArray(String columnName, Array array) | public void | updateAsciiStream(int columnIndex, InputStream stream, int length) | public void | updateAsciiStream(String columnName, InputStream stream, int length) | public void | updateAsciiStream(int columnIndex, InputStream stream, long length) | public void | updateAsciiStream(String columnName, InputStream stream, long length) | public void | updateAsciiStream(int columnIndex, InputStream stream) | public void | updateAsciiStream(String columnName, InputStream stream) | public void | updateBigDecimal(int columnIndex, BigDecimal bigDecimal) | public void | updateBigDecimal(String columnName, BigDecimal bigDecimal) | public void | updateBinaryStream(int columnIndex, InputStream stream, int length) | public void | updateBinaryStream(String columnName, InputStream stream, int length) | public void | updateBinaryStream(int columnIndex, InputStream stream, long length) | public void | updateBinaryStream(String columnName, InputStream stream, long length) | public void | updateBinaryStream(int columnIndex, InputStream stream) | public void | updateBinaryStream(String columnName, InputStream stream) | public void | updateBlob(int columnIndex, Blob blob) | public void | updateBlob(String columnName, Blob blob) | public void | updateBlob(int columnIndex, InputStream stream, long length) | public void | updateBlob(String columnName, InputStream stream, long length) | public void | updateBlob(int columnIndex, InputStream stream) | public void | updateBlob(String columnName, InputStream stream) | public void | updateBoolean(int columnIndex, boolean booleanValue) | public void | updateBoolean(String columnName, boolean booleanValue) | public void | updateByte(int columnIndex, byte byteValue) | public void | updateByte(String columnName, byte byteValue) | public void | updateBytes(int columnIndex, byte[] byteArray) | public void | updateBytes(String columnName, byte[] byteArray) | public void | updateCharacterStream(int columnIndex, Reader reader, int length) | public void | updateCharacterStream(String columnName, Reader reader, int length) | public void | updateCharacterStream(int columnIndex, Reader reader, long length) | public void | updateCharacterStream(String columnName, Reader reader, long length) | public void | updateCharacterStream(int columnIndex, Reader reader) | public void | updateCharacterStream(String columnName, Reader reader) | public void | updateClob(int columnIndex, Clob clob) | public void | updateClob(String columnName, Clob clob) | public void | updateClob(int columnIndex, Reader reader, long length) | public void | updateClob(String columnName, Reader reader, long length) | public void | updateClob(int columnIndex, Reader reader) | public void | updateClob(String columnName, Reader reader) | public void | updateDate(int columnIndex, Date date) | public void | updateDate(String columnName, Date date) | public void | updateDouble(int columnIndex, double doubleValue) | public void | updateDouble(String columnName, double doubleValue) | public void | updateFloat(int columnIndex, float floatValue) | public void | updateFloat(String columnName, float floatValue) | public void | updateInt(int columnIndex, int intValue) | public void | updateInt(String columnName, int intValue) | public void | updateLong(int columnIndex, long longValue) | public void | updateLong(String columnName, long longValue) | public void | updateNCharacterStream(int columnIndex, Reader reader) | public void | updateNCharacterStream(String columnLabel, Reader reader) | public void | updateNCharacterStream(int columnIndex, Reader reader, long length) | public void | updateNCharacterStream(String columnLabel, Reader reader, long length) | public void | updateNString(int columnIndex, String value) | public void | updateNString(String columnLabel, String value) | public void | updateNull(int columnIndex) | public void | updateNull(String columnName) | public void | updateObject(int columnIndex, Object value) | public void | updateObject(int columnIndex, Object value, int scale) | public void | updateObject(String columnName, Object value, int scale) | public void | updateObject(String columnName, Object value) | public void | updateRef(int columnIndex, Ref ref) | public void | updateRef(String columnName, Ref ref) | public void | updateRow() | public void | updateShort(int columnIndex, short shortValue) | public void | updateShort(String columnName, short shortValue) | public void | updateString(int columnIndex, String value) | public void | updateString(String columnName, String value) | public void | updateTime(int columnIndex, Time time) | public void | updateTime(String columnName, Time time) | public void | updateTimestamp(int columnIndex, Timestamp timeStamp) | public void | updateTimestamp(String columnName, Timestamp timeStamp) | public boolean | wasNull() |
addColumn | public void addColumn()(Code) | | Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index. The first added column
will have the name Column1. No data will be stored
in the column.
|
addColumn | public void addColumn(String columnName)(Code) | | Adds a column to the simulated database table.
The column will get the specified name.
No data will be stored in the column.
Parameters: columnName - the column name |
addColumn | public void addColumn(Object[] values)(Code) | | Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index.
The specified data will be stored in the new column. If there
are other columns with not enough rows, the other
columns will be extended and filled with null
values.
Parameters: values - the column data as array, the array indexcorresponds to the row index, i.e.values[0] will be stored in the first rowand so on |
addColumn | public void addColumn(List values)(Code) | | Adds a column to the simulated database table.
The column will get the name ColumnX where
X is the column index.
The specified data will be stored in the new column. If there
are other columns with not enough rows, the other
columns will be extended and filled with null
values.
Parameters: values - the column data as List , the indexin the List corresponds to the row index, i.e. values.get(0) will be stored in the first row and so on |
addColumn | public void addColumn(String columnName, Object[] values)(Code) | | Adds a column to the simulated database table.
The column will get the specified name.
The specified data will be stored in the new column. If there
are other columns with not enough rows, the other
columns will be extended and filled with null
values.
Parameters: columnName - the column name Parameters: values - the column data as array, the array indexcorresponds to the row index, i.e.values[0] will be stored in the first rowand so on |
addColumn | public void addColumn(String columnName, List values)(Code) | | Adds a column to the simulated database table.
The column will get the specified name.
The specified data will be stored in the new column. If there
are other columns with not enough rows, the other
columns will be extended and filled with null
values.
Parameters: columnName - the column name Parameters: values - the column data as List , the indexin the List corresponds to the row index, i.e. values.get(0) will be stored in the first row and so on |
addRow | public void addRow(Object[] values)(Code) | | Adds a row to the simulated database table.
If there are not enough columns (initially there
are no columns, you have to specify them with the
addColumn methods) the missing columns will
be added automatically. Automatically created columns
will get the name ColumnX where X is
the column index.
Parameters: values - the row data as array, the array indexcorresponds to the column index, i.e.values[0] will be stored in the first columnand so on |
addRow | public void addRow(List values)(Code) | | Adds a row to the simulated database table.
If there are not enough columns (initially there
are no columns, you have to specify them with the
addColumn methods) the missing columns will
be added automatically. Automatically created columns
will get the name ColumnX where X is
the column index.
Parameters: values - the row data as List , the indexin the List corresponds to the column index, i.e. values.get(0) will be stored in the first column and so on |
getColumn | public List getColumn(int number)(Code) | | Returns the column with the specified number.
The first column has the number 1.
If number is less than 1 or higher than the
current column count, null will
be returned.
Parameters: number - the number of the column the column data as List |
getColumn | public List getColumn(String name)(Code) | | Returns the column with the specified name.
If a column with that name does not exist,
null will be returned.
Parameters: name - the name of the column the column data as List |
getColumnCount | public int getColumnCount()(Code) | | Returns the current number of columns.
the number of columns |
getId | public String getId()(Code) | | Returns the id of this ResultSet . Ids are used
to identify ResultSet objects in tests, because
they are usually cloned when executing statements, so
you cannot rely on the object identity.
the id of this ResultSet |
getRow | public List getRow(int number)(Code) | | Returns the row with the specified number.
The first row has the number 1.
If number is less than 1 or higher than the
current row count, null will
be returned. The result of this method depends
on the setting of databaseView.
See
MockResultSet.setDatabaseView .
Parameters: number - the number of the row the row data as List |
getRowCount | public int getRowCount()(Code) | | Returns the current number of rows.
the number of rows |
isClosed | public boolean isClosed()(Code) | | Returns if this ResultSet is closed.
true if this ResultSet is closed,false otherwise |
isColumnEqual | public boolean isColumnEqual(int number, List columnData)(Code) | | Returns if the column with the specified number is
equal to the specified data. Uses
com.mockrunner.jdbc.ParameterUtil.compareParameter .
The first column has the number 1. If the compared parameters are not of
the same type (and cannot be equal according to the
com.mockrunner.jdbc.ParameterUtil.compareParameter method) they
will be converted to a string with the toString() method before
comparison.
Parameters: number - the number of the column Parameters: columnData - the column data true if the column is equal to the specified data,false otherwise |
isColumnEqual | public boolean isColumnEqual(String name, List columnData)(Code) | | Returns if the column with the specified name is
equal to the specified data. Uses
com.mockrunner.jdbc.ParameterUtil.compareParameter .
The first column has the number 1. If the compared parameters are not of
the same type (and cannot be equal according to the
com.mockrunner.jdbc.ParameterUtil.compareParameter method) they
will be converted to a string with the toString() method before
comparison.
Parameters: name - the name of the column Parameters: columnData - the column data true if the column is equal to the specified data,false otherwise |
isEqual | public boolean isEqual(MockResultSet resultSet)(Code) | | Returns if the specified ResultSet is equal to
this ResultSet . If the compared parameters are not of
the same type (and cannot be equal according to the
com.mockrunner.jdbc.ParameterUtil.compareParameter method) they
will be converted to a string with the toString() method before
comparison.
true if the two ResultSet objects are equal,false otherwise |
isRowEqual | public boolean isRowEqual(int number, List rowData)(Code) | | Returns if the row with the specified number is
equal to the specified data. Uses
com.mockrunner.jdbc.ParameterUtil.compareParameter .
The first row has the number 1. If the compared parameters are not of
the same type (and cannot be equal according to the
com.mockrunner.jdbc.ParameterUtil.compareParameter method) they
will be converted to a string with the toString() method before
comparison.
Parameters: number - the number of the row Parameters: rowData - the row data true if the row is equal to the specified data,false otherwise |
rowDeleted | public boolean rowDeleted(int number)(Code) | | Returns if the row with the specified number was deleted
The first row has the number 1.
Parameters: number - the number of the row true if the row was deleted,false otherwise |
rowInserted | public boolean rowInserted(int number)(Code) | | Returns if the row with the specified number was inserted
The first row has the number 1.
Parameters: number - the number of the row true if the row was inserted,false otherwise |
rowUpdated | public boolean rowUpdated(int number)(Code) | | Returns if the row with the specified number was updated
The first row has the number 1.
Parameters: number - the number of the row true if the row was updated,false otherwise |
setColumnsCaseSensitive | public void setColumnsCaseSensitive(boolean columnsCaseSensitive)(Code) | | Set if column names are case sensitive. Default is
false . Please note, that switching this
attribute clears and resets the complete ResultSet .
Parameters: columnsCaseSensitive - are column names case sensitive |
setCursorName | public void setCursorName(String cursorName)(Code) | | Sets the cursor name. It's not possible to set
this in a real ResultSet .
Parameters: cursorName - the cursor name |
setDatabaseView | public void setDatabaseView(boolean databaseView)(Code) | | The MockResultSet keeps the data that's
stored in the simulated database and a copy of the data
that represents the current ResultSet data.
The update methods only update the
ResultSet data. This data will be persisted
when you call
MockResultSet.updateRow . When you set databaseView
to true the get methods will return the
data in the database, otherwise the current ResultSet
data is returned.
Parameters: databaseView - false = get the data from the ResultSet , true = get the datafrom the database, default is false |
setFetchDirection | public void setFetchDirection(int fetchDirection) throws SQLException(Code) | | |
setResultSetConcurrency | public void setResultSetConcurrency(int resultSetConcurrency)(Code) | | Sets the result set concurrency. It's not possible to set
this in a real ResultSet , but in tests
it can make sense to change it.
Parameters: resultSetConcurrency - the result set concurrency |
setResultSetHoldability | public void setResultSetHoldability(int resultSetHoldability)(Code) | | Sets the result set holdability. It's not possible to set
this in a real ResultSet , but in tests
it can make sense to change it.
Parameters: resultSetHoldability - the result set holdability |
setResultSetMetaData | public void setResultSetMetaData(ResultSetMetaData resultSetMetaData)(Code) | | Sets the ResultSetMetaData for this ResultSet .
The specified object will be returned when calling
MockResultSet.getMetaData .
If no ResultSetMetaData is set, the method
MockResultSet.getMetaData will return an object of
MockResultSetMetaData . The
MockResultSetMetaData returns default values for most
of its attributes (however the correct number of columns will be
returned). Usually you do not have to set the ResultSetMetaData .
Parameters: resultSetMetaData - the ResultSetMetaData |
setResultSetType | public void setResultSetType(int resultSetType)(Code) | | Sets the result set type. It's not possible to set
this in a real ResultSet , but in tests
it can make sense to change it.
Parameters: resultSetType - the result set type |
setStatement | public void setStatement(Statement statement)(Code) | | Sets the Statement for this ResultSet .
The ResultSet takes the result set type, result
set concurrency and the fetch direction from the specified
Statement .
Parameters: statement - the statement |
updateBoolean | public void updateBoolean(int columnIndex, boolean booleanValue) throws SQLException(Code) | | |
updateByte | public void updateByte(int columnIndex, byte byteValue) throws SQLException(Code) | | |
updateBytes | public void updateBytes(int columnIndex, byte[] byteArray) throws SQLException(Code) | | |
updateCharacterStream | public void updateCharacterStream(int columnIndex, Reader reader, int length) throws SQLException(Code) | | |
updateCharacterStream | public void updateCharacterStream(int columnIndex, Reader reader, long length) throws SQLException(Code) | | |
updateDouble | public void updateDouble(int columnIndex, double doubleValue) throws SQLException(Code) | | |
updateFloat | public void updateFloat(int columnIndex, float floatValue) throws SQLException(Code) | | |
updateLong | public void updateLong(int columnIndex, long longValue) throws SQLException(Code) | | |
updateNCharacterStream | public void updateNCharacterStream(int columnIndex, Reader reader, long length) throws SQLException(Code) | | |
updateShort | public void updateShort(int columnIndex, short shortValue) throws SQLException(Code) | | |
|
|