org.apache.commons.dbcp
Class DelegatingResultSet

java.lang.Object
  extended by org.apache.commons.dbcp.AbandonedTrace
      extended by org.apache.commons.dbcp.DelegatingResultSet
All Implemented Interfaces:
ResultSet

public class DelegatingResultSet
extends AbandonedTrace
implements ResultSet

A base delegating implementation of ResultSet.

All of the methods from the ResultSet interface simply call the corresponding method on the "delegate" provided in my constructor.

Extends AbandonedTrace to implement result set tracking and logging of code which created the ResultSet. Tracking the ResultSet ensures that the Statment which created it can close any open ResultSet's on Statement close.

Version:
$Revision: 479137 $ $Date: 2006-11-25 08:51:48 -0700 (Sat, 25 Nov 2006) $
Author:
Glenn L. Nielsen, James House, Dirk Verbeeck

Field Summary
 
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
 
Constructor Summary
DelegatingResultSet(Statement stmt, ResultSet res)
          Create a wrapper for the ResultSet which traces this ResultSet to the Statement which created it and the code which created it.
 
Method Summary
 boolean absolute(int row)
           
 void afterLast()
           
 void beforeFirst()
           
 void cancelRowUpdates()
           
 void clearWarnings()
           
 void close()
          Wrapper for close of ResultSet which removes this result set from being traced then calls close on the original ResultSet.
 void deleteRow()
           
 boolean equals(Object obj)
           
 int findColumn(String columnName)
           
 boolean first()
           
 Array getArray(int i)
           
 Array getArray(String colName)
           
 InputStream getAsciiStream(int columnIndex)
           
 InputStream getAsciiStream(String columnName)
           
 BigDecimal getBigDecimal(int columnIndex)
           
 BigDecimal getBigDecimal(int columnIndex, int scale)
          Deprecated.  
 BigDecimal getBigDecimal(String columnName)
           
 BigDecimal getBigDecimal(String columnName, int scale)
          Deprecated.  
 InputStream getBinaryStream(int columnIndex)
           
 InputStream getBinaryStream(String columnName)
           
 Blob getBlob(int i)
           
 Blob getBlob(String colName)
           
 boolean getBoolean(int columnIndex)
           
 boolean getBoolean(String columnName)
           
 byte getByte(int columnIndex)
           
 byte getByte(String columnName)
           
 byte[] getBytes(int columnIndex)
           
 byte[] getBytes(String columnName)
           
 Reader getCharacterStream(int columnIndex)
           
 Reader getCharacterStream(String columnName)
           
 Clob getClob(int i)
           
 Clob getClob(String colName)
           
 int getConcurrency()
           
 String getCursorName()
           
 Date getDate(int columnIndex)
           
 Date getDate(int columnIndex, Calendar cal)
           
 Date getDate(String columnName)
           
 Date getDate(String columnName, Calendar cal)
           
 ResultSet getDelegate()
           
 double getDouble(int columnIndex)
           
 double getDouble(String columnName)
           
 int getFetchDirection()
           
 int getFetchSize()
           
 float getFloat(int columnIndex)
           
 float getFloat(String columnName)
           
 ResultSet getInnermostDelegate()
          If my underlying ResultSet is not a DelegatingResultSet, returns it, otherwise recursively invokes this method on my delegate.
 int getInt(int columnIndex)
           
 int getInt(String columnName)
           
 long getLong(int columnIndex)
           
 long getLong(String columnName)
           
 ResultSetMetaData getMetaData()
           
 Object getObject(int columnIndex)
           
 Object getObject(int i, Map map)
           
 Object getObject(String columnName)
           
 Object getObject(String colName, Map map)
           
 Ref getRef(int i)
           
 Ref getRef(String colName)
           
 int getRow()
           
 short getShort(int columnIndex)
           
 short getShort(String columnName)
           
 Statement getStatement()
           
 String getString(int columnIndex)
           
 String getString(String columnName)
           
 Time getTime(int columnIndex)
           
 Time getTime(int columnIndex, Calendar cal)
           
 Time getTime(String columnName)
           
 Time getTime(String columnName, Calendar cal)
           
 Timestamp getTimestamp(int columnIndex)
           
 Timestamp getTimestamp(int columnIndex, Calendar cal)
           
 Timestamp getTimestamp(String columnName)
           
 Timestamp getTimestamp(String columnName, Calendar cal)
           
 int getType()
           
 InputStream getUnicodeStream(int columnIndex)
          Deprecated.  
 InputStream getUnicodeStream(String columnName)
          Deprecated.  
 URL getURL(int columnIndex)
           
 URL getURL(String columnName)
           
 SQLWarning getWarnings()
           
