java.io.Closeable
, java.lang.AutoCloseable
class UpdatableBlobStream
extends java.io.InputStream
Modifier and Type | Field | Description |
---|---|---|
private EmbedBlob |
blob |
|
private boolean |
materialized |
Flag to check if it is using stream from LOBStreamControl or from DVD.
|
private long |
maxPos |
Position in Blob where to stop reading unless EOF is reached first.
|
private long |
pos |
|
private java.io.InputStream |
stream |
Constructor | Description |
---|---|
UpdatableBlobStream(EmbedBlob blob,
java.io.InputStream is) |
Constructs UpdatableBlobStream using the the InputStream receives as the
parameter.
|
UpdatableBlobStream(EmbedBlob blob,
java.io.InputStream is,
long pos,
long len) |
Construct an
UpdatableBlobStream using the
InputStream received as parameter. |
Modifier and Type | Method | Description |
---|---|---|
int |
read() |
Reads the next byte of data from the input stream.
|
int |
read(byte[] b) |
Reads some number of bytes from the input stream and stores them into
the buffer array
b . |
int |
read(byte[] b,
int off,
int len) |
Reads up to
len bytes of data from the input stream into
an array of bytes. |
long |
skip(long n) |
Skips over and discards
n bytes of data from this input
stream. |
private void |
updateIfRequired() |
Checks if this object is using materialized blob
if not it checks if the blob was materialized since
this stream was last access.
|
private boolean materialized
true
means data is read from LOBStreamControl,
false
means data is read from the DVD.private java.io.InputStream stream
private long pos
private final EmbedBlob blob
private final long maxPos
UpdatableBlobStream(EmbedBlob blob, java.io.InputStream is) throws java.io.IOException
0
.blob
- EmbedBlob this stream is associated with.is
- InputStream this class is going to use internally.java.io.IOException
- if an I/O error occursUpdatableBlobStream(EmbedBlob blob, java.io.InputStream is, long pos, long len) throws java.io.IOException
UpdatableBlobStream
using the
InputStream
received as parameter. The initial
position in the stream is set to pos
and the
stream is restricted to a length of len
.blob
- EmbedBlob this stream is associated with.is
- InputStream this class is going to use internally.pos
- initial positionlen
- The length to which the underlying InputStream
has to be restricted.java.io.IOException
private void updateIfRequired() throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
int
in the range 0
to
255
. If no byte is available because the end of the stream
has been reached, the value -1
is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
A subclass must provide an implementation of this method.
Note that this stream will reflect changes made to the underlying Blob at positions equal to or larger then the current position.
read
in class java.io.InputStream
-1
if the end of the
stream is reached.java.io.IOException
- if an I/O error occurs.InputStream.read()
public int read(byte[] b, int off, int len) throws java.io.IOException
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.
Note that this stream will reflect changes made to the underlying Blob at positions equal to or larger then the current position .
read
in class java.io.InputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.-1
if there is no more data because the end of
the stream has been reached.java.io.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.java.lang.NullPointerException
- If b
is null
.java.lang.IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is greater than
b.length - off
InputStream.read(byte[],int,int)
public int read(byte[] b) throws java.io.IOException
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.
Note that this stream will reflect changes made to the underlying Blob at positions equal to or larger then the current position .
read
in class java.io.InputStream
b
- the buffer into which the data is read.-1
is there is no more data because the end of
the stream has been reached.java.io.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.java.lang.NullPointerException
- if b
is null
.InputStream.read(byte[])
public long skip(long n) throws java.io.IOException
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, no bytes are skipped.
Note that this stream will reflect changes made to the underlying Blob at positions equal to or larger then the current position .
skip
in class java.io.InputStream
n
- the number of bytes to be skipped.java.io.IOException
- if the stream does not support seek,
or if some other I/O error occurs.InputStream.skip(long)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.