Package org.apache.derby.client.am
Class ClobLocatorOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.derby.client.am.ClobLocatorOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
class ClobLocatorOutputStream extends java.io.OutputStreamAnOutputStreamthat will use an locator to write bytes to the Clob value on the server.Closing a
ByteArrayInputStreamhas no effect. The methods in this class can be called after the stream has been closed without generating anIOException.This
OutputStreamimplementation is pretty basic. No buffering of data is done. Hence, for efficiency #write(byte[]) should be used instead of #write(int).
-
-
Field Summary
Fields Modifier and Type Field Description private ClientClobclobThe Clob to be accessed.private longcurrentPosCurrent position in the underlying Clob.
-
Constructor Summary
Constructors Constructor Description ClobLocatorOutputStream(ClientClob clob, long pos)Create anOutputStreamfor writing to theClobvalue represented by the given locator basedClobobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)private voidwriteBytes(byte[] b)Write thebyte[]to theClobvalue on the server; starting from the current position of this stream.
-
-
-
Field Detail
-
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
-
-
Constructor Detail
-
ClobLocatorOutputStream
ClobLocatorOutputStream(ClientClob clob, long pos) throws SqlException
Create anOutputStreamfor writing to theClobvalue represented by the given locator basedClobobject.- Parameters:
clob-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
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException- See Also:
This method writes one byte at a time to the server. For more efficient writing, use #write(byte[]).
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException- See Also:
OutputStream.write(byte[])
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException- See Also:
OutputStream.write(byte[], int, int)
-
flush
public void flush()
- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- See Also:
OutputStream.flush()
-
writeBytes
private void writeBytes(byte[] b) throws java.io.IOExceptionWrite thebyte[]to theClobvalue on the server; starting from the current position of this stream.- Parameters:
b- The byte array containing the bytes to be written- Throws:
java.io.IOException- Wrapped SqlException if writing to server fails.
-
-