protected  void handleException(SQLException e)
           
 int hashCode()
           
 void insertRow()
           
 boolean isAfterLast()
           
 boolean isBeforeFirst()
           
 boolean isFirst()
           
 boolean isLast()
           
 boolean last()
           
 void moveToCurrentRow()
           
 void moveToInsertRow()
           
 boolean next()
           
 boolean previous()
           
 void refreshRow()
           
 boolean relative(int rows)
           
 boolean rowDeleted()
           
 boolean rowInserted()
           
 boolean rowUpdated()
           
 void setFetchDirection(int direction)
           
 void setFetchSize(int rows)
           
 void updateArray(int columnIndex, Array x)
           
 void updateArray(String columnName, Array x)
           
 void updateAsciiStream(int columnIndex, InputStream x, int length)
           
 void updateAsciiStream(String columnName, InputStream x, int length)
           
 void updateBigDecimal(int columnIndex, BigDecimal x)
           
 void updateBigDecimal(String columnName, BigDecimal x)
           
 void updateBinaryStream(int columnIndex, InputStream x, int length)
           
 void updateBinaryStream(String columnName, InputStream x, int length)
           
 void updateBlob(int columnIndex, Blob x)
           
 void updateBlob(String columnName, Blob x)
           
 void updateBoolean(int columnIndex, boolean x)
           
 void updateBoolean(String columnName, boolean x)
           
 void updateByte(int columnIndex, byte x)
           
 void updateByte(String columnName, byte x)
           
 void updateBytes(int columnIndex, byte[] x)
           
 void updateBytes(String columnName, byte[] x)
           
 void updateCharacterStream(int columnIndex, Reader x, int length)
           
 void updateCharacterStream(String columnName, Reader reader, int length)
           
 void updateClob(int columnIndex, Clob x)
           
 void updateClob(String columnName, Clob x)
           
 void updateDate(int columnIndex, Date x)
           
 void updateDate(String columnName, Date x)
           
 void updateDouble(int columnIndex, double x)
           
 void updateDouble(String columnName, double x)
           
 void updateFloat(int columnIndex, float x)
           
 void updateFloat(String columnName, float x)
           
 void updateInt(int columnIndex, int x)
           
 void updateInt(String columnName, int x)
           
 void updateLong(int columnIndex, long x)
           
 void updateLong(String columnName, long x)
           
 void updateNull(int columnIndex)
           
 void updateNull(String columnName)
           
 void updateObject(int columnIndex, Object x)
           
 void updateObject(int columnIndex, Object x, int scale)
           
 void updateObject(String columnName, Object x)
           
 void updateObject(String columnName, Object x, int scale)
           
 void updateRef(int columnIndex, Ref x)
           
 void updateRef(String columnName, Ref x)
           
 void updateRow()
           
 void updateShort(int columnIndex, short x)
           
 void updateShort(String columnName, short x)
           
 void updateString(int columnIndex, String x)
           
 void updateString(String columnName, String x)
           
 void updateTime(int columnIndex, Time x)
           
 void updateTime(String columnName, Time x)
           
 void updateTimestamp(int columnIndex, Timestamp x)
           
 void updateTimestamp(String columnName, Timestamp x)
           
 boolean wasNull()
           
static ResultSet wrapResultSet(Statement stmt, ResultSet rset)
           
 
Methods inherited from class org.apache.commons.dbcp.AbandonedTrace
addTrace, clearTrace, getConfig, getLastUsed, getTrace, printStackTrace, removeTrace, setLastUsed, setLastUsed, setStackTrace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingResultSet

public DelegatingResultSet(Statement stmt,
                           ResultSet res)
Create a wrapper for the ResultSet which traces this ResultSet to the Statement which created it and the code which created it.

Parameters:
stmt - Statement which created this ResultSet
res - ResultSet to wrap
Method Detail

wrapResultSet

public static ResultSet wrapResultSet(Statement stmt,
                                      ResultSet rset)

getDelegate

public ResultSet getDelegate()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getInnermostDelegate

public ResultSet getInnermostDelegate()
If my underlying ResultSet is not a DelegatingResultSet, returns it, otherwise recursively invokes this method on my delegate.

Hence this method will return the first delegate that is not a DelegatingResultSet, or null when no non-DelegatingResultSet delegate can be found by transversing this chain.

This method is useful when you may have nested DelegatingResultSets, and you want to make sure to obtain a "genuine" ResultSet.


getStatement

public Statement getStatement()
                       throws SQLException
Specified by:
getStatement in interface ResultSet
Throws:
SQLException

close

public void close()
           throws SQLException
Wrapper for close of ResultSet which removes this result set from being traced then calls close on the original ResultSet.

Specified by:
close in interface ResultSet
Throws:
SQLException

handleException

protected void handleException(SQLException e)
                        throws SQLException
Throws:
SQLException

next

public boolean next()
             throws SQLException
Specified by:
next in interface ResultSet
Throws:
SQLException

wasNull

public boolean wasNull()
                throws SQLException
Specified by:
wasNull in interface ResultSet
Throws:
SQLException

getString

public String getString(int columnIndex)
                 throws SQLException
Specified by:
getString in interface ResultSet
Throws:
SQLException

getBoolean

public boolean getBoolean(int columnIndex)
                   throws SQLException
Specified by:
getBoolean in interface ResultSet
Throws:
SQLException

getByte

public byte getByte(int columnIndex)
             throws SQLException
Specified by:
getByte in interface ResultSet
Throws:
SQLException

getShort

public short getShort(int columnIndex)
               throws SQLException
