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

pack-priv final Class AutoPositioningStream

extends BinaryToRawStream
Class Inheritance
Imports
org.apache.derby.shared.common.error.StandardException, java.io.EOFException, .IOException, .InputStream, org.apache.derby.shared.common.sanity.SanityManager

This Stream is a wrapper for PositionedStoreStream to set the position correctly before performing any operation on it. All the read and skip methods ensure that the PositionedStoreStream is set to right position before actually performing these operations. PositionedStoreStream is accessed within synchronized block to ensure exclusive access to it. This class must be constructed while synchronizing on ConnectionChild.getConnectionSynchronization

Field Summary

Modifier and TypeField and Description
private final ConnectionChild
conChild

ConnectionChild to get synchronizion object

private long
private final PositionedStoreStream

Constructor Summary

AccessConstructor and Description
pack-priv
AutoPositioningStream(ConnectionChild
ConnectionChild to get synchronization object before accessing PositionedStoreStream
conChild
,
InputStream
InputStream
in
,
Object
Parent of the stream to prevent it from being gc.
parent
)

Constructs AutoPositioningStream object.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The next byte of data, or -1 if the end of the stream is reached.
read
()

Overrides java.io.FilterInputStream.read.

Reads a single byte from the underlying stream.

public int

Returns:

The actual number of bytes read, or -1 if the end of the stream is reached.
read
(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

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 actual number of bytes read, or -1 if the end of the stream is reached.
read
(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.FilterInputStream.read.

Reads a number of bytes from the underlying stream and stores them in the specified byte array.

private void
setPosition()

Checks if positionedStream's position was changed since last used, sets the position to right position if its changed.

public long

Returns:

The actual number of bytes skipped.
skip
(long
the number of bytes to be skipped.
n
)

Overrides java.io.FilterInputStream.skip.

Skips up to the specified number of bytes from the underlying stream.

Inherited from org.apache.derby.impl.jdbc.BinaryToRawStream:
getLength

Field Detail

conChildback to summary
private final ConnectionChild conChild

ConnectionChild to get synchronizion object

posback to summary
private long pos
positionedStreamback to summary
private final PositionedStoreStream positionedStream

Constructor Detail

AutoPositioningStreamback to summary
pack-priv AutoPositioningStream(ConnectionChild conChild, InputStream in, Object parent) throws IOException

Constructs AutoPositioningStream object. This constructor must be called from block synchronized on conChild.getConnectionSynchronization.

Parameters
conChild:ConnectionChild

ConnectionChild to get synchronization object before accessing PositionedStoreStream

in:InputStream

InputStream

parent:Object

Parent of the stream to prevent it from being gc.

Exceptions
IOException:
if an I/O error occurs

Method Detail

readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Reads a single byte from the underlying stream.

Returns:int

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

Exceptions
IOException:
if an I/O error occurs
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Reads a number of bytes from the underlying stream and stores them in the specified byte array at the specified offset.

Parameters
b:byte[]

Doc from java.io.FilterInputStream.read.

the buffer into which the data is read.

off:int

Doc from java.io.FilterInputStream.read.

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

len:int

Doc from java.io.FilterInputStream.read.

the maximum number of bytes to read.

Returns:int

The actual number of bytes read, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.FilterInputStream.read.

Reads a number of bytes from the underlying stream and stores them in the specified byte array.

Parameters
b:byte[]

Doc from java.io.FilterInputStream.read.

the buffer into which the data is read.

Returns:int

The actual number of bytes read, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs
setPositionback to summary
private void setPosition() throws IOException

Checks if positionedStream's position was changed since last used, sets the position to right position if its changed.

skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Skips up to the specified number of bytes from the underlying stream.

Parameters
n:long

Doc from java.io.FilterInputStream.skip.

the number of bytes to be skipped.

Returns:long

The actual number of bytes skipped.

Exceptions
IOException:
if an I/O error occurs