public class CharacterStreamDescriptor
extends java.lang.Object
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.
CharacterStreamDescriptor.Builder
Modifier and Type | Class and Description |
---|---|
static class |
CharacterStreamDescriptor.Builder
The builder for the
CharacterStreamDescriptor class. |
Modifier and Type | Field and Description |
---|---|
static 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).
|
private boolean |
bufferable
Tells if the stream can be buffered or not.
|
private long |
byteLength
The byte length of the stream,
0 if unknown. |
private long |
charLength
The character length of the stream,
0 if unknown. |
private long |
curBytePos
The current byte position.
|
private long |
curCharPos
The current character position.
|
private long |
dataOffset
First data byte in the byte stream.
|
private long |
maxCharLength
The maximum allowed character length.
|
private boolean |
positionAware
Tells if the stream is aware of its own position.
|
private java.io.InputStream |
stream
Reference to the stream we are describing.
|
Modifier | Constructor and Description |
---|---|
private |
CharacterStreamDescriptor(CharacterStreamDescriptor.Builder b)
Creates a character stream descriptor, using the supplied builder.
|
Modifier and Type | Method and Description |
---|---|
long |
getByteLength() |
long |
getCharLength() |
long |
getCurBytePos() |
long |
getCurCharPos()
Returns the current character position.
|
long |
getDataOffset()
Returns the first index of the described stream that contains real data.
|
long |
getMaxCharLength()
Returns the imposed maximum character length on the described stream.
|
PositionedStream |
getPositionedStream()
Returns the associated positioned stream, if the stream is position
aware.
|
java.io.InputStream |
getStream()
Returns the associated stream.
|
boolean |
isBufferable()
Tells if the described stream should be buffered or not.
|
boolean |
isPositionAware()
Tells if the described stream is aware of its own position, and that it
can reposition itself on request.
|
java.lang.String |
toString() |
public static final long BEFORE_FIRST
private final long dataOffset
private final long curBytePos
private final long curCharPos
private final long byteLength
0
if unknown.private final long charLength
0
if unknown.private final long maxCharLength
private final boolean bufferable
private final boolean positionAware
private final java.io.InputStream stream
private CharacterStreamDescriptor(CharacterStreamDescriptor.Builder b)
Use the builder to create instances of this class.
b
- object builderCharacterStreamDescriptor.Builder
public boolean isBufferable()
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.
true
if the stream should be buffered for improved
performance, false
if it should not be buffered.public boolean isPositionAware()
true
if the stream is position aware, @{code false}
otherwise.public long getByteLength()
public long getCharLength()
public long getCurBytePos()
public long getCurCharPos()
1
, or BEFORE_FIRST
if the stream is
positioned before the first character.public long getDataOffset()
The information is typically used to filter out meta data at the head of the stream, and to correctly reset the stream.
public long getMaxCharLength()
The default value is Long.MAX_VALUE
.
0
if
no limit has been set.public java.io.InputStream getStream()
InputStream
reference.public PositionedStream getPositionedStream()
PositionedStream
reference.java.lang.ClassCastException
- if the stream cannot be cast to
PositionedStream
java.lang.IllegalArgumentException
- if the method is called and the
assoicated stream isn't described as position aware.isPositionAware()
public java.lang.String toString()
toString
in class java.lang.Object
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.