Package org.firebirdsql.jdbc
Interface FirebirdBlob.BlobInputStream
- All Known Implementing Classes:
FBBlobInputStream
- Enclosing interface:
- FirebirdBlob
public static interface FirebirdBlob.BlobInputStream
Blob input stream. This interface defines methods to access contents
of the Blob field. Some method signatures are copied from the
InputStream only because it is abstract class and not interface
that we can extend.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSeek based on the absolute beginning of the streamstatic final intSeek relative to the tail end of the streamstatic final intSeek relative to the current position in the stream -
Method Summary
Modifier and TypeMethodDescriptionintGet number of available bytes that can be read without blocking.voidclose()Close this stream.getBlob()Get instance ofFirebirdBlobto which this stream belongs to.longlength()Get Blob length.intread()Read single byte from the stream.intread(byte[] buffer, int offset, int length) Read some bytes from the stream without blocking.voidreadFully(byte[] buffer) Readbuffer.lengthbytes from the buffer.voidreadFully(byte[] buffer, int offset, int length) Readlengthfrom the stream into the specified buffer.voidseek(int position) Move current position in the Blob stream.voidseek(int position, int seekMode) Move current position in the Blob stream.
-
Field Details
-
SEEK_MODE_ABSOLUTE
static final int SEEK_MODE_ABSOLUTESeek based on the absolute beginning of the stream- See Also:
-
SEEK_MODE_RELATIVE
static final int SEEK_MODE_RELATIVESeek relative to the current position in the stream- See Also:
-
SEEK_MODE_FROM_TAIL
static final int SEEK_MODE_FROM_TAILSeek relative to the tail end of the stream- See Also:
-
-
Method Details
-
getBlob
FirebirdBlob getBlob()Get instance ofFirebirdBlobto which this stream belongs to.Note, code
FirebirdBlob.BlobInputStream otherStream = (FirebirdBlob.BlobInputStream) inputStream.getBlob().getBinaryStream();will return new stream object.- Returns:
- instance of
FirebirdBlob.
-
available
Get number of available bytes that can be read without blocking. This method will return number of bytes of the last read blob segment in the blob buffer.- Returns:
- number of bytes available without blocking or -1 if end of stream is reached.
- Throws:
IOException- if I/O error occured.
-
close
Close this stream.- Throws:
IOException- if I/O error occurs.
-
length
Get Blob length. This is shortcut method for theinputStream.getBlob().length()call, however is more resource friendly, because no new Blob handle is created.- Returns:
- length of the blob.
- Throws:
IOException- if I/O error occurs.
-
read
Read single byte from the stream.- Returns:
- next byte read from the stream or -1 if end of stream was reached.
- Throws:
IOException- if I/O error occurs.
-
read
Read some bytes from the stream without blocking.- Parameters:
buffer- buffer into which data should be read.offset- offset in the buffer where to start.length- number of bytes to read.- Returns:
- number of bytes that were read.
- Throws:
IOException- if I/O error occurs.
-
readFully
Readlengthfrom the stream into the specified buffer. This method can block until desired number of bytes is read, it can throw an exception if end of stream was reached during read.- Parameters:
buffer- buffer where data should be read.offset- offset in the buffer where to start.length- number of bytes to read.- Throws:
EOFException- if stream end was reached when reading data.IOException- if I/O error occurs.
-
readFully
Readbuffer.lengthbytes from the buffer. This is a shortcut method forreadFully(buffer, 0, buffer.length)call.- Parameters:
buffer- buffer where data should be read.- Throws:
IOException- if I/O error occurs.
-
seek
Move current position in the Blob stream. This is a shortcut method toseek(int, int)passingSEEK_MODE_ABSOLUTEas seek mode.- Parameters:
position- absolute position to seek, starting position is 0 (note, inBlob.getBytes(long, int)starting position is 1).- Throws:
IOException- if I/O error occurs.
-
seek
Move current position in the Blob stream. Depending on the specified seek mode, position can be either positive or negative.Note, this method allows to move position in the Blob stream only forward. If you need to read data before the current position, new stream must be opened.
- Parameters:
position- position in the stream, starting position is 0 (note, inBlob.getBytes(long, int)starting position is 1).seekMode- mode of seek operation, one ofSEEK_MODE_ABSOLUTE,SEEK_MODE_RELATIVEorSEEK_MODE_FROM_TAIL.- Throws:
IOException- if I/O erro occurs.
-