Top Description Fields Constructors Methods
org.apache.derby.iapi.types

public final Class CharStreamHeaderGenerator

extends Object
implements StreamHeaderGenerator
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.types.StreamHeaderGenerator
Imports
java.io.IOException, .ObjectOutput

Generates stream headers for non-Clob string data types.

The stream header encodes the byte length of the stream. Since two bytes are used for the header, the maximum encodable length is 65535 bytes. There are three special cases, all handled by encoding zero into the header and possibly appending an EOF-marker to the stream:

The length is encoded like this:
           out.writeByte((byte)(byteLength >>> 8));
           out.writeByte((byte)(byteLength >>> 0));

Field Summary

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

The Derby-specific end-of-stream marker.

private static final int
MAX_ENCODABLE_LENGTH

The maximum length that can be encoded by the header.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

false.
expectsCharCount
()

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.expectsCharCount.

A byte count is expected.

public int

Returns:

The number of bytes written into the buffer.
generateInto
(byte[]
the buffer to write into
buffer
,
int
starting offset in the buffer
offset
,
long
the length to encode in the header
byteLength
)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.generateInto.

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.
generateInto
(ObjectOutput
the destination stream
out
,
long
the byte length to encode in the header
byteLength
)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.generateInto.

Generates the header for the specified length.

public int

Returns:

Maximum header length in bytes.
getMaxHeaderLength
()

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.getMaxHeaderLength.

Returns the maximum header length.

public int

Returns:

Number of bytes written (zero or more).
writeEOF
(byte[]
the buffer to write into
buffer
,
int
starting offset in the buffer
offset
,
long
the byte length of the stream
byteLength
)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.writeEOF.

Writes a Derby-specific end-of-stream marker to the buffer for a stream of the specified byte length, if required.

public int

Returns:

Number of bytes written (zero or more).
writeEOF
(ObjectOutput
the destination stream
out
,
long
the length of the stream
byteLength
)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.writeEOF.

Writes a Derby-specific end-of-stream marker to the destination stream for the specified byte length, if required.

public static int
writeEOFMarker(byte[] buffer, int offset)

Write the EOF marker to a byte array and return the EOF marker's length

public static int
writeEOFMarker(ObjectOutput out)

Write the EOF marker to an Object stream and return the EOF marker's length

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DERBY_EOF_MARKERback to summary
private static final byte[] DERBY_EOF_MARKER

The Derby-specific end-of-stream marker.

MAX_ENCODABLE_LENGTHback to summary
private static final int MAX_ENCODABLE_LENGTH

The maximum length that can be encoded by the header.

Constructor Detail

CharStreamHeaderGeneratorback to summary
public CharStreamHeaderGenerator()

Method Detail

expectsCharCountback to summary
public boolean expectsCharCount()

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.expectsCharCount.

A byte count is expected.

Returns:boolean

false.

generateIntoback to summary
public int generateInto(byte[] buffer, int offset, long byteLength)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.generateInto.

Generates the header for the specified length and writes it into the provided buffer, starting at the specified offset.

Parameters
buffer:byte[]

the buffer to write into

offset:int

starting offset in the buffer

byteLength:long

the length to encode in the header

Returns:int

The number of bytes written into the buffer.

generateIntoback to summary
public int generateInto(ObjectOutput out, long byteLength) throws IOException

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.generateInto.

Generates the header for the specified length.

Parameters
out:ObjectOutput

the destination stream

byteLength:long

the byte length to encode in the header

Returns:int

The number of bytes written to the destination stream.

Exceptions
IOException:
if writing to the destination stream fails
getMaxHeaderLengthback to summary
public int getMaxHeaderLength()

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.getMaxHeaderLength.

Returns the maximum header length.

Returns:int

Maximum header length in bytes.

writeEOFback to summary
public int writeEOF(byte[] buffer, int offset, long byteLength)

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.writeEOF.

Writes a Derby-specific end-of-stream marker to the buffer for a stream of the specified byte length, if required.

Parameters
buffer:byte[]

the buffer to write into

offset:int

starting offset in the buffer

byteLength:long

the byte length of the stream

Returns:int

Number of bytes written (zero or more).

writeEOFback to summary
public int writeEOF(ObjectOutput out, long byteLength) throws IOException

Implements org.apache.derby.iapi.types.StreamHeaderGenerator.writeEOF.

Writes a Derby-specific end-of-stream marker to the destination stream for the specified byte length, if required.

Parameters
out:ObjectOutput

the destination stream

byteLength:long

the length of the stream

Returns:int

Number of bytes written (zero or more).

Exceptions
IOException:

Doc from org.apache.derby.iapi.types.StreamHeaderGenerator.writeEOF.

if writing to the destination stream fails

writeEOFMarkerback to summary
public static int writeEOFMarker(byte[] buffer, int offset)

Write the EOF marker to a byte array and return the EOF marker's length

writeEOFMarkerback to summary
public static int writeEOFMarker(ObjectOutput out) throws IOException

Write the EOF marker to an Object stream and return the EOF marker's length