Package org.teiid.core.types
Class BlobImpl
- java.lang.Object
-
- org.teiid.core.types.BaseLob
-
- org.teiid.core.types.BlobImpl
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Blob
,InputStreamFactory.StreamFactoryReference
,LobSearchUtil.StreamProvider
- Direct Known Subclasses:
BinaryWSProcedureExecution.StreamingBlob
public class BlobImpl extends BaseLob implements Blob, LobSearchUtil.StreamProvider
This object holds a chunk of binary data and implements the JDBC Blob interface. It presents a streaming interface and provides a way to access partial of the blob data. Connectors can use this object when dealing with large objects.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BlobImpl()
BlobImpl(InputStreamFactory streamFactory)
Creates a MMBlob object with thevalueID
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getBinaryStream(long arg0, long arg1)
byte[]
getBytes(long pos, int length)
Returns as an array of bytes, part or all of theBLOB
value that thisBlob
object designates.long
position(byte[] pattern, long start)
Determines the byte position at which the specified bytepattern
begins within theBLOB
value that thisBlob
object represents.long
position(Blob pattern, long start)
Determines the byte position in theBLOB
value designated by thisBlob
object at whichpattern
begins.static long
quickLength(Blob b)
For a given blob try to determine the length without fully reading an inputstreamOutputStream
setBinaryStream(long pos)
int
setBytes(long pos, byte[] bytes)
int
setBytes(long pos, byte[] bytes, int offset, int len)
void
truncate(long len)
-
Methods inherited from class org.teiid.core.types.BaseLob
free, getBinaryStream, getCharacterStream, getCharset, getStreamFactory, length, readExternal, setCharset, setEncoding, setStreamFactory, writeExternal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Blob
free, getBinaryStream, length
-
Methods inherited from interface org.teiid.core.types.LobSearchUtil.StreamProvider
getBinaryStream
-
-
-
-
Constructor Detail
-
BlobImpl
public BlobImpl()
-
BlobImpl
public BlobImpl(InputStreamFactory streamFactory)
Creates a MMBlob object with thevalueID
.- Parameters:
streamFactory
- reference to value chunk in data source.
-
-
Method Detail
-
getBytes
public byte[] getBytes(long pos, int length) throws SQLException
Returns as an array of bytes, part or all of theBLOB
value that thisBlob
object designates. The byte array contains up tolength
consecutive bytes starting at positionpos
.- Specified by:
getBytes
in interfaceBlob
- Parameters:
pos
- the ordinal position of the first byte in theBLOB
value to be extracted; the first byte is at position 1length
- the number of consecutive bytes to be copied- Returns:
- a byte array containing up to
length
consecutive bytes from theBLOB
value designated by thisBlob
object, starting with the byte at positionpos
- Throws:
SQLException
- if there is an error accessing theBLOB
-
position
public long position(Blob pattern, long start) throws SQLException
Determines the byte position in theBLOB
value designated by thisBlob
object at whichpattern
begins. The search begins at positionstart
.- Specified by:
position
in interfaceBlob
- Parameters:
pattern
- theBlob
object designating theBLOB
value for which to searchstart
- the position in theBLOB
value at which to begin searching; the first position is 1- Returns:
- the position at which the pattern begins, else -1
- Throws:
SQLException
- if there is an error accessing theBLOB
-
position
public long position(byte[] pattern, long start) throws SQLException
Determines the byte position at which the specified bytepattern
begins within theBLOB
value that thisBlob
object represents. The search forpattern
begins at positionstart
.- Specified by:
position
in interfaceBlob
- Parameters:
pattern
- the byte array for which to searchstart
- the position at which to begin searching; the first position is 1- Returns:
- the position at which the pattern appears, else -1
- Throws:
SQLException
- if there is an error accessing theBLOB
-
getBinaryStream
public InputStream getBinaryStream(long arg0, long arg1) throws SQLException
- Specified by:
getBinaryStream
in interfaceBlob
- Throws:
SQLException
-
setBytes
public int setBytes(long pos, byte[] bytes) throws SQLException
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
- See Also:
Blob.setBytes(long, byte[])
-
setBytes
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
- Specified by:
setBytes
in interfaceBlob
- Throws:
SQLException
- See Also:
Blob.setBytes(long, byte[], int, int)
-
setBinaryStream
public OutputStream setBinaryStream(long pos) throws SQLException
- Specified by:
setBinaryStream
in interfaceBlob
- Throws:
SQLException
- See Also:
Blob.setBinaryStream(long)
-
truncate
public void truncate(long len) throws SQLException
- Specified by:
truncate
in interfaceBlob
- Throws:
SQLException
- See Also:
Blob.truncate(long)
-
quickLength
public static long quickLength(Blob b)
For a given blob try to determine the length without fully reading an inputstream- Returns:
- the length or -1 if it cannot be determined
-
-