Top Description Fields Constructors Methods
org.apache.derby.client.am

pack-priv Class ClobLocatorReader

extends Reader
Class Inheritance
Imports
java.io.IOException, .Reader, org.apache.derby.shared.common.sanity.SanityManager

An Reader that will use an locator to fetch the Clob value from the server.

This Reader implementation is pretty basic. No buffering of data is done. Hence, for efficiency #read(char[]) should be used instead of #read(). Marks are not supported, but it should be pretty simple to extend the implementation to support this. A more efficient skip implementation should also be straight-forward.

Field Summary

Modifier and TypeField and Description
private final ClientClob
clob

The Clob to be accessed.

private final ClientConnection
connection

Connection used to read Clob from server.

private long
currentPos

Current position in the underlying Clob.

private boolean
isClosed

Stores the information to whether this Reader has been closed or not.

private final long
maxPos

Position in Clob where to stop reading.

Inherited from java.io.Reader:
lock

Constructor Summary

AccessConstructor and Description
pack-priv
ClobLocatorReader(ClientConnection
connection to be used to read the Clob value from the server
connection
,
ClientClob
Clob object that contains locator for the Clob value on the server.
clob
)

Create an Reader for reading the Clob value represented by the given locator based Clob object.

pack-priv
ClobLocatorReader(ClientConnection
connection to be used to read the Clob value from the server
connection
,
ClientClob
Clob object that contains locator for the Clob value on the server.
clob
,
long
The offset to the first character of the partial value to be retrieved.
pos
,
long
The length in characters of the partial value to be retrieved.
len
)

Create an Reader for reading the Clob value represented by the given locator based Clob object.

Method Summary

Modifier and TypeMethod and Description
private void
checkClosed()

Check to see if this Reader is closed.

public void
close()

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
public int
read()

Overrides java.io.Reader.read.

Reads a single character.
public int
read(char[]
Destination buffer
c
,
int
Offset at which to start storing characters
off
,
int
Maximum number of characters to read
len
)

Implements abstract java.io.Reader.read.

Reads characters into a portion of an array.
private char[]

Returns:

char[] containing the read characters.
readCharacters
(int
number of characters to read.
len
)

Read the next len characters of the Clob value from the server.

Inherited from java.io.Reader:
markmarkSupportednullReaderreadreadreadyresetskiptransferTo

Field Detail

clobback to summary
private final ClientClob clob

The Clob to be accessed.

connectionback to summary
private final ClientConnection connection

Connection used to read Clob from server.

currentPosback to summary
private long currentPos

Current position in the underlying Clob. Clobs are indexed from 1

isClosedback to summary
private boolean isClosed

Stores the information to whether this Reader has been closed or not. Is set to true if close() has been called. Is false otherwise.

maxPosback to summary
private final long maxPos

Position in Clob where to stop reading. maxPos starts counting from 1.

Constructor Detail

ClobLocatorReaderback to summary
pack-priv ClobLocatorReader(ClientConnection connection, ClientClob clob) throws SqlException

Create an Reader for reading the Clob value represented by the given locator based Clob object.

Parameters
connection:ClientConnection

connection to be used to read the Clob value from the server

clob:ClientClob

Clob object that contains locator for the Clob value on the server.

ClobLocatorReaderback to summary
pack-priv ClobLocatorReader(ClientConnection connection, ClientClob clob, long pos, long len) throws SqlException

Create an Reader for reading the Clob value represented by the given locator based Clob object.

Parameters
connection:ClientConnection

connection to be used to read the Clob value from the server

clob:ClientClob

Clob object that contains locator for the Clob value on the server.

pos:long

The offset to the first character of the partial value to be retrieved.

len:long

The length in characters of the partial value to be retrieved.

Method Detail

checkClosedback to summary
private void checkClosed() throws IOException

Check to see if this Reader is closed. If it is closed throw an IOException that states that the stream is closed.

Exceptions
IOException:
if isClosed = true.
closeback to summary
public void close() throws IOException

Implements abstract java.io.Reader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Exceptions
IOException:
If an I/O error occurs
See Also
java.io.Reader#close()
readback to summary
public int read() throws IOException

Overrides java.io.Reader.read.

Doc from java.io.Reader.read.

Reads a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Subclasses that intend to support efficient single-character input should override this method.

Returns:int

The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
See Also
This method fetches one character at a time from the server. For more efficient retrieval, use #read(char[]).
readback to summary
public int read(char[] c, int off, int len) throws IOException

Implements abstract java.io.Reader.read.

Doc from java.io.Reader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
c:char[]

Destination buffer

off:int

Offset at which to start storing characters

len:int

Maximum number of characters to read

Returns:int

The number of characters read, or -1 if the end of the stream has been reached

Exceptions
IOException:
If an I/O error occurs
See Also
java.io.Reader#read(char[], int, int)
readCharactersback to summary
private char[] readCharacters(int len) throws IOException

Read the next len characters of the Clob value from the server.

Parameters
len:int

number of characters to read.

Returns:char[]

char[] containing the read characters.

Exceptions
IOException:
Wrapped SqlException if reading from server fails.