net.spy.db
Class GenericResultSetStub

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.db.GenericResultSetStub
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
CachedResultSetStub, FileResultSetStub

public abstract class GenericResultSetStub
extends SpyObject
implements java.lang.Cloneable

This object contains all the common stuff required to stub a ResultSet implementation.


Constructor Summary
protected GenericResultSetStub()
          Get an instance of a GenericResultSetStub with no initialization.
  GenericResultSetStub(java.sql.ResultSet rs)
          Magically transform the passed in ResultSet to a GenericResultSetStub
 
Method Summary
 void clearWarnings()
           
 void close()
          Close the ResultSet.
 int findColumn(java.lang.String columnName)
           
 java.math.BigDecimal getBigDecimal(int index)
           
 java.math.BigDecimal getBigDecimal(java.lang.String name)
           
 boolean getBoolean(int index)
          Get the given value as a boolean.
 boolean getBoolean(java.lang.String name)
           
 java.sql.Date getDate(int index)
           
 java.sql.Date getDate(java.lang.String name)
           
 double getDouble(int index)
           
 double getDouble(java.lang.String name)
           
 float getFloat(int index)
           
 float getFloat(java.lang.String name)
           
 int getInt(int index)
           
 int getInt(java.lang.String name)
           
 long getLong(int index)
           
 long getLong(java.lang.String name)
           
 java.sql.ResultSetMetaData getMetaData()
           
 java.lang.Object getObject(int index)
           
 java.lang.Object getObject(java.lang.String name)
           
protected  java.lang.Object getResultColumn(int index)
          Get the Object at the given result column for the current result row.
 short getShort(int index)
           
 short getShort(java.lang.String name)
           
 java.lang.String getString(int index)
          Get the given column as a string.
 java.lang.String getString(java.lang.String name)
           
 java.sql.Time getTime(int index)
           
 java.sql.Time getTime(java.lang.String name)
           
 java.sql.Timestamp getTimestamp(int index)
           
 java.sql.Timestamp getTimestamp(java.lang.String name)
           
 java.sql.SQLWarning getWarnings()
           
 boolean next()
          Seek to the next row in this ResultSet.
protected  void resetResults()
          Reset the results to the beginning.
protected  void setMetaData(java.sql.ResultSetMetaData rsmd)
          Set the ResultSetMetaData used for this ResultSet.
protected  void setResults(java.util.List to)
          Set the results for this ResultSet to use.
 java.lang.String toString()
          Debug routine for displaying the current row of the ResultSet.
 boolean wasNull()
          Check to see if the last column fetched was null.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericResultSetStub

public GenericResultSetStub(java.sql.ResultSet rs)
                     throws java.sql.SQLException
Magically transform the passed in ResultSet to a GenericResultSetStub

Parameters:
rs - the ResultSet we want to magically transform
Throws:
java.sql.SQLException - if the ResultSet somehow fails us.

GenericResultSetStub

protected GenericResultSetStub()
                        throws java.sql.SQLException
Get an instance of a GenericResultSetStub with no initialization. The subclass is expected to do whatever is necessary, and then call setResults(List) and setMetaData(ResultSetMetaData) to make everything happy.

Throws:
java.sql.SQLException - (never)
Method Detail

resetResults

protected void resetResults()
Reset the results to the beginning.


setResults

protected void setResults(java.util.List to)
Set the results for this ResultSet to use.

Parameters:
to - results list to use

setMetaData

protected void setMetaData(java.sql.ResultSetMetaData rsmd)
                    throws java.sql.SQLException
Set the ResultSetMetaData used for this ResultSet.

Parameters:
rsmd - the ResultSetMetaData
Throws:
java.sql.SQLException - if there's a problem examining the signature

getResultColumn

protected java.lang.Object getResultColumn(int index)
                                    throws java.sql.SQLException
Get the Object at the given result column for the current result row.

Parameters:
index - the numeric index of the column
Returns:
whatever Object is found at that column (may be null)
Throws:
java.sql.SQLException - if there is not a current ResultSet row, or the index is out of bounds

toString

public java.lang.String toString()
Debug routine for displaying the current row of the ResultSet.

Overrides:
toString in class java.lang.Object

next

public boolean next()
             throws java.sql.SQLException
Seek to the next row in this ResultSet.

Returns:
true if there was another row.
Throws:
java.sql.SQLException - if there's a problem seeking...or something

close

public void close()
           throws java.sql.SQLException
Close the ResultSet. This currently does nothing.

Throws:
java.sql.SQLException - (never)

wasNull

public boolean wasNull()
                throws java.sql.SQLException
Check to see if the last column fetched was null.

Returns:
true if it was null
Throws:
java.sql.SQLException - (never)

getString

public java.lang.String getString(int index)
                           throws java.sql.SQLException
Get the given column as a string.

Parameters:
index - the index of the column
Returns:
the String value of the column, or null
Throws:
java.sql.SQLException - if misused

getBoolean

public boolean getBoolean(int index)
                   throws java.sql.SQLException
Get the given value as a boolean.

Parameters:
index - the index of the column
Returns:
the boolean value of the column
Throws:
java.sql.SQLException - if there's a problem getting the value

getShort

public short getShort(int index)
               throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getInt

public int getInt(int index)
           throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getLong

public long getLong(int index)
             throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getFloat

public float getFloat(int index)
               throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getDouble

public double getDouble(int index)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getBigDecimal

public java.math.BigDecimal getBigDecimal(int index)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getDate

public java.sql.Date getDate(int index)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getTime

public java.sql.Time getTime(int index)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getTimestamp

public java.sql.Timestamp getTimestamp(int index)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getObject

public java.lang.Object getObject(int index)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

findColumn

public int findColumn(java.lang.String columnName)
               throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getString

public java.lang.String getString(java.lang.String name)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getBoolean

public boolean getBoolean(java.lang.String name)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getShort

public short getShort(java.lang.String name)
               throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getInt

public int getInt(java.lang.String name)
           throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getLong

public long getLong(java.lang.String name)
             throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getFloat

public float getFloat(java.lang.String name)
               throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getDouble

public double getDouble(java.lang.String name)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getDate

public java.sql.Date getDate(java.lang.String name)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getTime

public java.sql.Time getTime(java.lang.String name)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String name)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String name)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getObject

public java.lang.Object getObject(java.lang.String name)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet

getMetaData

public java.sql.ResultSetMetaData getMetaData()
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException
See Also:
ResultSet


Copyright © 1995-2005 SPY Internetworking. All Rights Reserved.