Package org.apache.derby.impl.drda
Class EXTDTAInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.derby.impl.drda.EXTDTAInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class EXTDTAInputStream extends java.io.InputStream
EXTDTAObjectHolder provides Externalized Large Object representation that does not hold locks until the end of the transaction (DERBY-255) It serves as a holder for lob data and is only valid as long as the original result set from which it came is on the same row.
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.Blob
_blob
private java.sql.Clob
_clob
private java.io.InputStream
binaryInputStream
(package private) int
columnNumber
Column index starting with 1(package private) int
ndrdaType
DRDA Type of column/parameter(package private) EngineResultSet
rs
ResultSet that contains the stream
-
Constructor Summary
Constructors Modifier Constructor Description private
EXTDTAInputStream(java.sql.Blob blob, int ndrdaType)
private
EXTDTAInputStream(java.sql.Clob clob, int ndrdaType)
private
EXTDTAInputStream(java.sql.ResultSet rs, int columnNumber, int ndrdaType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
private static void
badDRDAType(int drdaType)
void
close()
boolean
equals(java.lang.Object arg0)
protected void
finalize()
private java.io.InputStream
getBinaryStream()
private java.io.Reader
getCharacterStream()
static EXTDTAInputStream
getEXTDTAStream(java.sql.CallableStatement cs, int column, int drdaType)
Create a new EXTDTAInputStream from a CallableStatement.static EXTDTAInputStream
getEXTDTAStream(java.sql.ResultSet rs, int column, int drdaType)
Create a new EXTDTAInputStream.int
hashCode()
void
initInputStream()
This method takes information of ResultSet and initializes the binaryInputStream variable of this object with not empty stream by calling getBinaryStream or getCharacterStream() as appropriate.protected boolean
isEmptyStream()
boolean
isNull()
Is the value null?private long
length()
void
mark(int arg0)
boolean
markSupported()
int
read()
RequiresinitInputStream()
be called before we can read from the streamint
read(byte[] arg0)
int
read(byte[] arg0, int arg1, int arg2)
void
reset()
long
skip(long arg0)
-
-
-
Field Detail
-
binaryInputStream
private java.io.InputStream binaryInputStream
-
ndrdaType
int ndrdaType
DRDA Type of column/parameter
-
rs
EngineResultSet rs
ResultSet that contains the stream
-
columnNumber
int columnNumber
Column index starting with 1
-
_clob
private java.sql.Clob _clob
-
_blob
private java.sql.Blob _blob
-
-
Method Detail
-
getEXTDTAStream
public static EXTDTAInputStream getEXTDTAStream(java.sql.ResultSet rs, int column, int drdaType)
Create a new EXTDTAInputStream. Before read the stream must be initialized by the user withinitInputStream()
- Parameters:
rs
- result set from which to retrieve the lobcolumn
- column numberdrdaType
- FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED- Returns:
- null if the value is null or a new EXTDTAInputStream corresponding to rs.getBinaryStream(column) value and associated length
- Throws:
java.sql.SQLException
- See Also:
DDMWriter.writeScalarStream(boolean, int, org.apache.derby.impl.drda.EXTDTAInputStream, boolean)
,initInputStream()
-
getEXTDTAStream
public static EXTDTAInputStream getEXTDTAStream(java.sql.CallableStatement cs, int column, int drdaType) throws java.sql.SQLException
Create a new EXTDTAInputStream from a CallableStatement.- Parameters:
cs
- CallableStatement from which to retrieve the lobcolumn
- column numberdrdaType
- FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED- Throws:
java.sql.SQLException
-
read
public int read() throws java.io.IOException
RequiresinitInputStream()
be called before we can read from the stream- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.read()
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.available()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.close()
-
equals
public boolean equals(java.lang.Object arg0)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
mark
public void mark(int arg0)
- Overrides:
mark
in classjava.io.InputStream
- See Also:
InputStream.mark(int)
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
- See Also:
InputStream.markSupported()
-
read
public int read(byte[] arg0) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.read(byte[])
-
read
public int read(byte[] arg0, int arg1, int arg2) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.read(byte[], int, int)
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.reset()
-
skip
public long skip(long arg0) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
- See Also:
InputStream.skip(long)
-
isEmptyStream
protected boolean isEmptyStream() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
length
private long length() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
initInputStream
public void initInputStream() throws java.sql.SQLException
This method takes information of ResultSet and initializes the binaryInputStream variable of this object with not empty stream by calling getBinaryStream or getCharacterStream() as appropriate. The Reader returned from getCharacterStream() will be encoded in binarystream.- Throws:
java.sql.SQLException
-
getBinaryStream
private java.io.InputStream getBinaryStream() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getCharacterStream
private java.io.Reader getCharacterStream() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
badDRDAType
private static void badDRDAType(int drdaType)
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
isNull
public boolean isNull() throws java.sql.SQLException
Is the value null? Null status is obtained from the underlying EngineResultSet or LOB, so that it can be determined before the stream is retrieved.- Returns:
- true if this value is null
- Throws:
java.sql.SQLException
-
-