|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.client.am.Lob
org.apache.derby.client.am.Blob
public class Blob
Field Summary | |
---|---|
(package private) java.io.InputStream |
binaryStream_
|
(package private) byte[] |
binaryString_
|
(package private) int |
dataOffset_
|
Fields inherited from class org.apache.derby.client.am.Lob |
---|
agent_, ASCII_STREAM, BINARY_STREAM, BINARY_STRING, CHARACTER_STREAM, dataType_, INVALID_LOCATOR, isValid_, LOB_OBJECT_LENGTH_UNKNOWN_YET, LOCATOR, locator_, STRING, UNICODE_STREAM |
Constructor Summary | |
---|---|
Blob(Agent agent,
java.io.InputStream binaryStream)
Create a new Blob from a stream with unknown length. |
|
Blob(Agent agent,
java.io.InputStream binaryStream,
int length)
|
|
Blob(Agent agent,
int locator)
Create a Blob object for a Blob value stored
on the server and indentified by locator . |
|
Blob(byte[] binaryString,
Agent agent,
int dataOffset)
|
Method Summary | |
---|---|
protected long |
binaryStringPosition(byte[] pattern,
long start)
|
void |
free()
This method frees the Blob object and releases the resources that
it holds. |
java.io.InputStream |
getBinaryStream()
|
java.io.InputStream |
getBinaryStream(long pos,
long length)
Returns an InputStream object that contains a partial
Blob value, starting with the byte specified by pos,
which is length bytes in length. |
(package private) java.io.InputStream |
getBinaryStreamX()
|
byte[] |
getBinaryString()
|
byte[] |
getBytes(long pos,
int length)
Returns as an array of bytes part or all of the BLOB
value that this Blob object designates. |
private byte[] |
getBytesX(long pos,
int length)
|
(package private) long |
getLocatorLength()
Get the length in bytes of the Blob value represented by
this locator based |
boolean |
isBinaryStream()
|
boolean |
isBinaryString()
|
protected boolean |
isSubString(byte[] pattern,
int index)
|
long |
length()
|
protected void |
materializeStream()
Materialize the stream used for input to the database. |
long |
position(java.sql.Blob pattern,
long start)
|
long |
position(byte[] pattern,
long start)
|
private long |
positionX(java.sql.Blob pattern,
long start)
|
private long |
positionX(byte[] pattern,
long start)
|
java.io.OutputStream |
setBinaryStream(long pos)
|
int |
setBytes(long pos,
byte[] bytes)
|
int |
setBytes(long pos,
byte[] bytes,
int offset,
int len)
|
int |
setBytesX(long pos,
byte[] bytes,
int offset,
int len)
|
void |
truncate(long len)
|
Methods inherited from class org.apache.derby.client.am.Lob |
---|
checkForClosedConnection, checkForLocatorValidity, checkPosAndLength, checkValidity, completeLocalCommit, completeLocalCommit, completeLocalRollback, completeLocalRollback, finalize, getAgent, getLocator, getUpdateCount, incrementUpdateCount, isLayerBStreamingPossible, isLocator, listenToUnitOfWork, materializeStream, setSqlLength, sqlLength, willBeLayerBStreamed |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
byte[] binaryString_
java.io.InputStream binaryStream_
int dataOffset_
Constructor Detail |
---|
public Blob(byte[] binaryString, Agent agent, int dataOffset)
public Blob(Agent agent, java.io.InputStream binaryStream, int length)
public Blob(Agent agent, java.io.InputStream binaryStream)
Blob
from a stream with unknown length.
Important: This constructor is a temporary solution for
implementing lengthless overloads in the JDBC4 API. Before a proper
solution can be implemented, we need to enable streaming without having
to know the stream length in the DRDA protocol. See Jira DERBY-1471 and
DERBY-1417 for more details.
Shortcomings: This constructor will cause the whole stream
to be materialized to determine its length. If the stream is big
enough, the client will fail with an OutOfMemoryError. Since this is a
temporary solution, state checking is not added to all methods as it
would clutter up the class severely. After using the constructor, the
length
-method must be called, which will materialize the
stream and determine the length. Do not pass a Blob object created
with this constructor to the user!
agent
- binaryStream
- the stream to get data frompublic Blob(Agent agent, int locator)
Blob
object for a Blob value stored
on the server and indentified by locator
.
agent
- context for this Blob object (incl. connection)locator
- reference id to Blob value on serverMethod Detail |
---|
public long length() throws java.sql.SQLException
length
in interface java.sql.Blob
length
in class Lob
java.sql.SQLException
long getLocatorLength() throws SqlException
Blob
value represented by
this locator based
getLocatorLength
in class Lob
SqlException
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
BLOB
value that this Blob
object designates. The byte
array contains up to length
consecutive bytes
starting at position pos
.
The starting position must be between 1 and the length
of the BLOB plus 1. This allows for zero-length BLOB values, from
which only zero-length byte arrays can be returned.
If a larger length is requested than there are bytes available,
characters from the start position to the end of the BLOB are returned.
getBytes
in interface java.sql.Blob
pos
- the ordinal position of the first byte in the
BLOB
value to be extracted; the first byte is at
position 1length
- is the number of consecutive bytes to be copied
length
consecutive bytes from the BLOB
value designated
by this Blob
object, starting with the
byte at position startPos
.
java.sql.SQLException
- if there is an error accessing the
BLOB
NOTE: If the starting position is the length of the BLOB plus 1,
zero bytess are returned regardless of the length requested.private byte[] getBytesX(long pos, int length) throws SqlException
SqlException
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
getBinaryStream
in interface java.sql.Blob
java.sql.SQLException
java.io.InputStream getBinaryStreamX() throws SqlException
SqlException
public long position(byte[] pattern, long start) throws java.sql.SQLException
position
in interface java.sql.Blob
java.sql.SQLException
private long positionX(byte[] pattern, long start) throws SqlException
SqlException
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
position
in interface java.sql.Blob
java.sql.SQLException
private long positionX(java.sql.Blob pattern, long start) throws SqlException
SqlException
public int setBytes(long pos, byte[] bytes) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
java.sql.SQLException
public int setBytes(long pos, byte[] bytes, int offset, int len) throws java.sql.SQLException
setBytes
in interface java.sql.Blob
java.sql.SQLException
public int setBytesX(long pos, byte[] bytes, int offset, int len) throws SqlException
SqlException
public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
setBinaryStream
in interface java.sql.Blob
java.sql.SQLException
public void truncate(long len) throws java.sql.SQLException
truncate
in interface java.sql.Blob
java.sql.SQLException
public void free() throws java.sql.SQLException
Blob
object and releases the resources that
it holds. The object is invalid once the free
method is called. If free
is called multiple times, the subsequent
calls to free
are treated as a no-op.
free
in interface java.sql.Blob
java.sql.SQLException
- if an error occurs releasing
the Blob's resourcespublic java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLException
InputStream
object that contains a partial
Blob
value, starting with the byte specified by pos,
which is length bytes in length.
getBinaryStream
in interface java.sql.Blob
pos
- the offset to the first byte of the partial value to
be retrieved. The first byte in the Blob
is at position 1.length
- the length in bytes of the partial value to be retrieved
InputStream
through which the partial
Blob
value can be read.
java.sql.SQLException
- if pos is less than 1 or if pos is greater than
the number of bytes in the Blob
or if pos + length
is
greater than Blob.length() +1
public boolean isBinaryString()
public boolean isBinaryStream()
public byte[] getBinaryString()
protected long binaryStringPosition(byte[] pattern, long start)
protected boolean isSubString(byte[] pattern, int index)
protected void materializeStream() throws SqlException
materializeStream
in class Lob
SqlException
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |