org.apache.derby.client.am
Class ClientBlob
- java.lang.Object
-
- org.apache.derby.client.am.Lob
-
- org.apache.derby.client.am.ClientBlob
-
- All Implemented Interfaces:
- java.sql.Blob, UnitOfWorkListener
public class ClientBlob extends Lob implements java.sql.Blob
-
-
Field Summary
-
Fields inherited from class org.apache.derby.client.am.Lob
INVALID_LOCATOR
-
-
Constructor Summary
Constructors Constructor and Description ClientBlob(Agent agent, int locator)Create aBlobobject for a Blob value stored on the server and indentified bylocator.ClientBlob(byte[] binaryString, Agent agent, int dataOffset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidfree()This method frees theBlobobject and releases the resources that it holds.java.io.InputStreamgetBinaryStream()java.io.InputStreamgetBinaryStream(long pos, long length)Returns anInputStreamobject that contains a partialBlobvalue, starting with the byte specified by pos, which is length bytes in length.byte[]getBytes(long pos, int length)Returns as an array of bytes part or all of theBLOBvalue that thisBlobobject designates.booleanisBinaryStream()booleanisBinaryString()longlength()longposition(java.sql.Blob pattern, long start)longposition(byte[] pattern, long start)java.io.OutputStreamsetBinaryStream(long pos)intsetBytes(long pos, byte[] bytes)intsetBytes(long pos, byte[] bytes, int offset, int len)voidtruncate(long len)-
Methods inherited from class org.apache.derby.client.am.Lob
completeLocalCommit, completeLocalRollback, getAgent, getLocator, isLocator, listenToUnitOfWork, willBeLayerBStreamed
-
-
-
-
Constructor Detail
-
ClientBlob
public ClientBlob(byte[] binaryString, Agent agent, int dataOffset)
-
ClientBlob
public ClientBlob(Agent agent, int locator)
Create aBlobobject for a Blob value stored on the server and indentified bylocator.- Parameters:
agent- context for this Blob object (incl. connection)locator- reference id to Blob value on server
-
-
Method Detail
-
length
public long length() throws java.sql.SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws java.sql.SQLExceptionReturns as an array of bytes part or all of theBLOBvalue that thisBlobobject designates. The byte array contains up tolengthconsecutive bytes starting at positionpos. 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.- Specified by:
getBytesin interfacejava.sql.Blob- Parameters:
pos- the ordinal position of the first byte in theBLOBvalue to be extracted; the first byte is at position 1length- is the number of consecutive bytes to be copied- Returns:
- a byte array containing up to
lengthconsecutive bytes from theBLOBvalue designated by thisBlobobject, starting with the byte at positionstartPos. - Throws:
java.sql.SQLException- if there is an error accessing theBLOBNOTE: If the starting position is the length of the BLOB plus 1, zero bytess are returned regardless of the length requested.
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException- Specified by:
getBinaryStreamin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
position
public long position(byte[] pattern, long start) throws java.sql.SQLException- Specified by:
positionin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
position
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException- Specified by:
positionin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long pos, byte[] bytes) throws java.sql.SQLException- Specified by:
setBytesin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
setBytes
public int setBytes(long pos, byte[] bytes, int offset, int len) throws java.sql.SQLException- Specified by:
setBytesin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
setBinaryStream
public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException- Specified by:
setBinaryStreamin interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
truncate
public void truncate(long len) throws java.sql.SQLException- Specified by:
truncatein interfacejava.sql.Blob- Throws:
java.sql.SQLException
-
free
public void free() throws java.sql.SQLExceptionThis method frees theBlobobject and releases the resources that it holds. The object is invalid once thefreemethod is called. Iffreeis called multiple times, the subsequent calls tofreeare treated as a no-op.- Specified by:
freein interfacejava.sql.Blob- Throws:
java.sql.SQLException- if an error occurs releasing the Blob's resources
-
getBinaryStream
public java.io.InputStream getBinaryStream(long pos, long length) throws java.sql.SQLExceptionReturns anInputStreamobject that contains a partialBlobvalue, starting with the byte specified by pos, which is length bytes in length.- Specified by:
getBinaryStreamin interfacejava.sql.Blob- Parameters:
pos- the offset to the first byte of the partial value to be retrieved. The first byte in theBlobis at position 1.length- the length in bytes of the partial value to be retrieved- Returns:
InputStreamthrough which the partialBlobvalue can be read.- Throws:
java.sql.SQLException- if pos is less than 1 or if pos is greater than the number of bytes in theBlobor ifpos + lengthis greater thanBlob.length() +1
-
isBinaryString
public boolean isBinaryString()
-
isBinaryStream
public boolean isBinaryStream()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG