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.ObjectThe builder for theCharacterStreamDescriptorclass. 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 booleanbufferableprivate longbyteLengthprivate longcharLengthprivate longcurBytePosprivate longcurCharPosprivate longdataOffsetprivate static longDEFAULT_MAX_CHAR_LENGTHDefault max character length is unlimited.private longmaxCharLengthprivate booleanpositionAwareprivate java.io.InputStreamstream
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharacterStreamDescriptor.Builderbufferable(boolean bufferable)Sets if the stream should be buffered, defaults tofalse.CharacterStreamDescriptorbuild()Creates a descriptor object based on the parameters kept in the builder instance.CharacterStreamDescriptor.BuilderbyteLength(long length)Sets the byte length of the stream, defaults to0.CharacterStreamDescriptor.BuildercharLength(long length)Sets the character length of the stream, defaults to0.CharacterStreamDescriptor.BuildercopyState(CharacterStreamDescriptor csd)Copies the state of the specified descriptor.CharacterStreamDescriptor.BuildercurBytePos(long pos)Sets the current byte position, defaults to0.CharacterStreamDescriptor.BuildercurCharPos(long pos)Sets the current character position, defaults to1.CharacterStreamDescriptor.BuilderdataOffset(long offset)Sets the offset of the user data, defaults to0.CharacterStreamDescriptor.BuildermaxCharLength(long length)Imposes a length limit on the stream, expressed in number of characters, defaults toLong.MAX_VALUE.CharacterStreamDescriptor.BuilderpositionAware(boolean positionAware)Sets if the stream can reposition itself or not, defaults tofalse.CharacterStreamDescriptor.Builderstream(java.io.InputStream stream)Sets the stream described by the descriptor.java.lang.StringtoString()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-trueif buffering is advised,falseif not- Returns:
- The builder.
-
positionAware
public CharacterStreamDescriptor.Builder positionAware(boolean positionAware)
Sets if the stream can reposition itself or not, defaults tofalse.- Parameters:
positionAware-trueif the stream can reposition itself,falseif 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
0means 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
0means 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:
toStringin classjava.lang.Object- Returns:
- The textual representation of the builder.
-
-