org.apache.commons.dbutils.wrappers
クラス SqlNullCheckedResultSet

java.lang.Object
  上位を拡張 org.apache.commons.dbutils.wrappers.SqlNullCheckedResultSet
すべての実装されたインタフェース:
java.lang.reflect.InvocationHandler

public class SqlNullCheckedResultSet
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

Decorates a ResultSet with checks for a SQL NULL value on each getXXX method. If a column value obtained by a getXXX method is not SQL NULL, the column value is returned. If the column value is SQL null, an alternate value is returned. The alternate value defaults to the Java null value, which can be overridden for instances of the class.

Usage example:

 Connection conn = // somehow get a connection
 Statement stmt = conn.createStatement();
 ResultSet rs = stmt.executeQuery("SELECT col1, col2 FROM table1");
 
 // Wrap the result set for SQL NULL checking
 SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
 wrapper.setNullString("---N/A---"); // Set null string
 wrapper.setNullInt(-999); // Set null integer
 rs = ProxyFactory.instance().createResultSet(wrapper);
 
 while (rs.next()) {
     // If col1 is SQL NULL, value returned will be "---N/A---"
     String col1 = rs.getString("col1");
     // If col2 is SQL NULL, value returned will be -999
     int col2 = rs.getInt("col2");
 }
 rs.close();
 


コンストラクタの概要
SqlNullCheckedResultSet(java.sql.ResultSet rs)
          Constructs a new instance of SqlNullCheckedResultSet to wrap the specified ResultSet.
 
メソッドの概要
 java.io.InputStream getNullAsciiStream()
          Returns the value when a SQL null is encountered as the result of invoking a getAsciiStream method.
 java.math.BigDecimal getNullBigDecimal()
          Returns the value when a SQL null is encountered as the result of invoking a getBigDecimal method.
 java.io.InputStream getNullBinaryStream()
          Returns the value when a SQL null is encountered as the result of invoking a getBinaryStream method.
 java.sql.Blob getNullBlob()
          Returns the value when a SQL null is encountered as the result of invoking a getBlob method.
 boolean getNullBoolean()
          Returns the value when a SQL null is encountered as the result of invoking a getBoolean method.
 byte getNullByte()
          Returns the value when a SQL null is encountered as the result of invoking a getByte method.
 byte[] getNullBytes()
          Returns the value when a SQL null is encountered as the result of invoking a getBytes method.
 java.io.Reader getNullCharacterStream()
          Returns the value when a SQL null is encountered as the result of invoking a getCharacterStream method.
 java.sql.Clob getNullClob()
          Returns the value when a SQL null is encountered as the result of invoking a getClob method.
 java.sql.Date getNullDate()
          Returns the value when a SQL null is encountered as the result of invoking a getDate method.
 double getNullDouble()
          Returns the value when a SQL null is encountered as the result of invoking a getDouble method.
 float getNullFloat()
          Returns the value when a SQL null is encountered as the result of invoking a getFloat method.
 int getNullInt()
          Returns the value when a SQL null is encountered as the result of invoking a getInt method.
 long getNullLong()
          Returns the value when a SQL null is encountered as the result of invoking a getLong method.
 java.lang.Object getNullObject()
          Returns the value when a SQL null is encountered as the result of invoking a getObject method.
 java.sql.Ref getNullRef()
          Returns the value when a SQL null is encountered as the result of invoking a getRef method.
 short getNullShort()
          Returns the value when a SQL null is encountered as the result of invoking a getShort method.
 java.lang.String getNullString()
          Returns the value when a SQL null is encountered as the result of invoking a getString method.
 java.sql.Time getNullTime()
          Returns the value when a SQL null is encountered as the result of invoking a getTime method.
 java.sql.Timestamp getNullTimestamp()
          Returns the value when a SQL null is encountered as the result of invoking a getTimestamp method.
 java.net.URL getNullURL()
          Returns the value when a SQL null is encountered as the result of invoking a getURL method.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Intercepts calls to get* methods and calls the appropriate getNull* method if the ResultSet returned null.
 void setNullAsciiStream(java.io.InputStream nullAsciiStream)
          Sets the value to return when a SQL null is encountered as the result of invoking a getAsciiStream method.
 void setNullBigDecimal(java.math.BigDecimal nullBigDecimal)
          Sets the value to return when a SQL null is encountered as the result of invoking a getBigDecimal method.
 void setNullBinaryStream(java.io.InputStream nullBinaryStream)
          Sets the value to return when a SQL null is encountered as the result of invoking a getBinaryStream method.
 void setNullBlob(java.sql.Blob nullBlob)
          Sets the value to return when a SQL null is encountered as the result of invoking a getBlob method.
 void setNullBoolean(boolean nullBoolean)
          Sets the value to return when a SQL null is encountered as the result of invoking a getBoolean method.
 void setNullByte(byte nullByte)
          Sets the value to return when a SQL null is encountered as the result of invoking a getByte method.
 void setNullBytes(byte[] nullBytes)
          Sets the value to return when a SQL null is encountered as the result of invoking a getBytes method.
 void setNullCharacterStream(java.io.Reader nullCharacterStream)
          Sets the value to return when a SQL null is encountered as the result of invoking a getCharacterStream method.
 void setNullClob(java.sql.Clob nullClob)
          Sets the value to return when a SQL null is encountered as the result of invoking a getClob method.
 void setNullDate(java.sql.Date nullDate)
          Sets the value to return when a SQL null is encountered as the result of invoking a getDate method.
 void setNullDouble(double nullDouble)
          Sets the value to return when a SQL null is encountered as the result of invoking a getDouble method.
 void setNullFloat(float nullFloat)
          Sets the value to return when a SQL null is encountered as the result of invoking a getFloat method.
 void setNullInt(int nullInt)
          Sets the value to return when a SQL null is encountered as the result of invoking a getInt method.
 void setNullLong(long nullLong)
          Sets the value to return when a SQL null is encountered as the result of invoking a getLong method.
 void setNullObject(java.lang.Object nullObject)
          Sets the value to return when a SQL null is encountered as the result of invoking a getObject method.
 void setNullRef(java.sql.Ref nullRef)
          Sets the value to return when a SQL null is encountered as the result of invoking a getRef method.
 void setNullShort(short nullShort)
          Sets the value to return when a SQL null is encountered as the result of invoking a getShort method.
 void setNullString(java.lang.String nullString)
          Sets the value to return when a SQL null is encountered as the result of invoking a getString method.
 void setNullTime(java.sql.Time nullTime)
          Sets the value to return when a SQL null is encountered as the result of invoking a getTime method.
 void setNullTimestamp(java.sql.Timestamp nullTimestamp)
          Sets the value to return when a SQL null is encountered as the result of invoking a getTimestamp method.
 void setNullURL(java.net.URL nullURL)
          Sets the value to return when a SQL null is encountered as the result of invoking a getURL method.
