public final class RawToBinaryFormatStream extends LimitInputStream
If the length of the stream is known then it is encoded
as the first bytes in the stream in the defined format.
If the length is unknown then the first four bytes will
be zero, indicating unknown length.
Note: This stream cannot be re-used. Once end of file is
reached, the next read call will throw an EOFException
SQLBinary
Modifier and Type | Field and Description |
---|---|
private byte[] |
encodedLength
Encoding of the length in bytes which will be
seen as the first encodedLength.length bytes of
this stream.
|
private int |
encodedOffset
Number of bytes of length encoding.
|
private boolean |
eof |
private int |
length
The length of the stream.
|
private int |
maximumLength
The maximum allowed length for the stream.
|
private java.lang.String |
typeName
The type of the column the stream is inserted into.
|
limitInPlace, remainingBytes
Constructor and Description |
---|
RawToBinaryFormatStream(java.io.InputStream in,
int length)
Create a binary on-disk stream from the given
InputStream . |
RawToBinaryFormatStream(java.io.InputStream in,
int maximumLength,
java.lang.String typeName)
Create a binary on-disk stream from the given
InputStream
of unknown length. |
Modifier and Type | Method and Description |
---|---|
private void |
checkSufficientData()
JDBC 3.0 (from tutorial book) requires that an
input stream has the correct number of bytes in
the stream.
|
int |
read()
Read from the wrapped stream prepending the intial bytes if needed.
|
int |
read(byte[] b,
int off,
int len)
Read from the wrapped stream prepending the intial bytes if needed.
|
available, clearLimit, markSupported, setInput, setLimit, skip
private int encodedOffset
private byte[] encodedLength
private boolean eof
private final int length
private final int maximumLength
private final java.lang.String typeName
null
if not in use.public RawToBinaryFormatStream(java.io.InputStream in, int length)
InputStream
.
The on-disk stream prepends a length encoding, and validates that the
actual length of the stream matches the specified length (as according
to JDBC 3.0).in
- application's raw binary stream passed into JDBC layerlength
- length of the streamjava.lang.IllegalArgumentException
- if length
is negative.
This exception should never be exposed to the user, and seeing it
means a programming error exists in the code.public RawToBinaryFormatStream(java.io.InputStream in, int maximumLength, java.lang.String typeName)
InputStream
of unknown length.
A limit is placed on the maximum length of the stream.in
- the application streammaximumLength
- maximum length of the column data is inserted intotypeName
- type name for the column data is inserted intojava.lang.IllegalArgumentException
- if maximum length is negative, or type
name is null. This exception should never be exposed
to the user, and seeing it means a programming error exists in the
code. Although a missing type name is not critical, an exception is
is thrown to signal the intended use of this constructor.
public int read() throws java.io.IOException
read
in class LimitInputStream
java.io.IOException
private void checkSufficientData() throws java.io.IOException
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class LimitInputStream
java.io.IOException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.