Package org.apache.derby.iapi.jdbc
Class CharacterStreamDescriptor
- java.lang.Object
-
- org.apache.derby.iapi.jdbc.CharacterStreamDescriptor
-
public class CharacterStreamDescriptor extends java.lang.ObjectA 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
Builderinstance and set the required parameters.- See Also:
CharacterStreamDescriptor.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCharacterStreamDescriptor.BuilderThe builder for theCharacterStreamDescriptorclass.
-
Field Summary
Fields Modifier and Type Field Description static longBEFORE_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).private booleanbufferableTells if the stream can be buffered or not.private longbyteLengthThe byte length of the stream,0if unknown.private longcharLengthThe character length of the stream,0if unknown.private longcurBytePosThe current byte position.private longcurCharPosThe current character position.private longdataOffsetFirst data byte in the byte stream.private longmaxCharLengthThe maximum allowed character length.private booleanpositionAwareTells if the stream is aware of its own position.private java.io.InputStreamstreamReference to the stream we are describing.
-
Constructor Summary
Constructors Modifier Constructor Description privateCharacterStreamDescriptor(CharacterStreamDescriptor.Builder b)Creates a character stream descriptor, using the supplied builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetByteLength()longgetCharLength()longgetCurBytePos()longgetCurCharPos()Returns the current character position.longgetDataOffset()Returns the first index of the described stream that contains real data.longgetMaxCharLength()Returns the imposed maximum character length on the described stream.PositionedStreamgetPositionedStream()Returns the associated positioned stream, if the stream is position aware.java.io.InputStreamgetStream()Returns the associated stream.booleanisBufferable()Tells if the described stream should be buffered or not.booleanisPositionAware()Tells if the described stream is aware of its own position, and that it can reposition itself on request.java.lang.StringtoString()
-
-
-
Field Detail
-
BEFORE_FIRST
public static final long BEFORE_FIRST
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).- See Also:
- Constant Field Values
-
dataOffset
private final long dataOffset
First data byte in the byte stream.
-
curBytePos
private final long curBytePos
The current byte position.
-
curCharPos
private final long curCharPos
The current character position.
-
byteLength
private final long byteLength
The byte length of the stream,0if unknown.
-
charLength
private final long charLength
The character length of the stream,0if unknown.
-
maxCharLength
private final long maxCharLength
The maximum allowed character length.
-
bufferable
private final boolean bufferable
Tells if the stream can be buffered or not.
-
positionAware
private final boolean positionAware
Tells if the stream is aware of its own position.
-
stream
private final java.io.InputStream stream
Reference to the stream we are describing.
-
-
Constructor Detail
-
CharacterStreamDescriptor
private CharacterStreamDescriptor(CharacterStreamDescriptor.Builder b)
Creates a character stream descriptor, using the supplied builder.Use the builder to create instances of this class.
- Parameters:
b- object builder- See Also:
CharacterStreamDescriptor.Builder
-
-
Method Detail
-
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:
trueif the stream should be buffered for improved performance,falseif 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:
trueif 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_FIRSTif 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
0if no limit has been set.
-
getStream
public java.io.InputStream getStream()
Returns the associated stream.- Returns:
- An
InputStreamreference.
-
getPositionedStream
public PositionedStream getPositionedStream()
Returns the associated positioned stream, if the stream is position aware.- Returns:
- A
PositionedStreamreference. - Throws:
java.lang.ClassCastException- if the stream cannot be cast toPositionedStreamjava.lang.IllegalArgumentException- if the method is called and the assoicated stream isn't described as position aware.- See Also:
isPositionAware()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-