org.apache.derby.client.am
Class ClobLocatorReader

java.lang.Object
  extended by java.io.Reader
      extended by org.apache.derby.client.am.ClobLocatorReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class ClobLocatorReader
extends java.io.Reader

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 efficieny #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
private  Clob clob
          The Clob to be accessed.
private  Connection 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  long maxPos
          Position in Clob where to stop reading.
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
ClobLocatorReader(Connection connection, Clob clob)
          Create an Reader for reading the Clob value represented by the given locator based Clob object.
ClobLocatorReader(Connection connection, Clob clob, long pos, long len)
          Create an Reader for reading the Clob value represented by the given locator based Clob object.
 
Method Summary
private  void checkClosed()
          Check to see if this Reader is closed.
 void close()
           
 int read()
           
 int read(char[] c, int off, int len)
           
private  char[] readCharacters(int len)
          Read the next len characters of the Clob value from the server.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

private final Connection connection
Connection used to read Clob from server.


clob

private final Clob clob
The Clob to be accessed.


currentPos

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


maxPos

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


isClosed

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.

Constructor Detail

ClobLocatorReader

public ClobLocatorReader(Connection connection,
                         Clob clob)
                  throws SqlException
Create an Reader for reading the Clob value represented by the given locator based Clob object.

Parameters:
connection - connection to be used to read the Clob value from the server
clob - Clob object that contains locator for the Clob value on the server.
Throws:
SqlException

ClobLocatorReader

public ClobLocatorReader(Connection connection,
                         Clob 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 - connection to be used to read the Clob value from the server
clob - Clob object that contains locator for the Clob value on the server.
pos - The offset to the first character of the partial value to be retrieved.
len - The length in characters of the partial value to be retrieved.
Throws:
SqlException
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.Reader
Throws:
java.io.IOException
See Also:
This method fetches one character at a time from the server. For more efficient retrieval, use #read(char[]).

read

public int read(char[] c,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.read(char[], int, int)

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.close()

checkClosed

private void checkClosed()
                  throws java.io.IOException
Check to see if this Reader is closed. If it is closed throw an IOException that states that the stream is closed.

Throws:
java.io.IOException - if isClosed = true.

readCharacters

private char[] readCharacters(int len)
                       throws java.io.IOException
Read the next len characters of the Clob value from the server.

Parameters:
len - number of characters to read.
Returns:
char[] containing the read characters.
Throws:
java.io.IOException - Wrapped SqlException if reading from server fails.

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.