Specified by:
getShort in interface ResultSet
Throws:
SQLException

getInt

public int getInt(int columnIndex)
           throws SQLException
Specified by:
getInt in interface ResultSet
Throws:
SQLException

getLong

public long getLong(int columnIndex)
             throws SQLException
Specified by:
getLong in interface ResultSet
Throws:
SQLException

getFloat

public float getFloat(int columnIndex)
               throws SQLException
Specified by:
getFloat in interface ResultSet
Throws:
SQLException

getDouble

public double getDouble(int columnIndex)
                 throws SQLException
Specified by:
getDouble in interface ResultSet
Throws:
SQLException

getBigDecimal

public BigDecimal getBigDecimal(int columnIndex,
                                int scale)
                         throws SQLException
Deprecated. 

Specified by:
getBigDecimal in interface ResultSet
Throws:
SQLException

getBytes

public byte[] getBytes(int columnIndex)
                throws SQLException
Specified by:
getBytes in interface ResultSet
Throws:
SQLException

getDate

public Date getDate(int columnIndex)
             throws SQLException
Specified by:
getDate in interface ResultSet
Throws:
SQLException

getTime

public Time getTime(int columnIndex)
             throws SQLException
Specified by:
getTime in interface ResultSet
Throws:
SQLException

getTimestamp

public Timestamp getTimestamp(int columnIndex)
                       throws SQLException
Specified by:
getTimestamp in interface ResultSet
Throws:
SQLException

getAsciiStream

public InputStream getAsciiStream(int columnIndex)
                           throws SQLException
Specified by:
getAsciiStream in interface ResultSet
Throws:
SQLException

getUnicodeStream

public InputStream getUnicodeStream(int columnIndex)
                             throws SQLException
Deprecated. 

Specified by:
getUnicodeStream in interface ResultSet
Throws:
SQLException

getBinaryStream

public InputStream getBinaryStream(int columnIndex)
                            throws SQLException
Specified by:
getBinaryStream in interface ResultSet
Throws:
SQLException

getString

public String getString(String columnName)
                 throws SQLException
Specified by:
getString in interface ResultSet
Throws:
SQLException

getBoolean

public boolean getBoolean(String columnName)
                   throws SQLException
Specified by:
getBoolean in interface ResultSet
Throws:
SQLException

getByte

public byte getByte(String columnName)
             throws SQLException
Specified by:
getByte in interface ResultSet
Throws:
SQLException

getShort

public short getShort(String columnName)
               throws SQLException
Specified by:
getShort in interface ResultSet
Throws:
SQLException

getInt

public int getInt(String columnName)
           throws SQLException
Specified by:
getInt in interface ResultSet
Throws:
SQLException

getLong

public long getLong(String columnName)
             throws SQLException
Specified by:
getLong in interface ResultSet
Throws:
SQLException

getFloat

public float getFloat(String columnName)
               throws SQLException
Specified by:
getFloat in interface ResultSet
Throws:
SQLException

getDouble

public double getDouble(String columnName)
                 throws SQLException
Specified by:
getDouble in interface ResultSet
Throws:
SQLException

getBigDecimal

public BigDecimal getBigDecimal(String columnName,
                                int scale)
                         throws SQLException
Deprecated. 

Specified by:
getBigDecimal in interface ResultSet
Throws:
SQLException

getBytes

public byte[] getBytes(String columnName)
                throws SQLException
Specified by:
getBytes in interface ResultSet
Throws:
SQLException

getDate

public Date getDate(String columnName)
             throws SQLException
Specified by:
getDate in interface ResultSet
Throws:
SQLException

getTime

public Time getTime(String columnName)
             throws SQLException
Specified by:
getTime in interface ResultSet
Throws:
SQLException

getTimestamp

public Timestamp getTimestamp(String columnName)
                       throws SQLException
Specified by:
getTimestamp in interface ResultSet
Throws:
SQLException

getAsciiStream

public InputStream getAsciiStream(String columnName)
                           throws SQLException
Specified by:
getAsciiStream in interface ResultSet
Throws:
SQLException

getUnicodeStream

public InputStream getUnicodeStream(String columnName)
                             throws SQLException
Deprecated. 

Specified by:
getUnicodeStream in interface ResultSet
Throws:
SQLException

getBinaryStream

public InputStream getBinaryStream(String columnName)
                            throws SQLException
Specified by:
getBinaryStream in interface ResultSet
Throws:
SQLException

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Specified by:
getWarnings in interface ResultSet
Throws:
SQLException

clearWarnings

public void clearWarnings()
                   throws SQLException
Specified by:
clearWarnings in interface ResultSet
Throws:
SQLException

getCursorName

public String getCursorName()
                     throws SQLException
Specified by:
getCursorName in interface ResultSet
Throws:
SQLException

getMetaData

public ResultSetMetaData getMetaData()
                              throws SQLException
Specified by:
getMetaData in interface ResultSet
Throws:
SQLException

getObject

public Object getObject(int columnIndex)
                 throws SQLException
Specified by:
getObject in interface ResultSet
Throws:
SQLException

getObject

public