Package org.postgresql.jdbc
Class AbstractBlobClob
- java.lang.Object
-
- org.postgresql.jdbc.AbstractBlobClob
-
public abstract class AbstractBlobClob extends Object
This class holds all of the methods common to both Blobs and Clobs.- Author:
- Michael Barker
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseConnectionconn
-
Constructor Summary
Constructors Constructor Description AbstractBlobClob(BaseConnection conn, long oid)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddSubLO(LargeObject subLO)protected voidassertPosition(long pos)Throws an exception if the pos value exceeds the max value by which the large object API can index.protected voidassertPosition(long pos, long len)Throws an exception if the pos value exceeds the max value by which the large object API can index.protected voidcheckFreed()Checks that this LOB hasn't been free()d already.voidfree()InputStreamgetBinaryStream()byte[]getBytes(long pos, int length)protected LargeObjectgetLo(boolean forWrite)longlength()longposition(byte[] pattern, long start)Iterate over the buffer looking for the specified pattern.longposition(Blob pattern, long start)This is simply passing the byte value of the pattern Blob.OutputStreamsetBinaryStream(long pos)voidtruncate(long len)For Blobs this should be in bytes while for Clobs it should be in characters.
-
-
-
Field Detail
-
conn
protected BaseConnection conn
-
-
Constructor Detail
-
AbstractBlobClob
public AbstractBlobClob(BaseConnection conn, long oid) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
free
public void free() throws SQLException- Throws:
SQLException
-
truncate
public void truncate(long len) throws SQLExceptionFor Blobs this should be in bytes while for Clobs it should be in characters. Since we really haven't figured out how to handle character sets for Clobs the current implementation uses bytes for both Blobs and Clobs.- Parameters:
len- maximum length- Throws:
SQLException- if operation fails
-
length
public long length() throws SQLException- Throws:
SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws SQLException- Throws:
SQLException
-
getBinaryStream
public InputStream getBinaryStream() throws SQLException
- Throws:
SQLException
-
setBinaryStream
public OutputStream setBinaryStream(long pos) throws SQLException
- Throws:
SQLException
-
position
public long position(byte[] pattern, long start) throws SQLExceptionIterate over the buffer looking for the specified pattern.- Parameters:
pattern- A pattern of bytes to search the blob forstart- The position to start reading from- Returns:
- position of the specified pattern
- Throws:
SQLException- if something wrong happens
-
position
public long position(Blob pattern, long start) throws SQLException
This is simply passing the byte value of the pattern Blob.- Parameters:
pattern- search patternstart- start position- Returns:
- position of given pattern
- Throws:
SQLException- if something goes wrong
-
assertPosition
protected void assertPosition(long pos) throws SQLExceptionThrows an exception if the pos value exceeds the max value by which the large object API can index.- Parameters:
pos- Position to write at.- Throws:
SQLException- if something goes wrong
-
assertPosition
protected void assertPosition(long pos, long len) throws SQLExceptionThrows an exception if the pos value exceeds the max value by which the large object API can index.- Parameters:
pos- Position to write at.len- number of bytes to write.- Throws:
SQLException- if something goes wrong
-
checkFreed
protected void checkFreed() throws SQLExceptionChecks that this LOB hasn't been free()d already.- Throws:
SQLException- if LOB has been freed.
-
getLo
protected LargeObject getLo(boolean forWrite) throws SQLException
- Throws:
SQLException
-
addSubLO
protected void addSubLO(LargeObject subLO)
-
-