static java.sql.ResultSet wrap(java.sql.ResultSet rs)
          Wraps the ResultSet in an instance of this class.
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

SqlNullCheckedResultSet

public SqlNullCheckedResultSet(java.sql.ResultSet rs)
Constructs a new instance of SqlNullCheckedResultSet to wrap the specified ResultSet.

パラメータ:
rs - ResultSet to wrap
メソッドの詳細

wrap

public static java.sql.ResultSet wrap(java.sql.ResultSet rs)
Wraps the ResultSet in an instance of this class. This is equivalent to:
 ProxyFactory.instance().createResultSet(new SqlNullCheckedResultSet(rs));
 

パラメータ:
rs - The ResultSet to wrap.
戻り値:
wrapped ResultSet

getNullAsciiStream

public java.io.InputStream getNullAsciiStream()
Returns the value when a SQL null is encountered as the result of invoking a getAsciiStream method.

戻り値:
the value

getNullBigDecimal

public java.math.BigDecimal getNullBigDecimal()
Returns the value when a SQL null is encountered as the result of invoking a getBigDecimal method.

戻り値:
the value

getNullBinaryStream

public java.io.InputStream getNullBinaryStream()
Returns the value when a SQL null is encountered as the result of invoking a getBinaryStream method.

戻り値:
the value

getNullBlob

public java.sql.Blob getNullBlob()
Returns the value when a SQL null is encountered as the result of invoking a getBlob method.

戻り値:
the value

getNullBoolean

public boolean getNullBoolean()
Returns the value when a SQL null is encountered as the result of invoking a getBoolean method.

戻り値:
the value

getNullByte

public byte getNullByte()
Returns the value when a SQL null is encountered as the result of invoking a getByte method.

戻り値:
the value

getNullBytes

public byte[] getNullBytes()
Returns the value when a SQL null is encountered as the result of invoking a getBytes method.

戻り値:
the value

getNullCharacterStream

public java.io.Reader getNullCharacterStream()
Returns the value when a SQL null is encountered as the result of invoking a getCharacterStream method.

戻り値:
the value

getNullClob

public java.sql.Clob getNullClob()
Returns the value when a SQL null is encountered as the result of invoking a getClob method.

戻り値:
the value

getNullDate

public java.sql.Date getNullDate()
Returns the value when a SQL null is encountered as the result of invoking a getDate method.

戻り値:
the value

getNullDouble

public double getNullDouble()
Returns the value when a SQL null is encountered as the result of invoking a getDouble method.

戻り値:
the value

getNullFloat

public float getNullFloat()
Returns the value when a SQL null is encountered as the result of invoking a getFloat method.

戻り値:
the value

getNullInt

public int getNullInt()
Returns the value when a SQL null is encountered as the result of invoking a getInt method.

戻り値:
the value

getNullLong

public long getNullLong()
Returns the value when a SQL null is encountered as the result of invoking a getLong method.

戻り値:
the value

getNullObject

public java.lang.Object getNullObject()
Returns the value when a SQL null is encountered as the result of invoking a getObject method.

戻り値:
the value

getNullRef

public java.sql.Ref getNullRef()
Returns the value when a SQL null is encountered as the result of invoking a getRef method.

