Package org.apache.derby.iapi.jdbc
Class CharacterStreamDescriptor.Builder
- java.lang.Object
-
- org.apache.derby.iapi.jdbc.CharacterStreamDescriptor.Builder
-
- Enclosing class:
- CharacterStreamDescriptor
public static class CharacterStreamDescriptor.Builder extends java.lang.Object
The builder for theCharacterStreamDescriptor
class. The builder is used to avoid having a large set of constructors. See the build() method for pre-build field validation. Note that the validation is only performed in sane builds.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
bufferable
private long
byteLength
private long
charLength
private long
curBytePos
private long
curCharPos
private long
dataOffset
private static long
DEFAULT_MAX_CHAR_LENGTH
Default max character length is unlimited.private long
maxCharLength
private boolean
positionAware
private java.io.InputStream
stream
-
Constructor Summary
Constructors Constructor Description Builder()
Creates a builder object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharacterStreamDescriptor.Builder
bufferable(boolean bufferable)
Sets if the stream should be buffered, defaults tofalse
.CharacterStreamDescriptor
build()
Creates a descriptor object based on the parameters kept in the builder instance.CharacterStreamDescriptor.Builder
byteLength(long length)
Sets the byte length of the stream, defaults to0
.CharacterStreamDescriptor.Builder
charLength(long length)
Sets the character length of the stream, defaults to0
.CharacterStreamDescriptor.Builder
copyState(CharacterStreamDescriptor csd)
Copies the state of the specified descriptor.CharacterStreamDescriptor.Builder
curBytePos(long pos)
Sets the current byte position, defaults to0
.CharacterStreamDescriptor.Builder
curCharPos(long pos)
Sets the current character position, defaults to1
.CharacterStreamDescriptor.Builder
dataOffset(long offset)
Sets the offset of the user data, defaults to0
.CharacterStreamDescriptor.Builder
maxCharLength(long length)
Imposes a length limit on the stream, expressed in number of characters, defaults toLong.MAX_VALUE
.CharacterStreamDescriptor.Builder
positionAware(boolean positionAware)
Sets if the stream can reposition itself or not, defaults tofalse
.CharacterStreamDescriptor.Builder
stream(java.io.InputStream stream)
Sets the stream described by the descriptor.java.lang.String
toString()
Returns a textual representation of the builder.
-
-
-
Field Detail
-
DEFAULT_MAX_CHAR_LENGTH
private static final long DEFAULT_MAX_CHAR_LENGTH
Default max character length is unlimited.- See Also:
- Constant Field Values
-
bufferable
private boolean bufferable
-
positionAware
private boolean positionAware
-
curBytePos
private long curBytePos
-
curCharPos
private long curCharPos
-
byteLength
private long byteLength
-
charLength
private long charLength
-
dataOffset
private long dataOffset
-
maxCharLength
private long maxCharLength
-
stream
private java.io.InputStream stream
-
-
Method Detail
-
bufferable
public CharacterStreamDescriptor.Builder bufferable(boolean bufferable)
Sets if the stream should be buffered, defaults tofalse
.- Parameters:
bufferable
-true
if buffering is advised,false
if not- Returns:
- The builder.
-
positionAware
public CharacterStreamDescriptor.Builder positionAware(boolean positionAware)
Sets if the stream can reposition itself or not, defaults tofalse
.- Parameters:
positionAware
-true
if the stream can reposition itself,false
if not- Returns:
- The builder.
-
curBytePos
public CharacterStreamDescriptor.Builder curBytePos(long pos)
Sets the current byte position, defaults to0
.- Parameters:
pos
- the current byte position- Returns:
- The builder.
-
curCharPos
public CharacterStreamDescriptor.Builder curCharPos(long pos)
Sets the current character position, defaults to1
.There is a special value for when the stream is position in the header area -
BEFORE_FIRST
.- Parameters:
pos
- the current character position,starting at1
- Returns:
- The builder.
- See Also:
CharacterStreamDescriptor.BEFORE_FIRST
-
byteLength
public CharacterStreamDescriptor.Builder byteLength(long length)
Sets the byte length of the stream, defaults to0
.A length of
0
means the length is unknown.- Parameters:
length
- the byte length of the stream (including header)- Returns:
- The builder.
-
copyState
public CharacterStreamDescriptor.Builder copyState(CharacterStreamDescriptor csd)
Copies the state of the specified descriptor.- Parameters:
csd
- the descriptor to copy- Returns:
- The builder.
-
charLength
public CharacterStreamDescriptor.Builder charLength(long length)
Sets the character length of the stream, defaults to0
.Headers are not included in this length, only the user data. A length of
0
means the length is unknown.- Parameters:
length
- the character length of the stream- Returns:
- The builder.
-
dataOffset
public CharacterStreamDescriptor.Builder dataOffset(long offset)
Sets the offset of the user data, defaults to0
.- Parameters:
offset
- first index with user data, zero based- Returns:
- The builder.
-
maxCharLength
public CharacterStreamDescriptor.Builder maxCharLength(long length)
Imposes a length limit on the stream, expressed in number of characters, defaults toLong.MAX_VALUE
.- Parameters:
length
- maximum number of characters- Returns:
- The builder.
-
stream
public CharacterStreamDescriptor.Builder stream(java.io.InputStream stream)
Sets the stream described by the descriptor.The stream is not allowed to be
null
.- Parameters:
stream
- the stream- Returns:
- The builder.
-
build
public CharacterStreamDescriptor build()
Creates a descriptor object based on the parameters kept in the builder instance.Default values will be used for parameters for which a value hasn't been set.
NOTE: Parameter validation is only performed in sane builds.
- Returns:
- A character stream descriptor instance.
-
toString
public java.lang.String toString()
Returns a textual representation of the builder.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The textual representation of the builder.
-
-