com.informix.jdbc

## Class IfxUDTInput

- java.lang.Object
- - com.informix.jdbc.IfxUDTInput

All Implemented Interfaces:
  IfmxUDTSQLInput, SQLUDTInput, java.sql.SQLInput

    public class IfxUDTInput
    extends java.lang.Object
    implements SQLUDTInput, IfmxUDTSQLInput

JDBC 2.0 A SQLInput stream contains a stream of values that represent an SQL structured or distinct type instance. The implementation is for UDTs and the data types are based on what's listed in public/mitypes.h

### Field Summary

Fields
`protected byte[]` `buf`
`protected IfxConnection` `conn`
`protected int` `currentPos`
`protected boolean` `isNull`
`protected int` `totalLength`
`protected Trace` `trace`
`protected int` `unreadLength`

### Method Summary

Methods
`int` `available()` Returns the number of bytes remaining in this input stream.
`protected void` `checkLength(int len)`
`protected int` `currentPosition()`
`boolean` `getAutoAlignment()` Returns true if auto alignment is enabled and false if auto alignment has been disabled.
`int` `getCurrentPosition()` Returns the current position in the input stream.
`IfxUDTInfo` `getUDTInfo(int xid)` Get general information about opaque and distinct types and detailed information for complex types.
`IfxUDTInfo` `getUDTInfo(java.lang.String name, java.lang.String owner)` Get general information about opaque and distinct types and detailed information for complex types.
`int` `length()` Get the total length of the entire data stream.
`java.sql.Array` `readArray()` Read an array from the stream.
`java.io.InputStream` `readAsciiStream()` Return the next attribute in the stream as a stream of ASCII characters.
`java.math.BigDecimal` `readBigDecimal()` Read the next attribute in the stream as a java.math.BigDecimal object.
`java.io.InputStream` `readBinaryStream()` Return the next attribute in the stream as a stream of uninterpreted bytes.
`java.sql.Blob` `readBlob()` Read a BLOB from the stream.
`boolean` `readBoolean()` Read the next attribute in the stream as a Java boolean.
`byte` `readByte()` Read the next attribute in the stream as a Java byte.
`byte[]` `readBytes()` Read the next attribute in the stream as an array of bytes.
`byte[]` `readBytes(int len)` Read the next attribute in the stream as an array of bytes.
`java.io.Reader` `readCharacterStream()` Return the next attribute in the stream as a stream of Unicode characters.
`java.sql.Clob` `readClob()` Read a CLOB from the stream.
`java.sql.Date` `readDate()` Read the next attribute in the stream as a java.sql.Date object.
`double` `readDouble()` Read the next attribute in the stream as a Java double.
`float` `readFloat()` Read the next attribute in the stream as a Java float.
`int` `readInt()` Read the next attribute in the stream as a Java int.
`Interval` `readInterval()` Read the next attribute in the stream as an Interval object (IntervalYM or IntervalMF).
`long` `readLong()` Read the next attribute in the stream as a Java long.
`long` `readLongBigint()` Read the next attribute in the stream as a Java long.
`java.sql.NClob` `readNClob()`
`java.lang.String` `readNString()`
`java.lang.Object` `readObject()` Return the datum at the head of the stream as a Java object.
`java.sql.Ref` `readRef()` Read a REF(<structured-type>) from the stream.
`java.sql.RowId` `readRowId()`
`short` `readShort()` Read the next attribute in the stream as a Java short.
`java.sql.SQLXML` `readSQLXML()`
`java.lang.String` `readString()` Read the next attribute in the stream as a Java String.
`java.lang.String` `readString(int len)` Read the next attribute in the stream as a Java String.
`java.lang.String` `readString(int len, java.lang.String dbEnc)` Read the next attribute in the stream as a Java String.
`java.sql.Time` `readTime()` Read the next attribute in the stream as a java.sql.Time object.
`java.sql.Timestamp` `readTimestamp()` Read the next attribute in the stream as a java.sql.Timestamp object.
`java.net.URL` `readURL()`
`protected void` `reset()`
`void` `setAutoAlignment(boolean value)` Enable or disable automatic alignment.
`void` `setCurrentPosition(int position)` Resets the current position.
`void` `skipBytes(int len)` Skips over and discards len bytes of data from the input stream.
`boolean` `wasNull()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.sql.SQLInput

`readTime, wasNull`

### Field Detail

#### conn

    protected IfxConnection conn

#### isNull

    protected boolean isNull

#### buf

    protected byte[] buf

#### totalLength

    protected int totalLength

#### unreadLength

    protected int unreadLength

#### currentPos

    protected int currentPos

#### trace

    protected Trace trace

### Method Detail

#### length

    public int length()

Description copied from interface: `SQLUDTInput`

Get the total length of the entire data stream.

Specified by:
  `length` in interface `IfmxUDTSQLInput`
Specified by:
  `length` in interface `SQLUDTInput`
Returns:
  the total length.

#### readString

    public java.lang.String readString()
                                throws java.sql.SQLException

Read the next attribute in the stream as a Java String. We can't use this method for UDT since we don't know the length. It's coming back as mi_char.

Specified by:
  `readString` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readByte

    public byte readByte()
                  throws java.sql.SQLException

Read the next attribute in the stream as a Java byte.

Specified by:
  `readByte` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readShort

    public short readShort()
                    throws java.sql.SQLException

Read the next attribute in the stream as a Java short.

Specified by:
  `readShort` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readInt

    public int readInt()
                throws java.sql.SQLException

Read the next attribute in the stream as a Java int.

Specified by:
  `readInt` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readString

    public java.lang.String readString(int len)
                                throws java.sql.SQLException

Read the next attribute in the stream as a Java String. We overloaded this method to read in a fix length of characters, from stream that uses default character encoding.

Specified by:
  `readString` in interface `IfmxUDTSQLInput`
Specified by:
  `readString` in interface `SQLUDTInput`
Parameters:
  `len` - the maximum size of data to read in.
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readString

    public java.lang.String readString(int len,
                              java.lang.String dbEnc)
                                throws java.sql.SQLException

Read the next attribute in the stream as a Java String. We overloaded this method to read in a fix length of characters.

Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readBoolean

    public boolean readBoolean()
                        throws java.sql.SQLException

Read the next attribute in the stream as a Java boolean. Booleans are represented as int1 (char) in mitypes.h

Specified by:
  `readBoolean` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readLong

    public long readLong()
                  throws java.sql.SQLException

Read the next attribute in the stream as a Java long. int8 is transported as struct ifx_int8.

Specified by:
  `readLong` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readLongBigint

    public long readLongBigint()
                        throws java.sql.SQLException

Read the next attribute in the stream as a Java long. bigint is transported as struct ifx_bigint.

Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readFloat

    public float readFloat()
                    throws java.sql.SQLException

Read the next attribute in the stream as a Java float.

Specified by:
  `readFloat` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readDouble

    public double readDouble()
                      throws java.sql.SQLException

Read the next attribute in the stream as a Java double.

Specified by:
  `readDouble` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readBigDecimal

    public java.math.BigDecimal readBigDecimal()
                                        throws java.sql.SQLException

Read the next attribute in the stream as a java.math.BigDecimal object.

Specified by:
  `readBigDecimal` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readBytes

    public byte[] readBytes()
                     throws java.sql.SQLException

Read the next attribute in the stream as an array of bytes.

Specified by:
  `readBytes` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readBytes

    public byte[] readBytes(int len)
                     throws java.sql.SQLException

Read the next attribute in the stream as an array of bytes.

Specified by:
  `readBytes` in interface `IfmxUDTSQLInput`
Specified by:
  `readBytes` in interface `SQLUDTInput`
Parameters:
  `len` - the maximum size of data to read in.
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readDate

    public java.sql.Date readDate()
                           throws java.sql.SQLException

Read the next attribute in the stream as a java.sql.Date object.

Specified by:
  `readDate` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readTimestamp

    public java.sql.Timestamp readTimestamp()
                                     throws java.sql.SQLException

Read the next attribute in the stream as a java.sql.Timestamp object. Timestamps are expected as mi_datetime defined in mitypes.h

Specified by:
  `readTimestamp` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readCharacterStream

    public java.io.Reader readCharacterStream()
                                       throws java.sql.SQLException

Return the next attribute in the stream as a stream of Unicode characters.

Specified by:
  `readCharacterStream` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readAsciiStream

    public java.io.InputStream readAsciiStream()
                                        throws java.sql.SQLException

Return the next attribute in the stream as a stream of ASCII characters.

Specified by:
  `readAsciiStream` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readBinaryStream

    public java.io.InputStream readBinaryStream()
                                         throws java.sql.SQLException

Return the next attribute in the stream as a stream of uninterpreted bytes.

Specified by:
  `readBinaryStream` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### readObject

    public java.lang.Object readObject()
                                throws java.sql.SQLException

Return the datum at the head of the stream as a Java object. The actual type of the object returned is determined by the default type mapping, and any customizations present in this stream's type map. A type map is registered with the stream by the JDBC driver before the stream is passed to the application. When the datum at the head of the stream is an SQL NULL, the method returns null. If the datum is an SQL structured or distinct type, it determines the SQL type of the datum at the head of the stream, constructs an object of the appropriate class, and calls method SQLData.readSQL on that object, which reads additional data from the stream, using the protocol described for SQLData.readSQL.

Specified by:
  `readObject` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### readRef

    public java.sql.Ref readRef()
                         throws java.sql.SQLException

Read a REF(<structured-type>) from the stream.

Specified by:
  `readRef` in interface `java.sql.SQLInput`
Returns:
  an object representing data of an SQL REF Type
Throws:
  `java.sql.SQLException`

#### readBlob

    public java.sql.Blob readBlob()
                           throws java.sql.SQLException

Read a BLOB from the stream.

Specified by:
  `readBlob` in interface `java.sql.SQLInput`
Returns:
  an object representing a BLOB
Throws:
  `java.sql.SQLException`

#### readClob

    public java.sql.Clob readClob()
                           throws java.sql.SQLException

Read a CLOB from the stream.

Specified by:
  `readClob` in interface `java.sql.SQLInput`
Returns:
  an object representing a CLOB
Throws:
  `java.sql.SQLException`

#### readArray

    public java.sql.Array readArray()
                             throws java.sql.SQLException

Read an array from the stream.

Specified by:
  `readArray` in interface `java.sql.SQLInput`
Returns:
  an object representing an SQL array
Throws:
  `java.sql.SQLException`

#### readInterval

    public Interval readInterval()
                          throws java.sql.SQLException

Read the next attribute in the stream as an Interval object (IntervalYM or IntervalMF). Interval is mapped to mi_interval defined in mitypes.h and is stored in intrvl_t defined in datetime.h.

Specified by:
  `readInterval` in interface `IfmxUDTSQLInput`
Specified by:
  `readInterval` in interface `SQLUDTInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### setAutoAlignment

    public void setAutoAlignment(boolean value)

