Top Description Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv Class EXTDTAInputStream

extends InputStream
Class Inheritance
Imports
java.io.BufferedInputStream, .IOException, .InputStream, .Reader, java.sql.Blob, .CallableStatement, .Clob, .ResultSet, .SQLException, org.apache.derby.iapi.jdbc.EngineResultSet, org.apache.derby.shared.common.reference.DRDAConstants, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.impl.jdbc.Util

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

Modifier and TypeField and Description
private Blob
private Clob
private InputStream
pack-priv int
columnNumber

Column index starting with 1

pack-priv int
ndrdaType

DRDA Type of column/parameter

pack-priv EngineResultSet
rs

ResultSet that contains the stream

Constructor Summary

AccessConstructor and Description
private
EXTDTAInputStream(ResultSet rs, int columnNumber, int ndrdaType)

private
EXTDTAInputStream(Clob clob, int ndrdaType)

private
EXTDTAInputStream(Blob blob, int ndrdaType)

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.
private static void
badDRDAType(int drdaType)

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
public boolean
equals(Object
the reference object with which to compare.
arg0
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
private InputStream
private Reader
public static EXTDTAInputStream

Returns:

null if the value is null or a new EXTDTAInputStream corresponding to rs.getBinaryStream(column) value and associated length
getEXTDTAStream
(ResultSet
result set from which to retrieve the lob
rs
,
int
column number
column
,
int
FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED
drdaType
)

Create a new EXTDTAInputStream.

public static EXTDTAInputStream
getEXTDTAStream(CallableStatement
CallableStatement from which to retrieve the lob
cs
,
int
column number
column
,
int
FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED
drdaType
)

Create a new EXTDTAInputStream from a CallableStatement.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public 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
public boolean

Returns:

true if this value is null
isNull
()

Is the value null?

private long
public void
mark(int
the maximum limit of bytes that can be read before the mark position becomes invalid.
arg0
)

Overrides java.io.InputStream.mark.

Marks the current position in this input stream.
public boolean
markSupported()

Overrides java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods.
public int
read()

Implements abstract java.io.InputStream.read.

Requires initInputStream() be called before we can read from the stream
public int
read(byte[]
the buffer into which the data is read.
arg0
)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.
public int
read(byte[]
the buffer into which the data is read.
arg0
,
int
the start offset in array b at which the data is written.
arg1
,
int
the maximum number of bytes to read.
arg2
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.
public void
reset()

Overrides java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.
public long
skip(long
the number of bytes to be skipped.
arg0
)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.
Inherited from java.io.InputStream:
nullInputStreamreadAllBytesreadNBytesreadNBytesskipNBytestransferTo

Field Detail

_blobback to summary
private Blob _blob
_clobback to summary
private Clob _clob
binaryInputStreamback to summary
private InputStream binaryInputStream
columnNumberback to summary
pack-priv int columnNumber

Column index starting with 1

ndrdaTypeback to summary
pack-priv int ndrdaType

DRDA Type of column/parameter

rsback to summary
pack-priv EngineResultSet rs

ResultSet that contains the stream

Constructor Detail

EXTDTAInputStreamback to summary
private EXTDTAInputStream(ResultSet rs, int columnNumber, int ndrdaType)
EXTDTAInputStreamback to summary
private EXTDTAInputStream(Clob clob, int ndrdaType)
EXTDTAInputStreamback to summary
private EXTDTAInputStream(Blob blob, int ndrdaType)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#available()
badDRDATypeback to summary
private static void badDRDAType(int drdaType)
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#close()
equalsback to summary
public boolean equals(Object arg0)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
arg0:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

See Also
java.lang.Object#equals(java.lang.Object)
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@SuppressWarnings:deprecation, removal
Exceptions
Throwable:
the Exception raised by this method
getBinaryStreamback to summary
private InputStream getBinaryStream() throws SQLException
getCharacterStreamback to summary
private Reader getCharacterStream() throws SQLException
getEXTDTAStreamback to summary
public static EXTDTAInputStream getEXTDTAStream(ResultSet rs, int column, int drdaType)

Create a new EXTDTAInputStream. Before read the stream must be initialized by the user with initInputStream()

Parameters
rs:ResultSet

result set from which to retrieve the lob

column:int

column number

drdaType:int

FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED

Returns:EXTDTAInputStream

null if the value is null or a new EXTDTAInputStream corresponding to rs.getBinaryStream(column) value and associated length

See Also
DDMWriter#writeScalarStream, initInputStream()
getEXTDTAStreamback to summary
public static EXTDTAInputStream getEXTDTAStream(CallableStatement cs, int column, int drdaType) throws SQLException

Create a new EXTDTAInputStream from a CallableStatement.

Parameters
cs:CallableStatement

CallableStatement from which to retrieve the lob

column:int

column number

drdaType:int

FD:OCA type of object one of DRDAConstants.DRDA_TYPE_NLOBBYTES DRDAConstants.DRDA_TYPE_LOBBYTES DRDAConstants.DRDA_TYPE_NLOBCMIXED DRDAConstants.DRDA_TYPE_LOBCMIXED

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

See Also
java.lang.Object#hashCode()
initInputStreamback to summary
public void initInputStream() throws 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.

isEmptyStreamback to summary
protected boolean isEmptyStream() throws SQLException
isNullback to summary
public boolean isNull() throws 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:boolean

true if this value is null

lengthback to summary
private long length() throws SQLException
markback to summary
public void mark(int arg0)

Overrides java.io.InputStream.mark.

Doc from java.io.InputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit arguments tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

The general contract of mark is that, if the method markSupported returns true, the stream somehow remembers all the bytes read after the call to mark and stands ready to supply those same bytes again if and whenever the method reset is called. However, the stream is not required to remember any data at all if more than readlimit bytes are read from the stream before reset is called.

Marking a closed stream should not have any effect on the stream.

Parameters
arg0:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

See Also
java.io.InputStream#mark(int)
markSupportedback to summary
public boolean markSupported()

Overrides java.io.InputStream.markSupported.

Doc from java.io.InputStream.markSupported.

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

Returns:boolean

true if this stream instance supports the mark and reset methods; false otherwise.

See Also
java.io.InputStream#markSupported()
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Requires initInputStream() be called before we can read from the stream

Returns:int

Doc from java.io.InputStream.read.

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:

Doc from java.io.InputStream.read.

if an I/O error occurs.

See Also
java.io.InputStream#read()
readback to summary
public int read(byte[] arg0) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Parameters
arg0:byte[]

the buffer into which the data is read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
See Also
java.io.InputStream#read(byte[])
readback to summary
public int read(byte[] arg0, int arg1, int arg2) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
arg0:byte[]

the buffer into which the data is read.

arg1:int

the start offset in array b at which the data is written.

arg2:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
See Also
java.io.InputStream#read(byte[], int, int)
resetback to summary
public void reset() throws IOException

Overrides java.io.InputStream.reset.

Doc from java.io.InputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

The general contract of reset is:

  • If the method markSupported returns true, then:
    • If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown.
    • If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.
  • If the method markSupported returns false, then:
    • The call to reset may throw an IOException.
    • If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.
Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
See Also
java.io.InputStream#reset()
skipback to summary
public long skip(long arg0) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Parameters
arg0:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped which might be zero.

Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.InputStream#skip(long)