Class IonBinaryWriterBuilder
- Direct Known Subclasses:
_Private_IonBinaryWriterBuilder
IonWriters emitting the Ion binary format.
WARNING: This class should not be extended by code outside of this library.
Builders may be configured once and reused to construct multiple objects.
Instances of this class are not not safe for use by multiple threads unless they are immutable.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.amazon.ion.system.IonWriterBuilder
IonWriterBuilder.InitialIvmHandling, IonWriterBuilder.IvmMinimizing -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNOT FOR APPLICATION USE!protectedNOT FOR APPLICATION USE! -
Method Summary
Modifier and TypeMethodDescriptionabstract IonBinaryWriterBuildercopy()final IonCatalogGets the catalog to use when building anIonWriter.final SymbolTable[]Gets the imports that will be used to construct the initial local symbol table.Gets the strategy for emitting Ion version markers at the start of the stream.abstract SymbolTableGets the symbol table to use for encoded data.Gets the strategy for eliminating Ion version markers mid-stream.abstract IonBinaryWriterBuilderbooleanIndicates whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data.abstract IonBinaryWriterBuildermutable()protected voidNOT FOR APPLICATION USE!voidsetCatalog(IonCatalog catalog) Sets the catalog to use when building anIonWriter.voidsetImports(SymbolTable... imports) Sets the shared symbol tables that will be used to construct the initial local symbol table.abstract voidsetInitialSymbolTable(SymbolTable symtab) Declares the symbol table to use for encoded data.abstract voidsetIsFloatBinary32Enabled(boolean enabled) Enables or disables writing Binary32 (4-byte, single precision, IEEE-754) values for floats when there would be no loss in precision.abstract voidsetLocalSymbolTableAppendEnabled(boolean enabled) Enables or disables writing local symbol tables that append symbols to the current symbol table.voidsetStreamCopyOptimized(boolean optimized) Declares whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data.static IonBinaryWriterBuilderstandard()The standard builder of binary writers, with all configuration properties having their default values.final IonBinaryWriterBuilderwithCatalog(IonCatalog catalog) Declares the catalog to use when building anIonWriter, returning a new mutable builder if this is immutable.abstract IonBinaryWriterBuilderDisables writing Binary32 (4-byte, single precision, IEEE-754) values for floats.abstract IonBinaryWriterBuilderEnables writing Binary32 (4-byte, single precision, IEEE-754) values for floats when there would be no loss in precision.final IonBinaryWriterBuilderwithImports(SymbolTable... imports) Declares the imports to use when building anIonWriter, returning a new mutable builder if this is immutable.abstract IonBinaryWriterBuilderwithInitialSymbolTable(SymbolTable symtab) Declares the symbol table to use for encoded data.abstract IonBinaryWriterBuilderDisables writing local symbol tables that append symbols to the current symbol table.abstract IonBinaryWriterBuilderEnables writing local symbol tables that append symbols to the current symbol table.final IonBinaryWriterBuilderwithStreamCopyOptimized(boolean optimized) Declares whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data, returning a new mutable builder if this is immutable.Methods inherited from class com.amazon.ion.system.IonWriterBuilder
build
-
Constructor Details
-
IonBinaryWriterBuilder
protected IonBinaryWriterBuilder()NOT FOR APPLICATION USE! -
IonBinaryWriterBuilder
NOT FOR APPLICATION USE!
-
-
Method Details
-
standard
The standard builder of binary writers, with all configuration properties having their default values.- Returns:
- a new, mutable builder instance.
-
copy
-
immutable
-
mutable
-
withCatalog
Declares the catalog to use when building anIonWriter, returning a new mutable builder if this is immutable.- Parameters:
catalog- the catalog to use in built writers. If null, the writer will be unable to resolve manually-written imports and may throw an exception.- Returns:
- this instance, if mutable; otherwise a mutable copy of this instance.
- See Also:
-
withImports
Declares the imports to use when building anIonWriter, returning a new mutable builder if this is immutable.If the imports sequence is not null and not empty, the output stream will be bootstrapped with a local symbol table that uses the given
imports.- Parameters:
imports- a sequence of shared symbol tables. The first (and only the first) may be a system table.- Returns:
- this instance, if mutable; otherwise a mutable copy of this instance.
- See Also:
-
getInitialIvmHandling
Description copied from class:IonWriterBuilderGets the strategy for emitting Ion version markers at the start of the stream. By default, IVMs are emitted only when explicitly written or when necessary (for example, before data that's not Ion 1.0, or at the start of Ion binary output).- Specified by:
getInitialIvmHandlingin classIonWriterBuilder- Returns:
- always
IonWriterBuilder.InitialIvmHandling.ENSURE.
-
getIvmMinimizing
Description copied from class:IonWriterBuilderGets the strategy for eliminating Ion version markers mid-stream. By default, IVMs are emitted as received or when necessary.This strategy does not affect handling of IVMs at the start of the stream; that's the job of
IonWriterBuilder.InitialIvmHandling.- Specified by:
getIvmMinimizingin classIonWriterBuilder- Returns:
- always null.
-
getInitialSymbolTable
Gets the symbol table to use for encoded data. To avoid conflicts between different data streams, if the given instance is mutable, it will be copied whenbuild()is called.- Returns:
- a local or system symbol table.
May be null, in which case the initial symbol table is that of
$ion_1_0. - See Also:
-
setInitialSymbolTable
Declares the symbol table to use for encoded data. To avoid conflicts between different data streams, if the given instance is mutable, it will be copied whenbuild()is called.- Parameters:
symtab- must be a local or system symbol table. May be null, in which case the initial symbol table is that of$ion_1_0.- Throws:
SubstituteSymbolTableException- if any imported table is a substitute (seeSymbolTable).- See Also:
-
withInitialSymbolTable
Declares the symbol table to use for encoded data. To avoid conflicts between different data streams, if the given instance is mutable, it will be copied whenbuild()is called.- Parameters:
symtab- must be a local or system symbol table. May be null, in which case the initial symbol table is that of$ion_1_0.- Throws:
SubstituteSymbolTableException- if any imported table is a substitute (seeSymbolTable).
-
setLocalSymbolTableAppendEnabled
public abstract void setLocalSymbolTableAppendEnabled(boolean enabled) Enables or disables writing local symbol tables that append symbols to the current symbol table. This functionality is disabled by default. -
withLocalSymbolTableAppendEnabled
Enables writing local symbol tables that append symbols to the current symbol table. This functionality is disabled by default. -
withLocalSymbolTableAppendDisabled
Disables writing local symbol tables that append symbols to the current symbol table. This functionality is disabled by default. -
setIsFloatBinary32Enabled
public abstract void setIsFloatBinary32Enabled(boolean enabled) Enables or disables writing Binary32 (4-byte, single precision, IEEE-754) values for floats when there would be no loss in precision. By default Binary32 support is disabled to ensure the broadest compatibility with existing Ion implementations. Historically, implementations were only able to read Binary64 values.When enabled, floats are evaluated for a possible loss of data at single precision. If the value can be represented in single precision without data loss, it is written as a 4-byte, Binary32 value. Floats which cannot be represented as single-precision values are written as 8-byte, Binary64 values (this is the legacy behavior for all floats, regardless of value).
- Parameters:
enabled-trueto enable writing 4-byte floats,falseto always write 8-byte floats.- See Also:
-
withFloatBinary32Enabled
Enables writing Binary32 (4-byte, single precision, IEEE-754) values for floats when there would be no loss in precision. By default Binary32 support is disabled to ensure the broadest compatibility with existing Ion implementations. Historically, implementations were only able to read Binary64 values.When enabled, floats are evaluated for a possible loss of data at single precision. If the value can be represented in single precision without data loss, it is written as a 4-byte, Binary32 value. Floats which cannot be represented as single-precision values are written as 8-byte, Binary64 values (this is the legacy behavior for all floats, regardless of value).
- See Also:
-
withFloatBinary32Disabled
Disables writing Binary32 (4-byte, single precision, IEEE-754) values for floats. This is the default behavior.When disabled, floats are always written as 8-byte, Binary64 values regardless of value. This is the legacy behavior for all Ion binary writers and ensures the boarded compatibility with other Ion consumers.
- See Also:
-
isStreamCopyOptimized
public boolean isStreamCopyOptimized()Indicates whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data. By default, this property is false.- See Also:
-
setStreamCopyOptimized
public void setStreamCopyOptimized(boolean optimized) Declares whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data. By default, this property is false.This feature is experimental! Please test thoroughly and report any issues.
- Throws:
UnsupportedOperationException- if this is immutable.- See Also:
-
withStreamCopyOptimized
Declares whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data, returning a new mutable builder if this is immutable.This feature is experimental! Please test thoroughly and report any issues.
- See Also:
-
mutationCheck
protected void mutationCheck()NOT FOR APPLICATION USE! -
getCatalog
Gets the catalog to use when building anIonWriter. The catalog is needed to resolve manually-written imports (not common). By default, this property is null.- See Also:
-
setCatalog
Sets the catalog to use when building anIonWriter.- Parameters:
catalog- the catalog to use in built writers. If null, the writer will be unable to resolve manually-written imports and may throw an exception.- Throws:
UnsupportedOperationException- if this is immutable.- See Also:
-
getImports
Gets the imports that will be used to construct the initial local symbol table.- Returns:
- may be null or empty.
- See Also:
-
setImports
Sets the shared symbol tables that will be used to construct the initial local symbol table.If the imports sequence is not null and not empty, the output stream will be bootstrapped with a local symbol table that uses the given
imports.- Parameters:
imports- a sequence of shared symbol tables. The first (and only the first) may be a system table.- Throws:
UnsupportedOperationException- if this is immutable.- See Also:
-