Enable or disable automatic alignment. The default is that the driver automatically handles alignment between data fields.

Specified by:
  `setAutoAlignment` in interface `IfmxUDTSQLInput`
Parameters:
  `value` - = true then alignment should be handles automatically. If value = false then no alignment is done. It's the user's respon- sibility to call skipBytes(int) to handle alignment.

#### getAutoAlignment

    public boolean getAutoAlignment()

Returns true if auto alignment is enabled and false if auto alignment has been disabled.

Specified by:
  `getAutoAlignment` in interface `IfmxUDTSQLInput`
Returns:
  true if auto alignment is enabled.

#### skipBytes

    public void skipBytes(int len)
                   throws java.sql.SQLException

Skips over and discards len bytes of data from the input stream. alignment has been disabled.

Specified by:
  `skipBytes` in interface `IfmxUDTSQLInput`
Parameters:
  `len` - Number of bytes to skip over and discard.
Throws:
  `java.sql.SQLException`

#### getCurrentPosition

    public int getCurrentPosition()

Returns the current position in the input stream.

Specified by:
  `getCurrentPosition` in interface `IfmxUDTSQLInput`
Returns:
  Returns the current position.

#### setCurrentPosition

    public void setCurrentPosition(int position)
                            throws java.sql.SQLException

Resets the current position.

Specified by:
  `setCurrentPosition` in interface `IfmxUDTSQLInput`
Parameters:
  `` -
Throws:
  `java.sql.SQLException`

#### available

    public int available()

Returns the number of bytes remaining in this input stream.

Specified by:
  `available` in interface `IfmxUDTSQLInput`
Returns:
  Returns the number of bytes remaining in this input stream.

#### getUDTInfo

    public IfxUDTInfo getUDTInfo(int xid)
                          throws java.sql.SQLException

Get general information about opaque and distinct types and detailed information for complex types. Calls IfmxConnection.getUDTInfo(int) param xid Is the extended id found in sysxtdtype system catalog.

Specified by:
  `getUDTInfo` in interface `IfmxUDTSQLInput`
Parameters:
  `xid` - Is the extended id found in sysxtdtype system catalog.
Returns:
  Object of type IfxUDTInfo which contains all information about a user defined datatype
Throws:
  `java.sql.SQLException`

#### getUDTInfo

    public IfxUDTInfo getUDTInfo(java.lang.String name,
                        java.lang.String owner)
                          throws java.sql.SQLException

Get general information about opaque and distinct types and detailed information for complex types. Calls IfmxConnection.getUDTInfo(String name, String owner)

Specified by:
  `getUDTInfo` in interface `IfmxUDTSQLInput`
Parameters:
  `name` - The data type name.
  `owner` - The owner of the data type (can be null).
Returns:
  The detailed type information as an Informix IfxUDTInfo.
Throws:
  `java.sql.SQLException`

#### readURL

    public java.net.URL readURL()
                         throws java.sql.SQLException

Specified by:
  `readURL` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### readNClob

    public java.sql.NClob readNClob()
                             throws java.sql.SQLException

Specified by:
  `readNClob` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### readNString

    public java.lang.String readNString()
                                 throws java.sql.SQLException

Specified by:
  `readNString` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### readRowId

    public java.sql.RowId readRowId()
                             throws java.sql.SQLException

Specified by:
  `readRowId` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### readSQLXML

    public java.sql.SQLXML readSQLXML()
                               throws java.sql.SQLException

Specified by:
  `readSQLXML` in interface `java.sql.SQLInput`
Throws:
  `java.sql.SQLException`

#### currentPosition

    protected int currentPosition()

#### reset

    protected void reset()

#### checkLength

    protected void checkLength(int len)
                        throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

#### readTime

    public java.sql.Time readTime()
                           throws java.sql.SQLException

Read the next attribute in the stream as a java.sql.Time object. Time are mapped to mi_datetime as defined in mitypes.h

Specified by:
  `readTime` in interface `java.sql.SQLInput`
Returns:
  the attribute; if the value is SQL NULL, return null.
Throws:
  `java.sql.SQLException`

#### wasNull

    public boolean wasNull()

Specified by:
  `wasNull` in interface `java.sql.SQLInput`
Returns:
  true iff the most recently gotten SQL value was null.