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 java.lang.ObjectProvides logic common to all BufferConfiguration Builder implementations.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Configurationbuild()Creates a new BufferConfiguration from the Builder's current settings.BufferConfiguration.DataHandlergetDataHandler()intgetInitialBufferSize()intgetMaximumBufferSize()abstract intgetMinimumMaximumBufferSize()Gets the minimum allowed maximum buffer size.abstract BufferConfiguration.DataHandlergetNoOpDataHandler()abstract BufferConfiguration.OversizedValueHandlergetNoOpOversizedValueHandler()BufferConfiguration.OversizedValueHandlergetOversizedValueHandler()BuilderTypeonData(BufferConfiguration.DataHandler handler)Sets the handler that will be notified when data is processed.BuilderTypeonOversizedValue(BufferConfiguration.OversizedValueHandler handler)Sets the handler that will be notified when oversized values are encountered.BuilderTypewithInitialBufferSize(int initialBufferSizeInBytes)Sets the initial size of the buffer that will be used to hold the data between top-level values.BuilderTypewithMaximumBufferSize(int maximumBufferSizeInBytes)Set the maximum number of bytes between top-level values.
-
-
-
Method Detail
-
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 lookahead 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 (seewithMaximumBufferSize(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 number of bytes between top-level values. This can be used to limit growth of the internal 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 delimited 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.OversizedValueHandlerfor the type of BufferConfiguration that this Builder builds.
-
getNoOpDataHandler
public abstract BufferConfiguration.DataHandler getNoOpDataHandler()
- Returns:
- the no-op
BufferConfiguration.DataHandlerfor 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.
-
-