| java.lang.Object org.postgresql.largeobject.LargeObject
LargeObject | public class LargeObject (Code) | | This class provides the basic methods required to run the interface, plus
a pair of methods that provide InputStream and OutputStream classes
for this object.
Normally, client code would use the getAsciiStream, getBinaryStream,
or getUnicodeStream methods in ResultSet, or setAsciiStream,
setBinaryStream, or setUnicodeStream methods in PreparedStatement to
access Large Objects.
However, sometimes lower level access to Large Objects are required,
that are not supported by the JDBC specification.
Refer to org.postgresql.largeobject.LargeObjectManager on how to gain access
to a Large Object, or how to create one.
See Also: org.postgresql.largeobject.LargeObjectManager See Also: java.sql.ResultSet.getAsciiStream See Also: java.sql.ResultSet.getBinaryStream See Also: java.sql.ResultSet.getUnicodeStream See Also: java.sql.PreparedStatement.setAsciiStream See Also: java.sql.PreparedStatement.setBinaryStream See Also: java.sql.PreparedStatement.setUnicodeStream |
Constructor Summary | |
protected | LargeObject(Fastpath fp, long oid, int mode) This opens a large object. |
Method Summary | |
public void | close() This method closes the object. | public LargeObject | copy() | public InputStream | getInputStream() Returns an InputStream from this object. | public long | getLongOID() | public int | getOID() | public OutputStream | getOutputStream() Returns an OutputStream to this object. | public byte[] | read(int len) | public int | read(byte buf, int off, int len) | public void | seek(int pos, int ref) Sets the current position within the object.
This is similar to the fseek() call in the standard C library. | public void | seek(int pos) Sets the current position within the object.
This is similar to the fseek() call in the standard C library. | public int | size() This method is inefficient, as the only way to find out the size of
the object is to seek to the end, record the current position, then
return to the original position. | public int | tell() | public void | truncate(int len) Truncates the large object to the given length in bytes.
If the number of bytes is larger than the current large
object length, the large object will be filled with zero
bytes. | public void | write(byte buf) | public void | write(byte buf, int off, int len) |
SEEK_CUR | final public static int SEEK_CUR(Code) | | Indicates a seek from the current position
|
SEEK_END | final public static int SEEK_END(Code) | | Indicates a seek from the end of a file
|
SEEK_SET | final public static int SEEK_SET(Code) | | Indicates a seek from the begining of a file
|
LargeObject | protected LargeObject(Fastpath fp, long oid, int mode) throws SQLException(Code) | | This opens a large object.
If the object does not exist, then an SQLException is thrown.
Parameters: fp - FastPath API for the connection to use Parameters: oid - of the Large Object to open Parameters: mode - Mode of opening the large object(defined in LargeObjectManager) exception: SQLException - if a database-access error occurs. See Also: org.postgresql.largeobject.LargeObjectManager |
close | public void close() throws SQLException(Code) | | This method closes the object. You must not call methods in this
object after this is called.
exception: SQLException - if a database-access error occurs. |
getInputStream | public InputStream getInputStream() throws SQLException(Code) | | Returns an InputStream from this object.
This InputStream can then be used in any method that requires an
InputStream.
exception: SQLException - if a database-access error occurs. |
getLongOID | public long getLongOID()(Code) | | the OID of this LargeObject |
getOutputStream | public OutputStream getOutputStream() throws SQLException(Code) | | Returns an OutputStream to this object.
This OutputStream can then be used in any method that requires an
OutputStream.
exception: SQLException - if a database-access error occurs. |
read | public byte[] read(int len) throws SQLException(Code) | | Reads some data from the object, and return as a byte[] array
Parameters: len - number of bytes to read byte[] array containing data read exception: SQLException - if a database-access error occurs. |
read | public int read(byte buf, int off, int len) throws SQLException(Code) | | Reads some data from the object into an existing array
Parameters: buf - destination array Parameters: off - offset within array Parameters: len - number of bytes to read the number of bytes actually read exception: SQLException - if a database-access error occurs. |
seek | public void seek(int pos, int ref) throws SQLException(Code) | | Sets the current position within the object.
This is similar to the fseek() call in the standard C library. It
allows you to have random access to the large object.
Parameters: pos - position within object Parameters: ref - Either SEEK_SET, SEEK_CUR or SEEK_END exception: SQLException - if a database-access error occurs. |
seek | public void seek(int pos) throws SQLException(Code) | | Sets the current position within the object.
This is similar to the fseek() call in the standard C library. It
allows you to have random access to the large object.
Parameters: pos - position within object from begining exception: SQLException - if a database-access error occurs. |
size | public int size() throws SQLException(Code) | | This method is inefficient, as the only way to find out the size of
the object is to seek to the end, record the current position, then
return to the original position.
A better method will be found in the future.
the size of the large object exception: SQLException - if a database-access error occurs. |
truncate | public void truncate(int len) throws SQLException(Code) | | Truncates the large object to the given length in bytes.
If the number of bytes is larger than the current large
object length, the large object will be filled with zero
bytes. This method does not modify the current file offset.
|
write | public void write(byte buf) throws SQLException(Code) | | Writes an array to the object
Parameters: buf - array to write exception: SQLException - if a database-access error occurs. |
write | public void write(byte buf, int off, int len) throws SQLException(Code) | | Writes some data from an array to the object
Parameters: buf - destination array Parameters: off - offset within array Parameters: len - number of bytes to write exception: SQLException - if a database-access error occurs. |
|
|