Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.driver.Blob Class Reference

List of all members.

Public Member Functions

 Blob (byte[] data)
long length () throws SQLException
byte[] getBytes (long pos, int length) throws SQLException
java.io.InputStream getBinaryStream () throws SQLException
long position (byte pattern[], long start) throws SQLException
long position (java.sql.Blob pattern, long start) throws SQLException
int setBytes (long pos, byte[] bytes) throws SQLException
int setBytes (long pos, byte[] bytes, int offset, int len) throws SQLException
java.io.OutputStream setBinaryStream (long pos) throws SQLException
void truncate (long len) throws SQLException

Package Attributes

byte[] binaryData = null

Detailed Description

The representation (mapping) in the Java TM programming language of an SQL BLOB value. An SQL BLOB is a built-in type that stores a Binary Large Object as a column value in a row of a database table. By default drivers implement Blob using an SQL locator(BLOB), which means that a Blob object contains a logical pointer to the SQL BLOB data rather than the data itself. A Blob object is valid for the duration of the transaction in which is was created.

Methods in the interfaces DriverResultSet,CallableStatement, and PreparedStatement, such as getBlob and setBlob allow a programmer to access an SQL BLOB value. The Blob interface provides methods for getting the length of an SQL BLOB (Binary Large Object) value, for materializing a BLOB value on the client, and for determining the position of a pattern of bytes within a BLOB value. In addition, this interface has methods for updating a BLOB value.

Author:
Emmanuel Cecchet

Nicolas Modrzyk

Since:
JDK 1.2

Definition at line 57 of file Blob.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.driver.Blob.Blob byte[]  data  ) 
 

Creates a new Blob instance.

Parameters:
data an byte array

Definition at line 67 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.binaryData.

00068   {
00069     binaryData = data;
00070   }


Member Function Documentation

java.io.InputStream org.objectweb.cjdbc.driver.Blob.getBinaryStream  )  throws SQLException
 

Retrieves the BLOB value designated by this Blob instance as a stream.

Returns:
a stream containing the BLOB data
Exceptions:
SQLException if there is an error accessing the BLOB value
See also:
setBinaryStream
Since:
JDK 1.2

Definition at line 123 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.binaryData.

00124   {
00125     return new ByteArrayInputStream(binaryData);
00126   }

byte [] org.objectweb.cjdbc.driver.Blob.getBytes long  pos,
int  length
throws SQLException
 

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes. This byte array contains up to length consecutive bytes starting at position pos.

Parameters:
pos the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
length the number of consecutive bytes to be copied
Returns:
a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos
Exceptions:
SQLException if there is an error accessing the BLOB value
See also:
setBytes(long, byte[])
Since:
JDK 1.2

Definition at line 104 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.binaryData, and org.objectweb.cjdbc.driver.Blob.length().

00105   {
00106     byte[] newData = new byte[length];
00107 
00108     System.arraycopy(binaryData, (int) (pos - 1), newData, 0, length);
00109 
00110     return newData;
00111   }

long org.objectweb.cjdbc.driver.Blob.length  )  throws SQLException
 

Returns the number of bytes in the BLOB value designated by this Blob object.

Returns:
length of the BLOB in bytes
Exceptions:
SQLException if there is an error accessing the length of the BLOB
Since:
JDK 1.2

Definition at line 81 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.binaryData.

Referenced by org.objectweb.cjdbc.driver.Blob.getBytes().

00082   {
00083     return binaryData.length;
00084   }

long org.objectweb.cjdbc.driver.Blob.position java.sql.Blob  pattern,
long  start
throws SQLException
 

Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins. The search begins at position start.

Parameters:
pattern the Blob object designating the BLOB value for which to search
start the position in the BLOB value at which to begin searching; the first position is 1
Returns:
the position at which the pattern begins, else -1
Exceptions:
SQLException if there is an error accessing the BLOB value
Since:
JDK 1.2

Definition at line 161 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.position().

00162   {
00163     return position(pattern.getBytes(0, (int) pattern.length()), start);
00164   }

long org.objectweb.cjdbc.driver.Blob.position byte  pattern[],
long  start
throws SQLException
 

Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents. The search for pattern begins at position start.

Parameters:
pattern the byte array for which to search
start the position at which to begin searching; the first position is 1
Returns:
the position at which the pattern appears, else -1
Exceptions:
SQLException if there is an error accessing the BLOB
Since:
JDK 1.2

Definition at line 142 of file Blob.java.

References org.objectweb.cjdbc.driver.Blob.binaryData.

Referenced by org.objectweb.cjdbc.driver.Blob.position().

00143   {
00144     return (new String(binaryData)).indexOf(new String(pattern), (int) start);
00145   }

java.io.OutputStream org.objectweb.cjdbc.driver.Blob.setBinaryStream long  pos  )  throws SQLException
 

Retrieves a stream that can be used to write to the BLOB value that this Blob object represents. The stream begins at position pos.

Parameters:
pos the position in the BLOB value at which to start writing
Returns:
a java.io.OutputStream object to which data can be written
Exceptions:
SQLException if there is an error accessing the BLOB value
See also:
getBinaryStream
Since:
JDK 1.4

Definition at line 229 of file Blob.java.

00230   {
00231     throw new NotImplementedException("setBinaryStream");
00232   }

int org.objectweb.cjdbc.driver.Blob.setBytes long  pos,
byte[]  bytes,
int  offset,
int  len
throws SQLException
 

Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.

Parameters:
pos the position in the BLOB object at which to start writing
bytes the array of bytes to be written to this BLOB object
offset the offset into the array bytes at which to start reading the bytes to be set
len the number of bytes to be written to the BLOB value from the array of bytes bytes
Returns:
the number of bytes written
Exceptions:
SQLException if there is an error accessing the BLOB value
See also:
getBytes
Since:
JDK 1.4

Definition at line 209 of file Blob.java.

00211   {
00212     throw new NotImplementedException("setBytes");
00213   }

int org.objectweb.cjdbc.driver.Blob.setBytes long  pos,
byte[]  bytes
throws SQLException
 

Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written.

Parameters:
pos the position in the BLOB object at which to start writing
bytes the array of bytes to be written to the BLOB value that this Blob object represents
Returns:
the number of bytes written
Exceptions:
SQLException if there is an error accessing the BLOB value
See also:
getBytes
Since:
JDK 1.4

Definition at line 183 of file Blob.java.

00184   {
00185     throw new NotImplementedException("setBytes");
00186   }

void org.objectweb.cjdbc.driver.Blob.truncate long  len  )  throws SQLException
 

Truncates the BLOB value that this Blob object represents to be len bytes in length.

Parameters:
len the length, in bytes, to which the BLOB value that this Blob object represents should be truncated
Exceptions:
SQLException if there is an error accessing the BLOB value
Since:
JDK 1.4

Definition at line 245 of file Blob.java.

00246   {
00247     throw new NotImplementedException("truncate");
00248   }


Member Data Documentation

byte [] org.objectweb.cjdbc.driver.Blob.binaryData = null [package]
 

The binary data that makes up this BLOB.

Definition at line 60 of file Blob.java.

Referenced by org.objectweb.cjdbc.driver.Blob.Blob(), org.objectweb.cjdbc.driver.Blob.getBinaryStream(), org.objectweb.cjdbc.driver.Blob.getBytes(), org.objectweb.cjdbc.driver.Blob.length(), and org.objectweb.cjdbc.driver.Blob.position().


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:04:50 2005 for C-JDBC by  doxygen 1.3.9.1