Class BufferConfiguration.Builder<Configuration extends BufferConfiguration<Configuration>,BuilderType extends BufferConfiguration.Builder<Configuration,BuilderType>>

java.lang.Object
com.amazon.ion.BufferConfiguration.Builder<Configuration,BuilderType>
Type Parameters:
Configuration - the type of BufferConfiguration.
BuilderType - the type of Builder that builds BufferConfiguration subclasses of type `Configuration`.
Direct Known Subclasses:
IonBufferConfiguration.Builder
Enclosing class:
BufferConfiguration<Configuration extends BufferConfiguration<Configuration>>

public abstract static class BufferConfiguration.Builder<Configuration extends BufferConfiguration<Configuration>,BuilderType extends BufferConfiguration.Builder<Configuration,BuilderType>> extends Object
Provides logic common to all BufferConfiguration Builder implementations.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • withInitialBufferSize

      public final BuilderType withInitialBufferSize(int initialBufferSizeInBytes)
      Sets the initial size of the buffer that will be used to hold the data between top-level values. Default: 32KB.
      Parameters:
      initialBufferSizeInBytes - the value.
      Returns:
      this Builder.
    • getInitialBufferSize

      public final int getInitialBufferSize()
      Returns:
      the initial size of the buffer, in bytes.
    • onOversizedValue

      public final BuilderType onOversizedValue(BufferConfiguration.OversizedValueHandler handler)
      Sets the handler that will be notified when oversized values are encountered. If the maximum buffer size is finite (see withMaximumBufferSize(int), this handler is required to be non-null.
      Parameters:
      handler - the handler.
      Returns:
      this builder.
    • onData

      public final BuilderType onData(BufferConfiguration.DataHandler handler)
      Sets the handler that will be notified when data is processed. The handler may be null, in which case the number of bytes processed will not be reported.
      Parameters:
      handler - the handler.
      Returns:
      this builder.
    • getOversizedValueHandler

      public final BufferConfiguration.OversizedValueHandler getOversizedValueHandler()
      Returns:
      the handler that will be notified when oversized values are encountered.
    • getDataHandler

      public final BufferConfiguration.DataHandler getDataHandler()
      Returns:
      the handler that will be notified when data is processed.
    • withMaximumBufferSize

      public final BuilderType withMaximumBufferSize(int maximumBufferSizeInBytes)
      Set the maximum size of the buffer. For binary Ion, the minimum value is 5 because all valid binary Ion data begins with a 4-byte Ion version marker and the smallest value is 1 byte. For text Ion, the minimum value is 2 because the smallest text Ion value is 1 byte and the smallest delimiter is 1 byte. Default: Integer.MAX_VALUE.
      Parameters:
      maximumBufferSizeInBytes - the value.
      Returns:
      this builder.
    • getMaximumBufferSize

      public int getMaximumBufferSize()
      Returns:
      the maximum number of bytes that will be buffered.
    • getMinimumMaximumBufferSize

      public abstract int getMinimumMaximumBufferSize()
      Gets the minimum allowed maximum buffer size.
      Returns:
      the value.
    • getNoOpOversizedValueHandler

      public abstract BufferConfiguration.OversizedValueHandler getNoOpOversizedValueHandler()
      Returns:
      the no-op BufferConfiguration.OversizedValueHandler for the type of BufferConfiguration that this Builder builds.
    • getThrowingOversizedValueHandler

      public abstract BufferConfiguration.OversizedValueHandler getThrowingOversizedValueHandler()
      Returns:
      an BufferConfiguration.OversizedValueHandler that always throws a runtime exception.
    • getNoOpDataHandler

      public abstract BufferConfiguration.DataHandler getNoOpDataHandler()
      Returns:
      the no-op BufferConfiguration.DataHandler for the type of BufferConfiguration that this Builder builds.
    • build

      public abstract Configuration build()
      Creates a new BufferConfiguration from the Builder's current settings.
      Returns:
      a new instance.