Top Description Inners Fields Constructors Methods
com.amazon.ion

public abstract Class BufferConfiguration<Configuration extends BufferConfiguration<Configuration>>

extends Object
Class Inheritance
Known Direct Subclasses
com.amazon.ion.IonBufferConfiguration
Type Parameters
<Configuration>
the type of the concrete subclass of this BufferConfiguration.
Imports
com.amazon.ion.impl._Private_IonConstants

Provides logic common to all BufferConfiguration implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
BufferConfiguration.Builder<
the type of BufferConfiguration.
Configuration extends BufferConfiguration<Configuration>
,
the type of Builder that builds BufferConfiguration subclasses of type `Configuration`.
BuilderType extends BufferConfiguration.Builder<Configuration, BuilderType>
>

Provides logic common to all BufferConfiguration Builder implementations.

public static interface
BufferConfiguration.DataHandler

Functional interface for reporting processed data.

public static interface
BufferConfiguration.OversizedValueHandler

Functional interface for handling oversized values.

Field Summary

Modifier and TypeField and Description
private final BufferConfiguration.DataHandler
dataHandler

The handler that will be notified when data is processed.

private final int
initialBufferSize

The initial size of the buffer, in bytes.

private final int
maximumBufferSize

The maximum number of bytes that may be buffered.

private final BufferConfiguration.OversizedValueHandler
oversizedValueHandler

The handler that will be notified when oversized values are encountered.

Constructor Summary

AccessConstructor and Description
protected
BufferConfiguration(BufferConfiguration.Builder<Configuration, ?>
the builder containing the settings to apply to the new configuration.
builder
)

Constructs an instance from the given Builder.

Method Summary

Modifier and TypeMethod and Description
public final BufferConfiguration.DataHandler

Returns:

the handler that will be notified when data is processed.
getDataHandler
()

public final int

Returns:

the initial size of the buffer, in bytes.
getInitialBufferSize
()

public final int

Returns:

the maximum number of bytes that will be buffered.
getMaximumBufferSize
()

public final BufferConfiguration.OversizedValueHandler

Returns:

the handler that will be notified when oversized values are encountered.
getOversizedValueHandler
()

protected void
requireMaximumBufferSize()

Requires that the maximum buffer size not be limited.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataHandlerback to summary
private final BufferConfiguration.DataHandler dataHandler

The handler that will be notified when data is processed.

initialBufferSizeback to summary
private final int initialBufferSize

The initial size of the buffer, in bytes.

maximumBufferSizeback to summary
private final int maximumBufferSize

The maximum number of bytes that may be buffered.

oversizedValueHandlerback to summary
private final BufferConfiguration.OversizedValueHandler oversizedValueHandler

The handler that will be notified when oversized values are encountered.

Constructor Detail

BufferConfigurationback to summary
protected BufferConfiguration(BufferConfiguration.Builder<Configuration, ?> builder)

Constructs an instance from the given Builder.

Parameters
builder:BufferConfiguration.Builder<Configuration, ?>

the builder containing the settings to apply to the new configuration.

Method Detail

getDataHandlerback to summary
public final BufferConfiguration.DataHandler getDataHandler()
Returns:BufferConfiguration.DataHandler

the handler that will be notified when data is processed.

getInitialBufferSizeback to summary
public final int getInitialBufferSize()
Returns:int

the initial size of the buffer, in bytes.

getMaximumBufferSizeback to summary
public final int getMaximumBufferSize()
Returns:int

the maximum number of bytes that will be buffered.

getOversizedValueHandlerback to summary
public final BufferConfiguration.OversizedValueHandler getOversizedValueHandler()
Returns:BufferConfiguration.OversizedValueHandler

the handler that will be notified when oversized values are encountered.

requireMaximumBufferSizeback to summary
protected void requireMaximumBufferSize()

Requires that the maximum buffer size not be limited.

com.amazon.ion back to summary

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

extends Object
Class Inheritance
Known Direct Subclasses
com.amazon.ion.IonBufferConfiguration.Builder
Type Parameters
<Configuration>
the type of BufferConfiguration.
<BuilderType>
the type of Builder that builds BufferConfiguration subclasses of type `Configuration`.

Provides logic common to all BufferConfiguration Builder implementations.

Field Summary

Modifier and TypeField and Description
private BufferConfiguration.DataHandler
dataHandler

The handler that will be notified when data is processed.

pack-priv static final int
DEFAULT_INITIAL_BUFFER_SIZE

Large enough that most streams will never need to grow the buffer.

private int
initialBufferSize

The initial size of the lookahead buffer, in bytes.

private int
maximumBufferSize

The maximum number of bytes that will be buffered.

private BufferConfiguration.OversizedValueHandler
oversizedValueHandler

The handler that will be notified when oversized values are encountered.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract Configuration

Returns:

a new instance.
build
()

Creates a new BufferConfiguration from the Builder's current settings.

public final BufferConfiguration.DataHandler

Returns:

the handler that will be notified when data is processed.
getDataHandler
()

public final int

Returns:

the initial size of the buffer, in bytes.
getInitialBufferSize
()

public int

Returns:

the maximum number of bytes that will be buffered.
getMaximumBufferSize
()

public abstract int

Returns:

the value.
getMinimumMaximumBufferSize
()

Gets the minimum allowed maximum buffer size.

public abstract BufferConfiguration.DataHandler

Returns:

the no-op DataHandler for the type of BufferConfiguration that this Builder builds.
getNoOpDataHandler
()

public abstract BufferConfiguration.OversizedValueHandler

Returns:

the no-op OversizedValueHandler for the type of BufferConfiguration that this Builder builds.
getNoOpOversizedValueHandler
()

