Class CharacterStreamDescriptor.Builder

java.lang.Object
org.apache.derby.iapi.jdbc.CharacterStreamDescriptor.Builder
Enclosing class:
CharacterStreamDescriptor

public static class CharacterStreamDescriptor.Builder extends Object
The builder for the CharacterStreamDescriptor 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 Details

    • DEFAULT_MAX_CHAR_LENGTH

      private static final long DEFAULT_MAX_CHAR_LENGTH
      Default max character length is unlimited.
      See Also:
    • 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 InputStream stream
  • Constructor Details

    • Builder

      public Builder()
      Creates a builder object.
  • Method Details

    • bufferable

      public CharacterStreamDescriptor.Builder bufferable(boolean bufferable)
      Sets if the stream should be buffered, defaults to false.
      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 to false.
      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 to 0.
      Parameters:
      pos - the current byte position
      Returns:
      The builder.
    • curCharPos

      public CharacterStreamDescriptor.Builder curCharPos(long pos)
      Sets the current character position, defaults to 1.

      There is a special value for when the stream is position in the header area - BEFORE_FIRST.

      Parameters:
      pos - the current character position,starting at 1
      Returns:
      The builder.
      See Also:
    • byteLength

      public CharacterStreamDescriptor.Builder byteLength(long length)
      Sets the byte length of the stream, defaults to 0.

      A length of 0 means the length is unknown.

      Parameters:
      length - the byte length of the stream (including header)
      Returns:
      The builder.
    • copyState

      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 to 0.

      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 to 0.
      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 to Long.MAX_VALUE.
      Parameters:
      length - maximum number of characters
      Returns:
      The builder.
    • 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 String toString()
      Returns a textual representation of the builder.
      Overrides:
      toString in class Object
      Returns:
      The textual representation of the builder.