org.apache.derby.client.am
Class BlobLocatorOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.derby.client.am.BlobLocatorOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class BlobLocatorOutputStream
extends java.io.OutputStream

An OutputStream that will use an locator to write bytes to the Blob value on the server.

Closing a BlobLocatorOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

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


Field Summary
private  Blob blob
          The Blob to be accessed.
private  Connection connection
          Connection used to read Blob from server.
private  long currentPos
          Current position in the underlying Blob.
 
Constructor Summary
BlobLocatorOutputStream(Connection connection, Blob blob, long pos)
          Create an OutputStream for writing to the Blob value represented by the given locator based Blob object.
 
Method Summary
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
private  void writeBytes(byte[] b)
          Write the byte[] to the Blob value on the server; starting from the current position of this stream.
 
Methods inherited from class java.io.OutputStream
close, flush
 
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 Blob from server.


blob

private final Blob blob
The Blob to be accessed.


currentPos

private long currentPos
Current position in the underlying Blob. Blobs are indexed from 1

Constructor Detail

BlobLocatorOutputStream

public BlobLocatorOutputStream(Connection connection,
                               Blob blob,
                               long pos)
                        throws SqlException
Create an OutputStream for writing to the Blob value represented by the given locator based Blob object.

Parameters:
connection - connection to be used to write to the Blob value on the server
blob - Blob object that contains locator for the Blob value on the server.
pos - the position in the BLOB value 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:
write in class java.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:
write in class java.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:
write in class java.io.OutputStream
Throws:
java.io.IOException
See Also:
OutputStream.write(byte[], int, int)

writeBytes

private void writeBytes(byte[] b)
                 throws java.io.IOException
Write the byte[] to the Blob value 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.

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

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