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

java.lang.Object
  拡張org.apache.commons.dbutils.wrappers.SqlNullCheckedResultSet
すべての実装インタフェース:
InvocationHandler

public class SqlNullCheckedResultSet
extends Object
implements InvocationHandler

ResultSet の各 getXXX メソッドに SQL NULL 値の判定処理を追加します。 getXXX メソッドによって SQL NULL でないカラム値が取得された場合、そのカラム値が返されます。 一方、カラム値が SQL NULL であった場合には代替値が返されます。 デフォルトの代替値は、当該クラスのインスタンスへオーバーライドすることが可能な Java の null 値です。

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 = // 接続を取得する
 Statement stmt = conn.createStatement();
 ResultSet rs = stmt.executeQuery("SELECT col1, col2 FROM table1");
 
 // SQL NULLを判定する結果セットをラップする
 SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
 wrapper.setNullString("---N/A---"); // null文字列に対して設定する
 wrapper.setNullInt(-999); // null 数値に対して設定する
 rs = ProxyFactory.instance().createResultSet(wrapper);
 
 while (rs.next()) {
     // col1 がSQL NULL の場合、"---N/A---" が値として返される
     String col1 = rs.getString("col1");
     // col2 がSQL NULL の場合、-999 が値として返される
     int col2 = rs.getInt("col2");
 }
 rs.close();
 
 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(); }

バージョン:
$Id: SqlNullCheckedResultSet.java,v 1.1.1.1 2004/02/13 10:02:04 hioki Exp $
作成者:
Steven Caswell, David Graham
翻訳者:
小川 環
校正者:
日置 聡
翻訳状況:
校正者校正中
翻訳更新日:
2003/12/22

コンストラクタの概要
SqlNullCheckedResultSet(ResultSet rs)
          指定された ResultSet をラップした SqlNullCheckedResultSet の新規インスタンスを作成します。
 
メソッドの概要
 InputStream getNullAsciiStream()
          getAsciiStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 BigDecimal getNullBigDecimal()
          getBigDecimal メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 InputStream getNullBinaryStream()
          getBinaryStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Blob getNullBlob()
          getBlob メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 boolean getNullBoolean()
          getBoolean メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 byte getNullByte()
          getByte メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 byte[] getNullBytes()
          getBytes メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Reader getNullCharacterStream()
          getCharacterStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Clob getNullClob()
          getClob メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Date getNullDate()
          getDate メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 double getNullDouble()
          getDouble メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 float getNullFloat()
          getFloat メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 int getNullInt()
          getInt メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 long getNullLong()
          getLong メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Object getNullObject()
          getObject メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Ref getNullRef()
          getRef メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 short getNullShort()
          getShort メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 String getNullString()
          getString メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Time getNullTime()
          getTime メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Timestamp getNullTimestamp()
          getTimestamp メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 URL getNullURL()
          getURL メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
 Object invoke(Object proxy, Method method, Object[] args)
          get* メソッドの呼び出しを捕捉し、ResultSetnull を返す場合、適切な getNull* メソッドを呼び出します。
 void setNullAsciiStream(InputStream nullAsciiStream)
          getAsciiStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullBigDecimal(BigDecimal nullBigDecimal)
          getBigDecimal メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullBinaryStream(InputStream nullBinaryStream)
          getBinaryStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullBlob(Blob nullBlob)
          getBlob メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullBoolean(boolean nullBoolean)
          getBoolean メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullByte(byte nullByte)
          getByte メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullBytes(byte[] nullBytes)
          getBytes メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullCharacterStream(Reader nullCharacterStream)
          getCharacterStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullClob(Clob nullClob)
          getClob メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullDate(Date nullDate)
          getDate メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullDouble(double nullDouble)
          getDouble メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullFloat(float nullFloat)
          getFloat メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullInt(int nullInt)
          getInt メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullLong(long nullLong)
          getLong メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullObject(Object nullObject)
          getObject メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullRef(Ref nullRef)
          getRef メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullShort(short nullShort)
          getShort メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullString(String nullString)
          getString メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullTime(Time nullTime)
          getTime メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullTimestamp(Timestamp nullTimestamp)
          getTimestamp メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
 void setNullURL(URL nullURL)
          getURL メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
static ResultSet wrap(ResultSet rs)
          このクラスのインスタンスに ResultSet をラップします。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

SqlNullCheckedResultSet

public SqlNullCheckedResultSet(ResultSet rs)
指定された ResultSet をラップした SqlNullCheckedResultSet の新規インスタンスを作成します。
Constructs a new instance of SqlNullCheckedResultSet to wrap the specified ResultSet.

メソッドの詳細

wrap

public static ResultSet wrap(ResultSet rs)
このクラスのインスタンスに ResultSet をラップします。 これは、次のコードと等しいです。
Wraps the ResultSet in an instance of this class. This is equivalent to:
 ProxyFactory.instance().createResultSet(new SqlNullCheckedResultSet(rs));
 

パラメータ:
rs - ラップする ResultSet
The ResultSet to wrap.

getNullAsciiStream

public InputStream getNullAsciiStream()
getAsciiStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getAsciiStream method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullBigDecimal

public BigDecimal getNullBigDecimal()
getBigDecimal メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getBigDecimal method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullBinaryStream

public InputStream getNullBinaryStream()
getBinaryStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getBinaryStream method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullBlob

public Blob getNullBlob()
getBlob メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getBlob method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullBoolean

