Package org.apache.derby.client.am
Class ClobLocatorWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.derby.client.am.ClobLocatorWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.Appendable,java.lang.AutoCloseable
class ClobLocatorWriter extends java.io.WriterAnWriterthat will use an locator to write the Clob value into the server.This
Writerimplementation is pretty basic. No buffering of data is done. Hence, for efficiency#write(char[])should be used instead of#write(int).
-
-
Field Summary
Fields Modifier and Type Field Description private ClientClobclobThe Clob to be accessed.private ClientConnectionconnectionConnection used to read Clob from server.private longcurrentPosCurrent position in the underlying Clob.private booleanisClosedStores the information to whether this Writer has been closed or not.
-
Constructor Summary
Constructors Constructor Description ClobLocatorWriter(ClientConnection connection, ClientClob clob, long pos)Create aWriterfor writing to theClobvalue represented by the given locator basedClobobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckClosed()Check to see if thisWriteris closed.voidclose()voidflush()voidwrite(char[] c)voidwrite(char[] c, int off, int len)voidwrite(int c)private voidwriteCharacters(char[] c, int off, int len)Write thechar[]to theClobvalue on the server; starting from the current position of this stream.
-
-
-
Field Detail
-
connection
private final ClientConnection connection
Connection used to read Clob from server.
-
clob
private final ClientClob 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
ClobLocatorWriter(ClientConnection connection, ClientClob clob, long pos) throws SqlException
Create aWriterfor writing to theClobvalue represented by the given locator basedClobobject.- Parameters:
connection- connection to be used to write to theClobvalue on the serverclob-Clobobject that contains locator for theClobvalue on the server.pos- the position in theCLOBvalue at which to start writing; the first position is 1- Throws:
SqlException
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Writer- Throws:
java.io.IOException- See Also:
Writer.close()
-
checkClosed
private void checkClosed() throws java.io.IOExceptionCheck to see if thisWriteris closed. If it is closed throw anIOExceptionthat states that the stream is closed.- Throws:
java.io.IOException- if isClosed = true.
-
write
public void write(int c) throws java.io.IOException- Overrides:
writein classjava.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:
writein classjava.io.Writer- Throws:
java.io.IOException- See Also:
Writer.write(char[])
-
flush
public void flush()
- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classjava.io.Writer- See Also:
Writer.flush()
-
write
public void write(char[] c, int off, int len) throws java.io.IOException- Specified by:
writein classjava.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.IOExceptionWrite thechar[]to theClobvalue 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.
-
-