com.mysql.jdbc
Class ResultSetRow

java.lang.Object
  extended by com.mysql.jdbc.ResultSetRow
Direct Known Subclasses:
BufferRow, ByteArrayRow

public abstract class ResultSetRow
extends java.lang.Object

Classes that implement this interface represent one row of data from the MySQL server that might be stored in different ways depending on whether the result set was streaming (so they wrap a reusable packet), or whether the result set was cached or via a server-side cursor (so they represent a byte[][]). Notice that no bounds checking is expected for implementors of this interface, it happens in ResultSetImpl.


Field Summary
protected  ExceptionInterceptor exceptionInterceptor
           
protected  Field[] metadata
          The metadata of the fields of this result set.
 
Constructor Summary
protected ResultSetRow(ExceptionInterceptor exceptionInterceptor)
           
 
Method Summary
abstract  void closeOpenStreams()
          Called during navigation to next row to close all open streams.
abstract  java.io.InputStream getBinaryInputStream(int columnIndex)
          Returns data at the given index as an InputStream with no character conversion.
abstract  int getBytesSize()
           
abstract  byte[] getColumnValue(int index)
          Returns the value at the given column (index starts at 0) "raw" (i.e.
protected  java.sql.Date getDateFast(int columnIndex, byte[] dateAsBytes, int offset, int length, ConnectionImpl conn, ResultSetImpl rs, java.util.Calendar targetCalendar)
           
abstract  java.sql.Date getDateFast(int columnIndex, ConnectionImpl conn, ResultSetImpl rs, java.util.Calendar targetCalendar)
           
abstract  int getInt(int columnIndex)
          Returns the value at the given column (index starts at 0) as an int
abstract  long getLong(int columnIndex)
          Returns the value at the given column (index starts at 0) as a long
protected  java.sql.Date getNativeDate(int columnIndex, byte[] bits, int offset, int length, ConnectionImpl conn, ResultSetImpl rs, java.util.Calendar cal)
           
abstract  java.sql.Date getNativeDate(int columnIndex, ConnectionImpl conn, ResultSetImpl rs, java.util.Calendar cal)
           
protected  java.lang.Object getNativeDateTimeValue(int columnIndex, byte[] bits, int offset, int length, java.util.Calendar targetCalendar, int jdbcType, int mysqlType, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.lang.Object getNativeDateTimeValue(int columnIndex, java.util.Calendar targetCalendar, int jdbcType, int mysqlType, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
protected  double getNativeDouble(byte[] bits, int offset)
           
abstract  double getNativeDouble(int columnIndex)
           
protected  float getNativeFloat(byte[] bits, int offset)
           
abstract  float getNativeFloat(int columnIndex)
           
protected  int getNativeInt(byte[] bits, int offset)
           
abstract  int getNativeInt(int columnIndex)
           
protected  long getNativeLong(byte[] bits, int offset)
           
abstract  long getNativeLong(int columnIndex)
           
protected  short getNativeShort(byte[] bits, int offset)
           
abstract  short getNativeShort(int columnIndex)
           
protected  java.sql.Time getNativeTime(int columnIndex, byte[] bits, int offset, int length, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.sql.Time getNativeTime(int columnIndex, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
protected  java.sql.Timestamp getNativeTimestamp(byte[] bits, int offset, int length, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.sql.Timestamp getNativeTimestamp(int columnIndex, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.io.Reader getReader(int columnIndex)
           
abstract  java.lang.String getString(int index, java.lang.String encoding, ConnectionImpl conn)
          Returns the value at the given column (index starts at 0) as a java.lang.String with the requested encoding, using the given ConnectionImpl to find character converters.
protected  java.lang.String getString(java.lang.String encoding, ConnectionImpl conn, byte[] value, int offset, int length)
          Convenience method for turning a byte[] into a string with the given encoding.
protected  java.sql.Time getTimeFast(int columnIndex, byte[] timeAsBytes, int offset, int length, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.sql.Time getTimeFast(int columnIndex, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
protected  java.sql.Timestamp getTimestampFast(int columnIndex, byte[] timestampAsBytes, int offset, int length, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  java.sql.Timestamp getTimestampFast(int columnIndex, java.util.Calendar targetCalendar, java.util.TimeZone tz, boolean rollForward, ConnectionImpl conn, ResultSetImpl rs)
           
abstract  boolean isFloatingPointNumber(int index)
          Could the column value at the given index (which starts at 0) be interpreted as a floating-point number (has +/-/E/e in it)?
abstract  boolean isNull(int index)
          Is the column value at the given index (which starts at 0) NULL?
abstract  long length(int index)
          Returns the length of the column at the given index (which starts at 0).
abstract  void setColumnValue(int index, byte[] value)
          Sets the given column value (only works currently with ByteArrayRowHolder).
 ResultSetRow setMetadata(Field[] f)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exceptionInterceptor

protected ExceptionInterceptor exceptionInterceptor

metadata

protected Field[] metadata
The metadata of the fields of this result set.

Constructor Detail

ResultSetRow

protected ResultSetRow(ExceptionInterceptor exceptionInterceptor)
Method Detail

closeOpenStreams

public abstract void closeOpenStreams()
Called during navigation to next row to close all open streams.


getBinaryInputStream

public abstract java.io.InputStream getBinaryInputStream(int columnIndex)
                                                  throws java.sql.SQLException
Returns data at the given index as an InputStream with no character conversion.

Parameters:
columnIndex - of the column value (starting at 0) to return.
Returns:
the value at the given index as an InputStream or null if null.
Throws:
java.sql.SQLException - if an error occurs while retrieving the value.

getColumnValue

public abstract byte[] getColumnValue(int index)
                               throws java.sql.SQLException
Returns the value at the given column (index starts at 0) "raw" (i.e. as-returned by the server).

Parameters:
index - of the column value (starting at 0) to return.
Returns:
the value for the given column (including NULL if it is)
Throws:
java.sql.SQLException - if an error occurs while retrieving the value.

getDateFast

protected final java.sql.Date getDateFast(int columnIndex,
                                          byte[] dateAsBytes,
                                          int offset,
                                          int length,
                                          ConnectionImpl conn,
                                          ResultSetImpl rs,
                                          java.util.Calendar targetCalendar)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getDateFast

public abstract java.sql.Date getDateFast(int columnIndex,
                                          ConnectionImpl conn,
                                          ResultSetImpl rs,
                                          java.util.Calendar targetCalendar)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getInt

public abstract int getInt(int columnIndex)
                    throws java.sql.SQLException
Returns the value at the given column (index starts at 0) as an int. *

Parameters:
index - of the column value (starting at 0) to return.
Returns:
the value for the given column (returns 0 if NULL, use isNull() to determine if the value was actually NULL)
Throws:
java.sql.SQLException - if an error occurs while retrieving the value.

getLong

public abstract long getLong(int columnIndex)
                      throws java.sql.SQLException
Returns the value at the given column (index starts at 0) as a long. *

Parameters:
index - of the column value (starting at 0) to return.
Returns:
the value for the given column (returns 0 if NULL, use isNull() to determine if the value was actually NULL)
Throws:
java.sql.SQLException - if an error occurs while retrieving the value.

getNativeDate

protected java.sql.Date getNativeDate(int columnIndex,
                                      byte[] bits,
                                      int offset,
                                      int length,
                                      ConnectionImpl conn,
                                      ResultSetImpl rs,
                                      java.util.Calendar cal)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeDate

public abstract java.sql.Date getNativeDate(int columnIndex,
                                            ConnectionImpl conn,
                                            ResultSetImpl rs,
                                            java.util.Calendar cal)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeDateTimeValue

protected java.lang.Object getNativeDateTimeValue(int columnIndex,
                                                  byte[] bits,
                                                  int offset,
                                                  int length,
                                                  java.util.Calendar targetCalendar,
                                                  int jdbcType,
                                                  int mysqlType,
                                                  java.util.TimeZone tz,
                                                  boolean rollForward,
                                                  ConnectionImpl conn,
                                                  ResultSetImpl rs)
                                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeDateTimeValue

public abstract java.lang.Object getNativeDateTimeValue(int columnIndex,
                                                        java.util.Calendar targetCalendar,
                                                        int jdbcType,
                                                        int mysqlType,
                                                        java.util.TimeZone tz,
                                                        boolean rollForward,
                                                        ConnectionImpl conn,
                                                        ResultSetImpl rs)
                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeDouble

protected double getNativeDouble(byte[] bits,
                                 int offset)

getNativeDouble

public abstract double getNativeDouble(int columnIndex)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeFloat

protected float getNativeFloat(byte[] bits,
                               int offset)

getNativeFloat

public abstract float getNativeFloat(int columnIndex)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeInt

protected int getNativeInt(byte[] bits,
                           int offset)

getNativeInt

public abstract int getNativeInt(int columnIndex)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeLong

protected long getNativeLong(byte[] bits,
                             int offset)

getNativeLong

public abstract long getNativeLong(int columnIndex)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeShort

protected short getNativeShort(byte[] bits,
                               int offset)

getNativeShort

public abstract short getNativeShort(int columnIndex)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeTime

protected java.sql.Time getNativeTime(int columnIndex,
                                      byte[] bits,
                                      int offset,
                                      int length,
                                      java.util.Calendar targetCalendar,
                                      java.util.TimeZone tz,
                                      boolean rollForward,
                                      ConnectionImpl conn,
                                      ResultSetImpl rs)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeTime

public abstract java.sql.Time getNativeTime(int columnIndex,
                                            java.util.Calendar targetCalendar,
                                            java.util.TimeZone tz,
                                            boolean rollForward,
                                            ConnectionImpl conn,
                                            ResultSetImpl rs)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeTimestamp

protected java.sql.Timestamp getNativeTimestamp(byte[] bits,
                                                int offset,
                                                int length,
                                                java.util.Calendar targetCalendar,
                                                java.util.TimeZone tz,
                                                boolean rollForward,
                                                ConnectionImpl conn,
                                                ResultSetImpl rs)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

getNativeTimestamp

public abstract java.sql.Timestamp getNativeTimestamp(int columnIndex,
                                                      java.util.Calendar targetCalendar,
                                                      java.util.TimeZone tz,
                                                      boolean rollForward,
                                                      ConnectionImpl conn,
                                                      ResultSetImpl rs)
                                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getReader

public abstract java.io.Reader getReader(int columnIndex)
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

getString

public abstract java.lang.String getString(int index,
                                           java.lang.String encoding,
                                           ConnectionImpl conn)
                                    throws java.sql.SQLException
Returns the value at the given column (index starts at 0) as a java.lang.String with the requested encoding, using the given ConnectionImpl to find character converters.

Parameters:
index - of the column value (starting at 0) to return.
encoding - the Java name for the character encoding
conn - the connection that created this result set row
Returns:
the value for the given column (including NULL if it is) as a String
Throws:
java.sql.SQLException - if an error occurs while retrieving the value.

getString

protected java.lang.String getString(java.lang.String encoding,
                                     ConnectionImpl conn,
                                     byte[] value,
                                     int offset,
                                     int length)
                              throws java.sql.SQLException
Convenience method for turning a byte[] into a string with the given encoding.

Parameters:
encoding - the Java encoding name for the byte[] -> char conversion
conn - the ConnectionImpl that created the result set
value - the String value as a series of bytes, encoded using "encoding"
offset - where to start the decoding
length - how many bytes to decode
Returns:
the String as decoded from bytes with the given encoding
Throws:
java.sql.SQLException - if an error occurs

getTimeFast

protected java.sql.Time getTimeFast(int columnIndex,
                                    byte[] timeAsBytes,
                                    int offset,
                                    int length,
                                    java.util.Calendar targetCalendar,
                                    java.util.TimeZone tz,
                                    boolean rollForward,
                                    ConnectionImpl conn,
                                    ResultSetImpl rs)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

getTimeFast

public abstract java.sql.Time getTimeFast(int columnIndex,
                                          java.util.Calendar targetCalendar,
                                          java.util.TimeZone tz,
                                          boolean rollForward,
                                          ConnectionImpl conn,
                                          ResultSetImpl rs)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getTimestampFast

protected java.sql.Timestamp getTimestampFast(int columnIndex,
                                              byte[] timestampAsBytes,
                                              int offset,
                                              int length,
                                              java.util.Calendar targetCalendar,
                                              java.util.TimeZone tz,
                                              boolean rollForward,
                                              ConnectionImpl conn,
                                              ResultSetImpl rs)
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getTimestampFast

public abstract java.sql.Timestamp getTimestampFast(int columnIndex,
                                                    java.util.Calendar targetCalendar,
                                                    java.util.TimeZone tz,
                                                    boolean rollForward,
                                                    ConnectionImpl conn,
                                                    ResultSetImpl rs)
                                             throws java.sql.SQLException
Throws:
java.sql.SQLException

isFloatingPointNumber

public abstract boolean isFloatingPointNumber(int index)
                                       throws java.sql.SQLException
Could the column value at the given index (which starts at 0) be interpreted as a floating-point number (has +/-/E/e in it)?

Parameters:
index - of the column value (starting at 0) to check.
Returns:
true if the column value at the given index looks like it might be a floating-point number, false if not.
Throws:
java.sql.SQLException - if an error occurs

isNull

public abstract boolean isNull(int index)
                        throws java.sql.SQLException
Is the column value at the given index (which starts at 0) NULL?

Parameters:
index - of the column value (starting at 0) to check.
Returns:
true if the column value is NULL, false if not.
Throws:
java.sql.SQLException - if an error occurs

length

public abstract long length(int index)
                     throws java.sql.SQLException
Returns the length of the column at the given index (which starts at 0).

Parameters:
index - of the column value (starting at 0) for which to return the length.
Returns:
the length of the requested column, 0 if null (clients of this interface should use isNull() beforehand to determine status of NULL values in the column).
Throws:
java.sql.SQLException

setColumnValue

public abstract void setColumnValue(int index,
                                    byte[] value)
                             throws java.sql.SQLException
Sets the given column value (only works currently with ByteArrayRowHolder).

Parameters:
index - index of the column value (starting at 0) to set.
value - the (raw) value to set
Throws:
java.sql.SQLException - if an error occurs, or the concrete RowHolder doesn't support this operation.

setMetadata

public ResultSetRow setMetadata(Field[] f)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

getBytesSize

public abstract int getBytesSize()