Top Description Inners Fields Constructors Methods
org.postgresql.jdbc

public abstract Class AbstractBlobClob

extends Object
Class Inheritance
Known Direct Subclasses
org.postgresql.jdbc.PgBlob, org.postgresql.jdbc.PgClob
Static Imports
org.postgresql.util.internal.Nullness.castNonNull

This class holds all of the methods common to both Blobs and Clobs.
Author
Michael Barker

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AbstractBlobClob.LOIterator

Iterates over a large object returning byte values.

Field Summary

Modifier and TypeField and Description
protected BaseConnection
private @Nullable LargeObject
private boolean
protected final ResourceLock
private final long
private @Nullable ArrayList<LargeObject>
subLOs

We create separate LargeObjects for methods that use streams so they won't interfere with each other.

private final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
assertPosition(long
Position to write at.
pos
)

Throws an exception if the pos value exceeds the max value by which the large object API can index.

protected void
assertPosition(long
Position to write at.
pos
,
long
number of bytes to write.
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.

public void
free()

public InputStream
public byte[]
getBytes(long pos, int length)

protected LargeObject
getLo(boolean forWrite)

public long
public long

Returns:

position of the specified pattern
position
(byte[]
A pattern of bytes to search the blob for
pattern
,
long
The position to start reading from
start
)

Iterate over the buffer looking for the specified pattern.

public long

Returns:

position of given pattern
position
(Blob
search pattern
pattern
,
long
start position
start
)

This is simply passing the byte value of the pattern Blob.

public OutputStream
setBinaryStream(long pos)

public void
truncate(long
maximum length
len
)

For Blobs this should be in bytes while for Clobs it should be in characters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connback to summary
protected BaseConnection conn
currentLoback to summary
private @Nullable LargeObject currentLo
currentLoIsWriteableback to summary
private boolean currentLoIsWriteable
lockback to summary
protected final ResourceLock lock
oidback to summary
private final long oid
subLOsback to summary
private @Nullable ArrayList<LargeObject> subLOs

We create separate LargeObjects for methods that use streams so they won't interfere with each other.

support64bitback to summary
private final boolean support64bit

Constructor Detail

AbstractBlobClobback to summary
public AbstractBlobClob(BaseConnection conn, long oid) throws SQLException

Method Detail

addSubLOback to summary
protected void addSubLO(LargeObject subLO)
assertPositionback to summary
protected void assertPosition(long pos) throws SQLException

Throws an exception if the pos value exceeds the max value by which the large object API can index.

Parameters
pos:long

Position to write at.

Exceptions
SQLException:
if something goes wrong
assertPositionback to summary
protected void assertPosition(long pos, long len) throws SQLException

Throws an exception if the pos value exceeds the max value by which the large object API can index.

Parameters
pos:long

Position to write at.

len:long

number of bytes to write.

Exceptions
SQLException:
if something goes wrong
checkFreedback to summary
protected void checkFreed() throws SQLException

Checks that this LOB hasn't been free()d already.

Exceptions
SQLException:
if LOB has been freed.
freeback to summary
public void free() throws SQLException
getBinaryStreamback to summary
public InputStream getBinaryStream() throws SQLException
getBytesback to summary
public byte[] getBytes(long pos, int length) throws SQLException
getLoback to summary
protected LargeObject getLo(boolean forWrite) throws SQLException
lengthback to summary
public long length() throws SQLException
positionback to summary
public long position(byte[] pattern, long start) throws SQLException

Iterate over the buffer looking for the specified pattern.

Parameters
pattern:byte[]

A pattern of bytes to search the blob for

start:long

The position to start reading from

Returns:long

position of the specified pattern

Exceptions
SQLException:
if something wrong happens
positionback to summary
public long position(Blob pattern, long start) throws SQLException

This is simply passing the byte value of the pattern Blob.

Parameters
pattern:Blob

search pattern

start:long

start position

Returns:long

position of given pattern

Exceptions
SQLException:
if something goes wrong
setBinaryStreamback to summary
public OutputStream setBinaryStream(long pos) throws SQLException
truncateback to summary
public void truncate(long len) throws 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:long

maximum length

Exceptions
SQLException:
if operation fails
org.postgresql.jdbc back to summary

private Class AbstractBlobClob.LOIterator

extends Object
Class Inheritance

Iterates over a large object returning byte values. Will buffer the data from the large object.

Field Summary

Modifier and TypeField and Description
private final byte[]
private static final int
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
LOIterator(long start)

Method Summary

Modifier and TypeMethod and Description
public boolean
private byte
next()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final byte[] buffer
BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
idxback to summary
private int idx
numBytesback to summary
private int numBytes

Constructor Detail

LOIteratorback to summary
pack-priv LOIterator(long start) throws SQLException

Method Detail

hasNextback to summary
public boolean hasNext() throws SQLException
nextback to summary
private byte next()