org.apache.derby.client.am
Class ClobLocatorWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.apache.derby.client.am.ClobLocatorWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class ClobLocatorWriter
extends java.io.Writer

An Writer that will use an locator to write the Clob value into the server.

This Writer implementation is pretty basic. No buffering of data is done. Hence, for efficieny #write(char[]) should be used instead of #write(int).


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 Writer has been closed or not.
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
ClobLocatorWriter(Connection connection, Clob clob, long pos)
          Create a Writer for writing to the Clob value represented by the given locator based Clob object.
 
Method Summary
private  void checkClosed()
          Check to see if this Writer is closed.
 void close()
           
 void flush()
           
 void write(char[] c)
           
 void write(char[] c, int off, int len)
           
 void write(int c)
           
private  void writeCharacters(char[] c, int off, int len)
          Write the char[] to the Clob value on the server; starting from the current position of this stream.
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
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


isClosed

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

Constructor Detail

ClobLocatorWriter

public ClobLocatorWriter(Connection connection,
                         Clob clob,
                         long pos)
                  throws SqlException
Create a Writer for writing to the Clob value represented by the given locator based Clob object.

Parameters:
connection - connection to be used to write to the Clob value on the server
clob - Clob object that contains locator for the Clob value on the server.
pos - the position in the CLOB value at which to start writing; the first position is 1
Throws:
SqlException
Method Detail

close

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

checkClosed

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

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

write

public void write(int c)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException
See Also:
This method writes one Character at a time to the server. For more efficient writing, use #write(char[]).

write

public void write(char[] c)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException
See Also:
Writer.write(char[])

flush

public void flush()
Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
See Also:
Writer.flush()

write

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

writeCharacters

private void writeCharacters(char[] c,
                             int off,
                             int len)
                      throws java.io.IOException
Write the char[] to the Clob value on the server; starting from the current position of this stream.

Parameters:
c - The character array containing the chars to be written
Throws:
java.io.IOException - Wrapped SqlException if writing to 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.