Package org.apache.derby.iapi.jdbc
Class CharacterStreamDescriptor
java.lang.Object
org.apache.derby.iapi.jdbc.CharacterStreamDescriptor
A description of a byte stream representing characters. The description is
used by decoders to properly configure themselves. Note that encoding is not
included in the description, because all internal byte streams are expected
to be using the modified UTF-8 encoding (see DataInput).
The information in the description is only guaranteed to be valid at the moment it is passed to the decoder object. As the decoder works on the stream, the information in the descriptor will be outdated.
To create a stream descriptor, obtain a Builder
instance and set the
required parameters.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The builder for theCharacterStreamDescriptor
class. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Constant for the character position, when it is positioned before the first character in the stream (i.e. at the very beginning of the stream or in the header).private final boolean
Tells if the stream can be buffered or not.private final long
The byte length of the stream,0
if unknown.private final long
The character length of the stream,0
if unknown.private final long
The current byte position.private final long
The current character position.private final long
First data byte in the byte stream.private final long
The maximum allowed character length.private final boolean
Tells if the stream is aware of its own position.private final InputStream
Reference to the stream we are describing. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Creates a character stream descriptor, using the supplied builder. -
Method Summary
Modifier and TypeMethodDescriptionlong
long
long
long
Returns the current character position.long
Returns the first index of the described stream that contains real data.long
Returns the imposed maximum character length on the described stream.Returns the associated positioned stream, if the stream is position aware.Returns the associated stream.boolean
Tells if the described stream should be buffered or not.boolean
Tells if the described stream is aware of its own position, and that it can reposition itself on request.toString()
-
Field Details
-
BEFORE_FIRST
public static final long BEFORE_FIRSTConstant for the character position, when it is positioned before the first character in the stream (i.e. at the very beginning of the stream or in the header).- See Also:
-
dataOffset
private final long dataOffsetFirst data byte in the byte stream. -
curBytePos
private final long curBytePosThe current byte position. -
curCharPos
private final long curCharPosThe current character position. -
byteLength
private final long byteLengthThe byte length of the stream,0
if unknown. -
charLength
private final long charLengthThe character length of the stream,0
if unknown. -
maxCharLength
private final long maxCharLengthThe maximum allowed character length. -
bufferable
private final boolean bufferableTells if the stream can be buffered or not. -
positionAware
private final boolean positionAwareTells if the stream is aware of its own position. -
stream
Reference to the stream we are describing.
-
-
Constructor Details
-
CharacterStreamDescriptor
Creates a character stream descriptor, using the supplied builder.Use the builder to create instances of this class.
- Parameters:
b
- object builder- See Also:
-
-
Method Details
-
isBufferable
public boolean isBufferable()Tells if the described stream should be buffered or not.Some of the reasons a stream should not be buffered at this level, are the stream is already buffered, or it serves bytes directly from a byte array in memory.
- Returns:
true
if the stream should be buffered for improved performance,false
if it should not be buffered.
-
isPositionAware
public boolean isPositionAware()Tells if the described stream is aware of its own position, and that it can reposition itself on request.- Returns:
true
if the stream is position aware, @{code false} otherwise.
-
getByteLength
public long getByteLength() -
getCharLength
public long getCharLength() -
getCurBytePos
public long getCurBytePos() -
getCurCharPos
public long getCurCharPos()Returns the current character position.- Returns:
- The current character position, where the first character is at
position
1
, orBEFORE_FIRST
if the stream is positioned before the first character.
-
getDataOffset
public long getDataOffset()Returns the first index of the described stream that contains real data.The information is typically used to filter out meta data at the head of the stream, and to correctly reset the stream.
- Returns:
- The first position in the stream containing real data.
-
getMaxCharLength
public long getMaxCharLength()Returns the imposed maximum character length on the described stream.The default value is
Long.MAX_VALUE
.- Returns:
- The max allowed character length of the stream, or
0
if no limit has been set.
-
getStream
Returns the associated stream.- Returns:
- An
InputStream
reference.
-
getPositionedStream
Returns the associated positioned stream, if the stream is position aware.- Returns:
- A
PositionedStream
reference. - Throws:
ClassCastException
- if the stream cannot be cast toPositionedStream
IllegalArgumentException
- if the method is called and the assoicated stream isn't described as position aware.- See Also:
-
toString
-