public final BufferConfiguration.OversizedValueHandler

Returns:

the handler that will be notified when oversized values are encountered.
getOversizedValueHandler
()

public abstract BufferConfiguration.OversizedValueHandler

Returns:

an OversizedValueHandler that always throws a runtime exception.
getThrowingOversizedValueHandler
()

public final BuilderType

Returns:

this builder.
onData
(final BufferConfiguration.DataHandler
the handler.
handler
)

Sets the handler that will be notified when data is processed.

public final BuilderType

Returns:

this builder.
onOversizedValue
(final BufferConfiguration.OversizedValueHandler
the handler.
handler
)

Sets the handler that will be notified when oversized values are encountered.

public final BuilderType

Returns:

this Builder.
withInitialBufferSize
(final int
the value.
initialBufferSizeInBytes
)

Sets the initial size of the buffer that will be used to hold the data between top-level values.

public final BuilderType

Returns:

this builder.
withMaximumBufferSize
(final int
the value.
maximumBufferSizeInBytes
)

Set the maximum size of the buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataHandlerback to summary
private BufferConfiguration.DataHandler dataHandler

The handler that will be notified when data is processed.

DEFAULT_INITIAL_BUFFER_SIZEback to summary
pack-priv static final int DEFAULT_INITIAL_BUFFER_SIZE

Large enough that most streams will never need to grow the buffer.

Note

this only needs to be large enough to exceed the length of the longest top-level value plus any system values that precede it.

initialBufferSizeback to summary
private int initialBufferSize

The initial size of the lookahead buffer, in bytes.

maximumBufferSizeback to summary
private int maximumBufferSize

The maximum number of bytes that will be buffered.

oversizedValueHandlerback to summary
private BufferConfiguration.OversizedValueHandler oversizedValueHandler

The handler that will be notified when oversized values are encountered.

Constructor Detail

Builderback to summary
public Builder()

Method Detail

buildback to summary
public abstract Configuration build()

Creates a new BufferConfiguration from the Builder's current settings.

Returns:Configuration

a new instance.

getDataHandlerback to summary
public final BufferConfiguration.DataHandler getDataHandler()
Returns:BufferConfiguration.DataHandler

the handler that will be notified when data is processed.

getInitialBufferSizeback to summary
public final int getInitialBufferSize()
Returns:int

the initial size of the buffer, in bytes.

getMaximumBufferSizeback to summary
public int getMaximumBufferSize()
Returns:int

the maximum number of bytes that will be buffered.

getMinimumMaximumBufferSizeback to summary
public abstract int getMinimumMaximumBufferSize()

Gets the minimum allowed maximum buffer size.

Returns:int

the value.

getNoOpDataHandlerback to summary
public abstract BufferConfiguration.DataHandler getNoOpDataHandler()
Returns:BufferConfiguration.DataHandler

the no-op DataHandler for the type of BufferConfiguration that this Builder builds.

getNoOpOversizedValueHandlerback to summary
public abstract BufferConfiguration.OversizedValueHandler getNoOpOversizedValueHandler()
Returns:BufferConfiguration.OversizedValueHandler

the no-op OversizedValueHandler for the type of BufferConfiguration that this Builder builds.

getOversizedValueHandlerback to summary
public final BufferConfiguration.OversizedValueHandler getOversizedValueHandler()
Returns:BufferConfiguration.OversizedValueHandler

the handler that will be notified when oversized values are encountered.

getThrowingOversizedValueHandlerback to summary
public abstract BufferConfiguration.OversizedValueHandler getThrowingOversizedValueHandler()
Returns:BufferConfiguration.OversizedValueHandler

an OversizedValueHandler that always throws a runtime exception.

onDataback to summary
public final BuilderType onData(final 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:BufferConfiguration.DataHandler

the handler.

Returns:BuilderType

this builder.

onOversizedValueback to summary
public final BuilderType onOversizedValue(final 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:BufferConfiguration.OversizedValueHandler

the handler.

Returns:BuilderType

this builder.

withInitialBufferSizeback to summary
public final BuilderType withInitialBufferSize(final 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:int

the value.

Returns:BuilderType

this Builder.

withMaximumBufferSizeback to summary
public final BuilderType withMaximumBufferSize(final 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: Near to the maximum size of an array.

Parameters
maximumBufferSizeInBytes:int

the value.

Returns:BuilderType

this builder.

com.amazon.ion back to summary

public Interface BufferConfiguration.DataHandler

Annotations
@FunctionalInterface

Functional interface for reporting processed data.

Method Summary

Modifier and TypeMethod and Description
public void
onData(int
the number of bytes processed.
numberOfBytes
)

Invoked whenever the bytes from a value are processed, regardless of whether the bytes are buffered or skipped due to the value being oversized.

Method Detail

onDataback to summary
public void onData(int numberOfBytes)

Invoked whenever the bytes from a value are processed, regardless of whether the bytes are buffered or skipped due to the value being oversized.

Parameters
numberOfBytes:int

the number of bytes processed.

com.amazon.ion back to summary

public Interface BufferConfiguration.OversizedValueHandler

Annotations
@FunctionalInterface

Functional interface for handling oversized values.

Method Summary

Modifier and TypeMethod and Description
public void
onOversizedValue()

Invoked each time a user value exceeds the buffer size limit specified.

Method Detail

onOversizedValueback to summary
public void onOversizedValue()

Invoked each time a user value exceeds the buffer size limit specified. This is recoverable. If the implementation wishes to recover, it should simply return normally from this method. The oversized value will be flushed from the buffer; normal processing will resume with the next value. If the implementation wishes to abort processing immediately, it may throw an exception from this method.