THREAD SAFETY NOTE: This class is considered thread safe, even though it strictly speaking isn't. However, with the assumption that an instance of this class cannot be shared across databases with different versions, the only bad thing that can happen is that the mode is obtained several times.
| Modifier and Type | Field and Description |
|---|---|
| private final StringDataValue | callbackDVD
Reference to "owning" DVD, used to update it with information about which header format should be used. |
| private static final CharStreamHeaderGenerator | CHARHDRGEN
Header generator for the pre 10.5 header format. |
| private Boolean | isPreDerbyTenFive
|
| private static final byte | MAGIC_BYTE
Magic byte for the 10.5 stream header format. |
| private static final byte[] | UNKNOWN_LENGTH
Bytes for a 10.5 unknown length header. |
| Access | Constructor and Description |
|---|---|
| public | ClobStreamHeaderGenerator(StringDataValue
the owning data value descriptor dvd)Creates a new generator that will use the context manager to determine which header format to use based on the database version. |
| public | ClobStreamHeaderGenerator(boolean
true if the database version is prior
to 10.5, false if the version is 10.5 or newerCreates a new generator using the specified header format. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | Returns: false if a byte count is expected (prior to 10.5),
true if a character count is expected (10.5 and newer).Implements org. Tells if the header encodes a character or byte count. |
| public int | Returns: The number of bytes written into the buffer.the buffer to write into buf, int starting offset in the buffer offset, long the length to encode in the header valueLength)Implements org. Generates the header for the specified length and writes it into the provided buffer, starting at the specified offset. |
| public int | Returns: The number of bytes written to the destination stream.the destination stream out, long the length to encode in the header valueLength)Implements org. Generates the header for the specified length. |
| private static Context | |
| public int | Returns: Maximum header length in bytes.Implements org. Returns the maximum header length. |
| public int | Returns: Number of bytes written (zero or more).the buffer to write into buffer, int starting offset in the buffer offset, long the length of the stream valueLength)Implements org. Writes a Derby-specific end-of-stream marker to the buffer for a stream of the specified character length, if required. |
| public int | Returns: Number of bytes written (zero or more).the destination stream out, long the length of the stream valueLength)Implements org. Writes a Derby-specific end-of-stream marker to the destination stream for the specified character length, if required. |
| callbackDVD | back to summary |
|---|---|
| private final StringDataValue callbackDVD Reference to "owning" DVD, used to update it with information about which header format should be used. This is currently only determined by consulting the data dictionary about the version. This is an optimization to avoid having to consult the data dictionary on every request to generate a header when a data value descriptor is reused. | |
| CHARHDRGEN | back to summary |
|---|---|
| private static final CharStreamHeaderGenerator CHARHDRGEN Header generator for the pre 10.5 header format. This format is used for Clobs as well if the database version is pre 10.5. | |
| isPreDerbyTenFive | back to summary |
|---|---|
| private Boolean isPreDerbyTenFive
| |
| MAGIC_BYTE | back to summary |
|---|---|
| private static final byte MAGIC_BYTE Magic byte for the 10.5 stream header format. | |
| UNKNOWN_LENGTH | back to summary |
|---|---|
| private static final byte[] UNKNOWN_LENGTH Bytes for a 10.5 unknown length header. | |
| ClobStreamHeaderGenerator | back to summary |
|---|---|
| public ClobStreamHeaderGenerator(StringDataValue dvd) Creates a new generator that will use the context manager to determine which header format to use based on the database version.
| |
| ClobStreamHeaderGenerator | back to summary |
|---|---|
| public ClobStreamHeaderGenerator(boolean isPreDerbyTenFive) Creates a new generator using the specified header format.
| |
| determineHeaderFormat | back to summary |
|---|---|
| private void determineHeaderFormat() Determines which header format to use. Implementation Note The header format is determined by consulting the data dictionary throught the context service. If there is no context, the operation will fail.
| |
| expectsCharCount | back to summary |
|---|---|
| public boolean expectsCharCount() Implements org. Tells if the header encodes a character or byte count. Currently the header expects a character count if the header format is 10.5 (or newer), and a byte count if we are accessing a database created by a version prior to 10.5.
| |
| generateInto | back to summary |
|---|---|
| public int generateInto(byte[] buf, int offset, long valueLength) Implements org. Generates the header for the specified length and writes it into the provided buffer, starting at the specified offset.
| |
| generateInto | back to summary |
|---|---|
| public int generateInto(ObjectOutput out, long valueLength) throws IOException Implements org. Generates the header for the specified length.
| |
| getContext | back to summary |
|---|---|
| private static Context getContext(final String contextID) Must be private so that user code can't call this entry point. | |
| getMaxHeaderLength | back to summary |
|---|---|
| public int getMaxHeaderLength() Implements org. Returns the maximum header length.
| |
| writeEOF | back to summary |
|---|---|
| public int writeEOF(byte[] buffer, int offset, long valueLength) Implements org. Writes a Derby-specific end-of-stream marker to the buffer for a stream of the specified character length, if required.
| |
| writeEOF | back to summary |
|---|---|
| public int writeEOF(ObjectOutput out, long valueLength) throws IOException Implements org. Writes a Derby-specific end-of-stream marker to the destination stream for the specified character length, if required.
| |