Package com.amazon.ion
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Configurationbuild()Creates a new BufferConfiguration from the Builder's current settings.final intintabstract intGets the minimum allowed maximum buffer size.abstract BufferConfiguration.DataHandlerfinal BuilderTypeonData(BufferConfiguration.DataHandler handler) Sets the handler that will be notified when data is processed.final BuilderTypeSets the handler that will be notified when oversized values are encountered.final BuilderTypewithInitialBufferSize(int initialBufferSizeInBytes) Sets the initial size of the buffer that will be used to hold the data between top-level values.final BuilderTypewithMaximumBufferSize(int maximumBufferSizeInBytes) Set the maximum size of the buffer.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
withInitialBufferSize
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
Sets the handler that will be notified when oversized values are encountered. If the maximum buffer size is finite (seewithMaximumBufferSize(int), this handler is required to be non-null.- Parameters:
handler- the handler.- Returns:
- this builder.
-
onData
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
- Returns:
- the handler that will be notified when oversized values are encountered.
-
getDataHandler
- Returns:
- the handler that will be notified when data is processed.
-
withMaximumBufferSize
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
- Returns:
- the no-op
BufferConfiguration.OversizedValueHandlerfor the type of BufferConfiguration that this Builder builds.
-
getThrowingOversizedValueHandler
- Returns:
- an
BufferConfiguration.OversizedValueHandlerthat always throws a runtime exception.
-
getNoOpDataHandler
- Returns:
- the no-op
BufferConfiguration.DataHandlerfor the type of BufferConfiguration that this Builder builds.
-
build
Creates a new BufferConfiguration from the Builder's current settings.- Returns:
- a new instance.
-