Class IonBinaryWriterBuilder
- java.lang.Object
-
- com.amazon.ion.system.IonWriterBuilder
-
- com.amazon.ion.system.IonBinaryWriterBuilder
-
- Direct Known Subclasses:
_Private_IonBinaryWriterBuilder
public abstract class IonBinaryWriterBuilder extends IonWriterBuilder
The builder for creatingIonWriters 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
Constructors Modifier Constructor Description protectedIonBinaryWriterBuilder()NOT FOR APPLICATION USE!protectedIonBinaryWriterBuilder(IonBinaryWriterBuilder that)NOT FOR APPLICATION USE!
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract IonBinaryWriterBuildercopy()IonCataloggetCatalog()Gets the catalog to use when building anIonWriter.SymbolTable[]getImports()Gets the imports that will be used to construct the initial local symbol table.IonWriterBuilder.InitialIvmHandlinggetInitialIvmHandling()Gets the strategy for emitting Ion version markers at the start of the stream.abstract SymbolTablegetInitialSymbolTable()Gets the symbol table to use for encoded data.IonWriterBuilder.IvmMinimizinggetIvmMinimizing()Gets the strategy for eliminating Ion version markers mid-stream.abstract IonBinaryWriterBuilderimmutable()booleanisStreamCopyOptimized()Indicates whether built writers may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data.abstract IonBinaryWriterBuildermutable()protected voidmutationCheck()NOT 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.IonBinaryWriterBuilderwithCatalog(IonCatalog catalog)Declares the catalog to use when building anIonWriter, returning a new mutable builder if this is immutable.abstract IonBinaryWriterBuilderwithFloatBinary32Disabled()Disables writing Binary32 (4-byte, single precision, IEEE-754) values for floats.abstract IonBinaryWriterBuilderwithFloatBinary32Enabled()Enables writing Binary32 (4-byte, single precision, IEEE-754) values for floats when there would be no loss in precision.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 IonBinaryWriterBuilderwithLocalSymbolTableAppendDisabled()Disables writing local symbol tables that append symbols to the current symbol table.abstract IonBinaryWriterBuilderwithLocalSymbolTableAppendEnabled()Enables writing local symbol tables that append symbols to the current symbol table.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 Detail
-
IonBinaryWriterBuilder
protected IonBinaryWriterBuilder()
NOT FOR APPLICATION USE!
-
IonBinaryWriterBuilder
protected IonBinaryWriterBuilder(IonBinaryWriterBuilder that)
NOT FOR APPLICATION USE!
-
-
Method Detail
-
standard
public static IonBinaryWriterBuilder standard()
The standard builder of binary writers, with all configuration properties having their default values.- Returns:
- a new, mutable builder instance.
-
copy
public abstract IonBinaryWriterBuilder copy()
-
immutable
public abstract IonBinaryWriterBuilder immutable()
-
mutable
public abstract IonBinaryWriterBuilder mutable()
-
withCatalog
public final IonBinaryWriterBuilder withCatalog(IonCatalog catalog)
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:
getCatalog(),setCatalog(IonCatalog)
-
withImports
public final IonBinaryWriterBuilder withImports(SymbolTable... imports)
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:
getImports(),setImports(SymbolTable...)
-
getInitialIvmHandling
public IonWriterBuilder.InitialIvmHandling 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
public IonWriterBuilder.IvmMinimizing 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
public abstract SymbolTable 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(SymbolTable),withInitialSymbolTable(SymbolTable)
-
setInitialSymbolTable
public abstract void setInitialSymbolTable(SymbolTable symtab)
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:
getInitialSymbolTable(),withInitialSymbolTable(SymbolTable)
-
withInitialSymbolTable
public abstract IonBinaryWriterBuilder withInitialSymbolTable(SymbolTable symtab)
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
public abstract IonBinaryWriterBuilder withLocalSymbolTableAppendEnabled()
Enables writing local symbol tables that append symbols to the current symbol table. This functionality is disabled by default.
-
withLocalSymbolTableAppendDisabled
public abstract IonBinaryWriterBuilder 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(),withFloatBinary32Disabled()
-
withFloatBinary32Enabled
public abstract IonBinaryWriterBuilder 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).
-
withFloatBinary32Disabled
public abstract IonBinaryWriterBuilder 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.
-
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.
-
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:
java.lang.UnsupportedOperationException- if this is immutable.- See Also:
isStreamCopyOptimized(),withStreamCopyOptimized(boolean)
-
withStreamCopyOptimized
public final IonBinaryWriterBuilder withStreamCopyOptimized(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.This feature is experimental! Please test thoroughly and report any issues.
-
mutationCheck
protected void mutationCheck()
NOT FOR APPLICATION USE!
-
getCatalog
public final IonCatalog 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(IonCatalog),withCatalog(IonCatalog)
-
setCatalog
public void setCatalog(IonCatalog catalog)
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:
java.lang.UnsupportedOperationException- if this is immutable.- See Also:
getCatalog(),withCatalog(IonCatalog)
-
getImports
public final SymbolTable[] getImports()
Gets the imports that will be used to construct the initial local symbol table.- Returns:
- may be null or empty.
- See Also:
setImports(SymbolTable...),withImports(SymbolTable...)
-
setImports
public void setImports(SymbolTable... imports)
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:
java.lang.UnsupportedOperationException- if this is immutable.- See Also:
getImports(),withImports(SymbolTable...)
-
-