戻り値:
the value

getNullShort

public short getNullShort()
Returns the value when a SQL null is encountered as the result of invoking a getShort method.

戻り値:
the value

getNullString

public java.lang.String getNullString()
Returns the value when a SQL null is encountered as the result of invoking a getString method.

戻り値:
the value

getNullTime

public java.sql.Time getNullTime()
Returns the value when a SQL null is encountered as the result of invoking a getTime method.

戻り値:
the value

getNullTimestamp

public java.sql.Timestamp getNullTimestamp()
Returns the value when a SQL null is encountered as the result of invoking a getTimestamp method.

戻り値:
the value

getNullURL

public java.net.URL getNullURL()
Returns the value when a SQL null is encountered as the result of invoking a getURL method.

戻り値:
the value

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Intercepts calls to get* methods and calls the appropriate getNull* method if the ResultSet returned null.

定義:
インタフェース java.lang.reflect.InvocationHandler 内の invoke
例外:
java.lang.Throwable
関連項目:
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

setNullAsciiStream

public void setNullAsciiStream(java.io.InputStream nullAsciiStream)
Sets the value to return when a SQL null is encountered as the result of invoking a getAsciiStream method.

パラメータ:
nullAsciiStream - the value

setNullBigDecimal

public void setNullBigDecimal(java.math.BigDecimal nullBigDecimal)
Sets the value to return when a SQL null is encountered as the result of invoking a getBigDecimal method.

パラメータ:
nullBigDecimal - the value

setNullBinaryStream

public void setNullBinaryStream(java.io.InputStream nullBinaryStream)
Sets the value to return when a SQL null is encountered as the result of invoking a getBinaryStream method.

パラメータ:
nullBinaryStream - the value

setNullBlob

public void setNullBlob(java.sql.Blob nullBlob)
Sets the value to return when a SQL null is encountered as the result of invoking a getBlob method.

パラメータ:
nullBlob - the value

setNullBoolean

public void setNullBoolean(boolean nullBoolean)
Sets the value to return when a SQL null is encountered as the result of invoking a getBoolean method.

パラメータ:
nullBoolean - the value

setNullByte

public void setNullByte(byte nullByte)
Sets the value to return when a SQL null is encountered as the result of invoking a getByte method.

パラメータ:
nullByte - the value

setNullBytes

public void setNullBytes(byte[] nullBytes)
Sets the value to return when a SQL null is encountered as the result of invoking a getBytes method.

パラメータ:
nullBytes - the value

setNullCharacterStream

public void setNullCharacterStream(java.io.Reader nullCharacterStream)
Sets the value to return when a SQL null is encountered as the result of invoking a getCharacterStream method.

パラメータ:
nullCharacterStream - the value

setNullClob

public void setNullClob(java.sql.Clob nullClob)
Sets the value to return when a SQL null is encountered as the result of invoking a getClob method.

パラメータ:
nullClob - the value

setNullDate

public void setNullDate(java.sql.Date nullDate)
Sets the value to return when a SQL null is encountered as the result of invoking a getDate method.

パラメータ:
nullDate - the value

setNullDouble

public void setNullDouble(double nullDouble)
Sets the value to return when a SQL null is encountered as the result of invoking a getDouble method.

パラメータ:
nullDouble - the value

setNullFloat

public void setNullFloat(float nullFloat)
Sets the value to return when a SQL null is encountered as the result of invoking a getFloat method.

パラメータ:
nullFloat - the value

setNullInt

public void setNullInt(int nullInt)
Sets the value to return when a SQL null is encountered as the result of invoking a getInt method.

パラメータ:
nullInt - the value

setNullLong

public void setNullLong(long nullLong)
Sets the value to return when a SQL null is encountered as the result of invoking a getLong method.

パラメータ:
nullLong - the value

setNullObject

public void setNullObject(java.lang.Object nullObject)
Sets the value to return when a SQL null is encountered as the result of invoking a getObject method.

パラメータ:
nullObject - the value

setNullRef

public void setNullRef(java.sql.Ref nullRef)
Sets the value to return when a SQL null is encountered as the result of invoking a getRef method.

パラメータ:
nullRef - the value

setNullShort

public void setNullShort(short nullShort)
Sets the value to return when a SQL null is encountered as the result of invoking a getShort method.

パラメータ:
nullShort - the value

setNullString

public void setNullString(java.lang.String nullString)
Sets the value to return when a SQL null is encountered as the result of invoking a getString method.

パラメータ:
nullString - the value

setNullTime

public void setNullTime(java.sql.Time nullTime)
Sets the value to return when a SQL null is encountered as the result of invoking a getTime method.

パラメータ:
nullTime - the value

setNullTimestamp

public void setNullTimestamp(java.sql.Timestamp nullTimestamp)
Sets the value to return when a SQL null is encountered as the result of invoking a getTimestamp method.

パラメータ:
nullTimestamp - the value

setNullURL

public void setNullURL(java.net.URL nullURL)
Sets the value to return when a SQL null is encountered as the result of invoking a getURL method.

パラメータ:
nullURL - the value