public boolean getNullBoolean()
getBoolean メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getBoolean method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullByte

public byte getNullByte()
getByte メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getByte method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullBytes

public byte[] getNullBytes()
getBytes メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getBytes method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullCharacterStream

public Reader getNullCharacterStream()
getCharacterStream メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getCharacterStream method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullClob

public Clob getNullClob()
getClob メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getClob method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullDate

public Date getNullDate()
getDate メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getDate method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullDouble

public double getNullDouble()
getDouble メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getDouble method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullFloat

public float getNullFloat()
getFloat メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getFloat method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullInt

public int getNullInt()
getInt メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getInt method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullLong

public long getNullLong()
getLong メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getLong method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullObject

public Object getNullObject()
getObject メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getObject method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullRef

public Ref getNullRef()
getRef メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getRef method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullShort

public short getNullShort()
getShort メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getShort method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullString

public String getNullString()
getString メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getString method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullTime

public Time getNullTime()
getTime メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getTime method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullTimestamp

public Timestamp getNullTimestamp()
getTimestamp メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getTimestamp method.

戻り値:
( SQL null の代わりに返す)値
the value

getNullURL

public URL getNullURL()
getURL メソッドの処理結果が SQL NULL だった場合に使用する値を返します。
Returns the value when a SQL null is encountered as the result of invoking a getURL method.

戻り値:
( SQL null の代わりに返す)値
the value

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
get* メソッドの呼び出しを捕捉し、ResultSetnull を返す場合、適切な getNull* メソッドを呼び出します。
Intercepts calls to get* methods and calls the appropriate getNull* method if the ResultSet returned null.

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

setNullAsciiStream

public void setNullAsciiStream(InputStream nullAsciiStream)
getAsciiStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getAsciiStream method.

パラメータ:
nullAsciiStream - ( SQL null の代わりに返す)値
the value

setNullBigDecimal

public void setNullBigDecimal(BigDecimal nullBigDecimal)
getBigDecimal メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getBigDecimal method.

パラメータ:
nullBigDecimal - ( SQL null の代わりに返す)値
the value

setNullBinaryStream

public void setNullBinaryStream(InputStream nullBinaryStream)
getBinaryStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getBinaryStream method.

パラメータ:
nullBinaryStream - ( SQL null の代わりに返す)値
the value

setNullBlob

public void setNullBlob(Blob nullBlob)
getBlob メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getBlob method.

パラメータ:
nullBlob - ( SQL null の代わりに返す)値
the value

setNullBoolean

public void setNullBoolean(boolean nullBoolean)
getBoolean メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getBoolean method.

パラメータ:
nullBoolean - ( SQL null の代わりに返す)値
the value

setNullByte

public void setNullByte(byte nullByte)
getByte メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getByte method.

パラメータ:
nullByte - ( SQL null の代わりに返す)値
the value

setNullBytes

public void setNullBytes(byte[] nullBytes)
getBytes メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getBytes method.

パラメータ:
nullBytes - ( SQL null の代わりに返す)値
the value

setNullCharacterStream

public void setNullCharacterStream(Reader nullCharacterStream)
getCharacterStream メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getCharacterStream method.

パラメータ:
nullCharacterStream - ( SQL null の代わりに返す)値
the value

setNullClob

public void setNullClob(Clob nullClob)
getClob メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getClob method.

パラメータ:
nullClob - ( SQL null の代わりに返す)値
the value

setNullDate

public void setNullDate(Date nullDate)
getDate メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getDate method.

パラメータ:
nullDate - ( SQL null の代わりに返す)値
the value

setNullDouble

public void setNullDouble(double nullDouble)
getDouble メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getDouble method.

パラメータ:
nullDouble - ( SQL null の代わりに返す)値
the value

setNullFloat

public void setNullFloat(float nullFloat)
getFloat メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getFloat method.

パラメータ:
nullFloat - ( SQL null の代わりに返す)値
the value

setNullInt

public void setNullInt(int nullInt)
getInt メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getInt method.

パラメータ:
nullInt - ( SQL null の代わりに返す)値
the value

setNullLong

public void setNullLong(long nullLong)
getLong メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getLong method.

パラメータ:
nullLong - ( SQL null の代わりに返す)値
the value

setNullObject

public void setNullObject(Object nullObject)
getObject メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getObject method.

パラメータ:
nullObject - ( SQL null の代わりに返す)値
the value

setNullRef

public void setNullRef(Ref nullRef)
getRef メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getRef method.

パラメータ:
nullRef - ( SQL null の代わりに返す)値
the value

setNullShort

public void setNullShort(short nullShort)
getShort メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getShort method.

パラメータ:
nullShort - ( SQL null の代わりに返す)値
the value

setNullString

public void setNullString(String nullString)
getString メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getString method.

パラメータ:
nullString - ( SQL null の代わりに返す)値
the value

setNullTime

public void setNullTime(Time nullTime)
getTime メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getTime method.

パラメータ:
nullTime - ( SQL null の代わりに返す)値
the value

setNullTimestamp

public void setNullTimestamp(Timestamp nullTimestamp)
getTimestamp メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getTimestamp method.

パラメータ:
nullTimestamp - ( SQL null の代わりに返す)値
the value

setNullURL

public void setNullURL(URL nullURL)
getURL メソッドの処理結果が SQL NULL だった場合に使用する値を設定します。
Sets the value to return when a SQL null is encountered as the result of invoking a getURL method.

パラメータ:
nullURL - ( SQL null の代わりに返す)値
the value


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation