APIdia Launch Partner
Top Description Fields Constructors Methods
javax.sql.rowset.serial

public Class SQLInputImpl

extends Object
implements SQLInput
Class Inheritance
All Implemented Interfaces
java.sql.SQLInput
Imports
java.sql.*, java.util.Arrays, .Map

An input stream used for custom mapping user-defined types (UDTs). An SQLInputImpl object is an input stream that contains a stream of values that are the attributes of a UDT.

This class is used by the driver behind the scenes when the method getObject is called on an SQL structured or distinct type that has a custom mapping; a programmer never invokes SQLInputImpl methods directly. They are provided here as a convenience for those who write RowSet implementations.

The SQLInputImpl class provides a set of reader methods analogous to the ResultSet getter methods. These methods make it possible to read the values in an SQLInputImpl object.

The method wasNull is used to determine whether the the last value read was SQL NULL.

When the method getObject is called with an object of a class implementing the interface SQLData, the JDBC driver calls the method SQLData.getSQLType to determine the SQL type of the UDT being custom mapped. The driver creates an instance of SQLInputImpl, populating it with the attributes of the UDT. The driver then passes the input stream to the method SQLData.readSQL, which in turn calls the SQLInputImpl reader methods to read the attributes from the input stream.

Since
1.5
See Also
java.sql.SQLData

Field Summary

Modifier and TypeField and Description
private Object[]
attrib

The array of attributes to be read from this stream.

private int
idx

The current index into the array of SQL structured type attributes that will be read from this SQLInputImpl object and mapped to the fields of a class in the Java programming language.

private boolean
lastValueWasNull

true if the last value returned was SQL NULL; false otherwise.

private Map<String, Class<?>>
map

The type map to use when the method readObject is invoked.

Constructor Summary

AccessConstructor and Description
public
SQLInputImpl(Object[]
an array of Object instances in which each element is an attribute of a UDT. The order of the attributes in the array is the same order in which the attributes were defined in the UDT definition.
attributes
,
Map<String, Class<?>>
a java.util.Map object containing zero or more entries, with each entry consisting of 1) a String giving the fully qualified name of the UDT and 2) the Class object for the SQLData implementation that defines how the UDT is to be mapped
map
)

Creates an SQLInputImpl object initialized with the given array of attributes and the given type map.

Method Summary

Modifier and TypeMethod and Description
private Object

Returns:

the next value in the input stream as an Object in the Java programming language
getNextAttribute
()

Retrieves the next attribute in this SQLInputImpl object as an Object in the Java programming language.

public Array

Returns:

an Array object representing the SQL ARRAY value at the head of the stream; * if the value is SQL NULL, return null
readArray
()

Implements java.sql.SQLInput.readArray.

Reads an SQL ARRAY value from the stream and returns it as an Array object in the Java programming language.

public InputStream

Returns:

the attribute; if the value is SQL NULL, return null
readAsciiStream
()

Implements java.sql.SQLInput.readAsciiStream.

Returns the next attribute in this SQLInputImpl object as a stream of ASCII characters.

public BigDecimal

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readBigDecimal
()

Implements java.sql.SQLInput.readBigDecimal.

Retrieves the next attribute in this SQLInputImpl object as a java.math.BigDecimal.

public InputStream

Returns:

the attribute; if the value is SQL NULL, return null
readBinaryStream
()

Implements java.sql.SQLInput.readBinaryStream.

Returns the next attribute in this SQLInputImpl object as a stream of uninterpreted bytes.

public Blob

Returns:

a Blob object representing the SQL BLOB value at the head of this stream; if the value is SQL NULL, return null
readBlob
()

Implements java.sql.SQLInput.readBlob.

Retrieves the BLOB value at the head of this SQLInputImpl object as a Blob object in the Java programming language.

public boolean

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readBoolean
()

Implements java.sql.SQLInput.readBoolean.

Retrieves the next attribute in this SQLInputImpl object as a boolean in the Java programming language.

public byte

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readByte
()

Implements java.sql.SQLInput.readByte.

Retrieves the next attribute in this SQLInputImpl object as a byte in the Java programming language.

public byte[]

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readBytes
()

Implements java.sql.SQLInput.readBytes.

Retrieves the next attribute in this SQLInputImpl object as an array of bytes.

public Reader

Returns:

the attribute; if the value is SQL NULL, return null
readCharacterStream
()

Implements java.sql.SQLInput.readCharacterStream.

Retrieves the next attribute in this SQLInputImpl object as a stream of Unicode characters.

public Clob

Returns:

a Clob object representing the SQL CLOB value at the head of the stream; if the value is SQL NULL, return null
readClob
()

Implements java.sql.SQLInput.readClob.

Retrieves the CLOB value at the head of this SQLInputImpl object as a Clob object in the Java programming language.

public Date

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readDate
()

Implements java.sql.SQLInput.readDate.

Retrieves the next attribute in this SQLInputImpl as a java.sql.Date object.

public double

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readDouble
()

Implements java.sql.SQLInput.readDouble.

Retrieves the next attribute in this SQLInputImpl object as a double in the Java programming language.

public float

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readFloat
()

Implements java.sql.SQLInput.readFloat.

Retrieves the next attribute in this SQLInputImpl object as a float in the Java programming language.

public int

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readInt
()

Implements java.sql.SQLInput.readInt.

Retrieves the next attribute in this SQLInputImpl object as an int in the Java programming language.

public long

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readLong
()

Implements java.sql.SQLInput.readLong.

Retrieves the next attribute in this SQLInputImpl object as a long in the Java programming language.

public NClob

Returns:

a NClob object representing data of the SQL NCLOB value at the head of the stream; null if the value read is SQL NULL
readNClob
()

Implements java.sql.SQLInput.readNClob.

Reads an SQL NCLOB value from the stream and returns it as a Clob object in the Java programming language.

public String

Returns:

the attribute; if the value is SQL NULL, returns null
readNString
()

Implements java.sql.SQLInput.readNString.

Reads the next attribute in the stream and returns it as a String in the Java programming language.

public Object

Returns:

the value at the head of the stream as an Object in the Java programming language; null if the value is SQL NULL
readObject
()

Implements java.sql.SQLInput.readObject.

Retrieves the value at the head of this SQLInputImpl object as an Object in the Java programming language.

public Ref

Returns:

a Ref object representing the SQL REF value at the head of the stream; if the value is SQL NULL return null
readRef
()

Implements java.sql.SQLInput.readRef.

Retrieves the value at the head of this SQLInputImpl object as a Ref object in the Java programming language.

public RowId

Returns:

a RowId object representing data of the SQL ROWID value at the head of the stream; null if the value read is SQL NULL
readRowId
()

Implements java.sql.SQLInput.readRowId.

Reads an SQL ROWID value from the stream and returns it as a RowId object in the Java programming language.

public short

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readShort
()

Implements java.sql.SQLInput.readShort.

Retrieves the next attribute in this SQLInputImpl object as a short in the Java programming language.

public SQLXML

Returns:

a SQLXML object representing data of the SQL XML value at the head of the stream; null if the value read is SQL NULL
readSQLXML
()

Implements java.sql.SQLInput.readSQLXML.

Reads an SQL XML value from the stream and returns it as a SQLXML object in the Java programming language.

public String

Returns:

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null
readString
()

Implements java.sql.SQLInput.readString.

Retrieves the next attribute in this SQLInputImpl object as a String in the Java programming language.

public Time

Returns:

the attribute; if the value is SQL NULL, return null
readTime
()

Implements java.sql.SQLInput.readTime.

Retrieves the next attribute in this SQLInputImpl object as a java.sql.Time object.

public Timestamp

Returns:

the attribute; if the value is SQL NULL, return null
readTimestamp
()

Implements java.sql.SQLInput.readTimestamp.

Retrieves the next attribute in this SQLInputImpl object as a java.sql.Timestamp object.

public URL

Returns:

an URL object representing the SQL DATALINK value at the head of the stream; * if the value is SQL NULL, return null
readURL
()

Implements java.sql.SQLInput.readURL.

Reads an SQL DATALINK value from the stream and returns it as an URL object in the Java programming language.

public boolean

Returns:

true if the SQL value read most recently was null; otherwise, false; by default it will return false
wasNull
()

Implements java.sql.SQLInput.wasNull.

Ascertains whether the last value read from this SQLInputImpl object was null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attribback to summary
private Object[] attrib

The array of attributes to be read from this stream. The order of the attributes is the same as the order in which they were listed in the SQL definition of the UDT.

idxback to summary
private int idx

The current index into the array of SQL structured type attributes that will be read from this SQLInputImpl object and mapped to the fields of a class in the Java programming language.

lastValueWasNullback to summary
private boolean lastValueWasNull

true if the last value returned was SQL NULL; false otherwise.

mapback to summary
private Map<String, Class<?>> map

The type map to use when the method readObject is invoked. This is a java.util.Map object in which there may be zero or more entries. Each entry consists of the fully qualified name of a UDT (the value to be mapped) and the Class object for a class that implements SQLData (the Java class that defines how the UDT will be mapped).

Constructor Detail

SQLInputImplback to summary
public SQLInputImpl(Object[] attributes, Map<String, Class<?>> map) throws SQLException

Creates an SQLInputImpl object initialized with the given array of attributes and the given type map. If any of the attributes is a UDT whose name is in an entry in the type map, the attribute will be mapped according to the corresponding SQLData implementation.

Parameters
attributes:Object[]

an array of Object instances in which each element is an attribute of a UDT. The order of the attributes in the array is the same order in which the attributes were defined in the UDT definition.

map:Map<String, Class<?>>

a java.util.Map object containing zero or more entries, with each entry consisting of 1) a String giving the fully qualified name of the UDT and 2) the Class object for the SQLData implementation that defines how the UDT is to be mapped

Exceptions
SQLException:
if the attributes or the map is a null value

Method Detail

getNextAttributeback to summary
private Object getNextAttribute() throws SQLException

Retrieves the next attribute in this SQLInputImpl object as an Object in the Java programming language.

Returns:Object

the next value in the input stream as an Object in the Java programming language

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no further values in the stream
readArrayback to summary
public Array readArray() throws SQLException

Implements java.sql.SQLInput.readArray.

Reads an SQL ARRAY value from the stream and returns it as an Array object in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:Array

an Array object representing the SQL ARRAY value at the head of the stream; * if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readAsciiStreamback to summary
public InputStream readAsciiStream() throws SQLException

Implements java.sql.SQLInput.readAsciiStream.

Returns the next attribute in this SQLInputImpl object as a stream of ASCII characters.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:InputStream

the attribute; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readBigDecimalback to summary
public BigDecimal readBigDecimal() throws SQLException

Implements java.sql.SQLInput.readBigDecimal.

Retrieves the next attribute in this SQLInputImpl object as a java.math.BigDecimal.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:BigDecimal

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readBinaryStreamback to summary
public InputStream readBinaryStream() throws SQLException

Implements java.sql.SQLInput.readBinaryStream.

Returns the next attribute in this SQLInputImpl object as a stream of uninterpreted bytes.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:InputStream

the attribute; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readBlobback to summary
public Blob readBlob() throws SQLException

Implements java.sql.SQLInput.readBlob.

Retrieves the BLOB value at the head of this SQLInputImpl object as a Blob object in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:Blob

a Blob object representing the SQL BLOB value at the head of this stream; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readBooleanback to summary
public boolean readBoolean() throws SQLException

Implements java.sql.SQLInput.readBoolean.

Retrieves the next attribute in this SQLInputImpl object as a boolean in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:boolean

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no further values in the stream.
readByteback to summary
public byte readByte() throws SQLException

Implements java.sql.SQLInput.readByte.

Retrieves the next attribute in this SQLInputImpl object as a byte in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:byte

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no further values in the stream
readBytesback to summary
public byte[] readBytes() throws SQLException

Implements java.sql.SQLInput.readBytes.

Retrieves the next attribute in this SQLInputImpl object as an array of bytes.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:byte[]

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readCharacterStreamback to summary
public Reader readCharacterStream() throws SQLException

Implements java.sql.SQLInput.readCharacterStream.

Retrieves the next attribute in this SQLInputImpl object as a stream of Unicode characters.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:Reader

the attribute; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readClobback to summary
public Clob readClob() throws SQLException

Implements java.sql.SQLInput.readClob.

Retrieves the CLOB value at the head of this SQLInputImpl object as a Clob object in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:Clob

a Clob object representing the SQL CLOB value at the head of the stream; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readDateback to summary
public Date readDate() throws SQLException

Implements java.sql.SQLInput.readDate.

Retrieves the next attribute in this SQLInputImpl as a java.sql.Date object.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:Date

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readDoubleback to summary
public double readDouble() throws SQLException

Implements java.sql.SQLInput.readDouble.

Retrieves the next attribute in this SQLInputImpl object as a double in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:double

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readFloatback to summary
public float readFloat() throws SQLException

Implements java.sql.SQLInput.readFloat.

Retrieves the next attribute in this SQLInputImpl object as a float in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:float

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readIntback to summary
public int readInt() throws SQLException

Implements java.sql.SQLInput.readInt.

Retrieves the next attribute in this SQLInputImpl object as an int in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:int

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readLongback to summary
public long readLong() throws SQLException

Implements java.sql.SQLInput.readLong.

Retrieves the next attribute in this SQLInputImpl object as a long in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:long

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readNClobback to summary
public NClob readNClob() throws SQLException

Implements java.sql.SQLInput.readNClob.

Reads an SQL NCLOB value from the stream and returns it as a Clob object in the Java programming language.

Returns:NClob

a NClob object representing data of the SQL NCLOB value at the head of the stream; null if the value read is SQL NULL

Exceptions
SQLException:
if a database access error occurs
Since
1.6
readNStringback to summary
public String readNString() throws SQLException

Implements java.sql.SQLInput.readNString.

Reads the next attribute in the stream and returns it as a String in the Java programming language. It is intended for use when accessing NCHAR,NVARCHAR and LONGNVARCHAR columns.

Returns:String

the attribute; if the value is SQL NULL, returns null

Exceptions
SQLException:
if a database access error occurs
Since
1.6
readObjectback to summary
public Object readObject() throws SQLException

Implements java.sql.SQLInput.readObject.

Retrieves the value at the head of this SQLInputImpl object as an Object in the Java programming language. The actual type of the object returned is determined by the default mapping of SQL types to types in the Java programming language unless there is a custom mapping, in which case the type of the object returned is determined by this stream's type map.

The JDBC technology-enabled driver registers a type map with the stream before passing the stream to the application.

When the datum at the head of the stream is an SQL NULL, this method returns null. If the datum is an SQL structured or distinct type with a custom mapping, this method determines the SQL type of the datum at the head of the stream, constructs an object of the appropriate class, and calls the method SQLData.readSQL on that object. The readSQL method then calls the appropriate SQLInputImpl.readXXX methods to retrieve the attribute values from the stream.

Returns:Object

the value at the head of the stream as an Object in the Java programming language; null if the value is SQL NULL

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readRefback to summary
public Ref readRef() throws SQLException

Implements java.sql.SQLInput.readRef.

Retrieves the value at the head of this SQLInputImpl object as a Ref object in the Java programming language.

Returns:Ref

a Ref object representing the SQL REF value at the head of the stream; if the value is SQL NULL return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readRowIdback to summary
public RowId readRowId() throws SQLException

Implements java.sql.SQLInput.readRowId.

Reads an SQL ROWID value from the stream and returns it as a RowId object in the Java programming language.

Returns:RowId

a RowId object representing data of the SQL ROWID value at the head of the stream; null if the value read is SQL NULL

Exceptions
SQLException:
if a database access error occurs
Since
1.6
readShortback to summary
public short readShort() throws SQLException

Implements java.sql.SQLInput.readShort.

Retrieves the next attribute in this SQLInputImpl object as a short in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:short

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no more values in the stream
readSQLXMLback to summary
public SQLXML readSQLXML() throws SQLException

Implements java.sql.SQLInput.readSQLXML.

Reads an SQL XML value from the stream and returns it as a SQLXML object in the Java programming language.

Returns:SQLXML

a SQLXML object representing data of the SQL XML value at the head of the stream; null if the value read is SQL NULL

Exceptions
SQLException:
if a database access error occurs
Since
1.6
readStringback to summary
public String readString() throws SQLException

Implements java.sql.SQLInput.readString.

Retrieves the next attribute in this SQLInputImpl object as a String in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type; this responsibility is delegated to the UDT mapping as defined by a SQLData implementation.

Returns:String

the next attribute in this SQLInputImpl object; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position or if there are no further values in the stream.
readTimeback to summary
public Time readTime() throws SQLException

Implements java.sql.SQLInput.readTime.

Retrieves the next attribute in this SQLInputImpl object as a java.sql.Time object.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:Time

the attribute; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readTimestampback to summary
public Timestamp readTimestamp() throws SQLException

Implements java.sql.SQLInput.readTimestamp.

Retrieves the next attribute in this SQLInputImpl object as a java.sql.Timestamp object.

Returns:Timestamp

the attribute; if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
readURLback to summary
public URL readURL() throws SQLException

Implements java.sql.SQLInput.readURL.

Reads an SQL DATALINK value from the stream and returns it as an URL object in the Java programming language.

This method does not perform type-safe checking to determine if the returned type is the expected type as this responsibility is delegated to the UDT mapping as implemented by a SQLData implementation.

Returns:URL

an URL object representing the SQL DATALINK value at the head of the stream; * if the value is SQL NULL, return null

Exceptions
SQLException:
if the read position is located at an invalid position; or if there are no further values in the stream.
wasNullback to summary
public boolean wasNull() throws SQLException

Implements java.sql.SQLInput.wasNull.

Ascertains whether the last value read from this SQLInputImpl object was null.

Returns:boolean

true if the SQL value read most recently was null; otherwise, false; by default it will return false

Exceptions
SQLException:
if an error occurs determining the last value read was a null value or not;