Package org.postgresql.jdbc
Class AbstractBlobClob
- java.lang.Object
-
- org.postgresql.jdbc.AbstractBlobClob
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AbstractBlobClob.LOIterator
Iterates over a large object returning byte values.
-
Field Summary
Fields Modifier and Type Field Description protected BaseConnection
conn
private LargeObject
currentLo
private boolean
currentLoIsWriteable
private long
oid
private java.util.ArrayList<LargeObject>
subLOs
We create separate LargeObjects for methods that use streams so they won't interfere with each other.private boolean
support64bit
-
Constructor Summary
Constructors Constructor Description AbstractBlobClob(BaseConnection conn, long oid)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addSubLO(LargeObject subLO)
protected void
assertPosition(long pos)
Throws an exception if the pos value exceeds the max value by which the large object API can index.protected void
assertPosition(long pos, long len)
Throws an exception if the pos value exceeds the max value by which the large object API can index.protected void
checkFreed()
Checks that this LOB hasn't been free()d already.void
free()
java.io.InputStream
getBinaryStream()
byte[]
getBytes(long pos, int length)
protected LargeObject
getLo(boolean forWrite)
long
length()
long
position(byte[] pattern, long start)
Iterate over the buffer looking for the specified pattern.long
position(java.sql.Blob pattern, long start)
This is simply passing the byte value of the pattern Blob.java.io.OutputStream
setBinaryStream(long pos)
void
truncate(long len)
For Blobs this should be in bytes while for Clobs it should be in characters.
-
-
-
Field Detail
-
conn
protected BaseConnection conn
-
currentLo
private LargeObject currentLo
-
currentLoIsWriteable
private boolean currentLoIsWriteable
-
support64bit
private boolean support64bit
-
subLOs
private java.util.ArrayList<LargeObject> subLOs
We create separate LargeObjects for methods that use streams so they won't interfere with each other.
-
oid
private final long oid
-
-
Constructor Detail
-
AbstractBlobClob
public AbstractBlobClob(BaseConnection conn, long oid) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
free
public void free() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
truncate
public void truncate(long len) throws java.sql.SQLException
For 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:
java.sql.SQLException
- if operation fails
-
length
public long length() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes(long pos, int length) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setBinaryStream
public java.io.OutputStream setBinaryStream(long pos) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
position
public long position(byte[] pattern, long start) throws java.sql.SQLException
Iterate 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:
java.sql.SQLException
- if something wrong happens
-
position
public long position(java.sql.Blob pattern, long start) throws java.sql.SQLException
This is simply passing the byte value of the pattern Blob.- Parameters:
pattern
- search patternstart
- start position- Returns:
- position of given pattern
- Throws:
java.sql.SQLException
- if something goes wrong
-
assertPosition
protected void assertPosition(long pos) throws java.sql.SQLException
Throws 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:
java.sql.SQLException
- if something goes wrong
-
assertPosition
protected void assertPosition(long pos, long len) throws java.sql.SQLException
Throws 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:
java.sql.SQLException
- if something goes wrong
-
checkFreed
protected void checkFreed() throws java.sql.SQLException
Checks that this LOB hasn't been free()d already.- Throws:
java.sql.SQLException
- if LOB has been freed.
-
getLo
protected LargeObject getLo(boolean forWrite) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
addSubLO
protected void addSubLO(LargeObject subLO)
-
-