Where a user expects the underlying stream to be at a given position,
reposition must be called with the expected position first. A use
case for this scenario is the LOB objects, where you can request a stream and
at the same time (this does not mean concurrently) query the LOB about its
length or ask to get a part of the LOB returned. Such multiplexed operations
must result in consistent and valid data, and to achieve this the underlying
store stream must be able to reposition itself.
Synchronization: Access to instances of this class must be
externally synchronized on the connection synchronization object. There are
two reasons for this:
EmbedConnection#getConnectionSynchronization
| Modifier and Type | Field and Description |
|---|---|
| private long | pos
Position of the underlying store stream. |
| private final InputStream | stream
Underlying store stream serving bytes. |
| Access | Constructor and Description |
|---|---|
| public | PositionedStoreStream(InputStream
a in)Resetable-streamCreates a positioned store stream on top of the specified resettable stream. |
| Modifier and Type | Method and Description |
|---|---|
| public InputStream | asInputStream()
Implements org. Returns a reference to self as an |
| public void | closeStream()
Implements org. Closes the resettable stream. |
| public long | Returns: Current byte position of the store stream.Implements org. Returns the current position of the underlying store stream. |
| public void | initStream()
Implements org. Initialize the resettable stream for use. |
| public int | Returns: The actual number of bytes read, or -1 if the end of the stream is reached.the buffer into which the data is read. b)Overrides java. Reads a number of bytes from the underlying stream and stores them in the specified byte array. |
| public int | Returns: The actual number of bytes read, or -1 if the end of the stream is reached.the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. Reads a number of bytes from the underlying stream and stores them in the specified byte array at the specified offset. |
| public int | Returns: The next byte of data, or -1 if the end of the stream is reached.Implements abstract java. Reads a single byte from the underlying stream. |
| public void | reposition(final long
requested byte position, first position is requestedPos)0Implements org. Repositions the underlying store stream to the requested position. |
| public void | resetStream()
Implements org. Resets the resettable stream. |
| public long | Returns: The actual number of bytes skipped.the number of bytes to be skipped. toSkip)Overrides java. Skips up to the specified number of bytes from the underlying stream. |
| pos | back to summary |
|---|---|
| private long pos Position of the underlying store stream. Note that the position is maintained by this class, not the underlying store stream itself. Future improvement: Add this functionality to the underlying store stream itself to avoid another level in the stream stack. | |
| stream | back to summary |
|---|---|
| private final InputStream stream Underlying store stream serving bytes. | |
| PositionedStoreStream | back to summary |
|---|---|
| public PositionedStoreStream(InputStream in) throws IOException, StandardException Creates a positioned store stream on top of the specified resettable stream. Upon creation, the underlying stream is initiated and reset to make sure the states of the streams are in sync with each other.
| |
| asInputStream | back to summary |
|---|---|
| public InputStream asInputStream() Implements org. Doc from org. Returns a reference to self as an
This method is not allowed to return
| |
| closeStream | back to summary |
|---|---|
| public void closeStream() Implements org. Closes the resettable stream.
| |
| getPosition | back to summary |
|---|---|
| public long getPosition() Implements org. Returns the current position of the underlying store stream.
| |
| initStream | back to summary |
|---|---|
| public void initStream() throws StandardException Implements org. Initialize the resettable stream for use.
| |
| read | back to summary |
|---|---|
| public int read(byte[] b) throws IOException Overrides java. Reads a number of bytes from the underlying stream and stores them in the specified byte array.
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Reads a number of bytes from the underlying stream and stores them in the specified byte array at the specified offset.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Reads a single byte from the underlying stream.
| |
| reposition | back to summary |
|---|---|
| public void reposition(final long requestedPos) throws IOException, StandardException Implements org. Repositions the underlying store stream to the requested position. Repositioning is required because there can be several uses of the store stream, which changes the position of it. If a class is dependent on the underlying stream not changing its position, it must call reposition with the position it expects before using the stream again.
If the repositioning fails because the stream is exhausted, most likely
because of an invalid position specified by the user, the stream is
reset to position zero and the
| |
| resetStream | back to summary |
|---|---|
| public void resetStream() throws IOException, StandardException Implements org. Resets the resettable stream.
| |
| skip | back to summary |
|---|---|
| public long skip(long toSkip) throws IOException Overrides java. Skips up to the specified number of bytes from the underlying stream.
| |