Class IonSystemBuilder
IonSystems.
Most applications will only have one or two system instances;
see IonSystem for important constraints.
Builders may be configured once and reused to construct multiple
objects. They can be copied to create a mutable
copy of a prototype (presumably for altering some property).
Instances of this class are not safe for use by multiple threads unless they are immutable.
The easiest way to get going is to use the standard() builder:
IonSystem ion = IonSystemBuilder.standard().build();
However, most long-lived applications will want to provide a custom
IonCatalog implementation rather than using the default
SimpleCatalog. For example:
IonCatalog catalog = newCustomCatalog();
IonSystemBuilder b = IonSystemBuilder.standard().copy();
b.setCatalog(catalog);
IonSystem ion = b.build();
Configuration properties follow the standard JavaBeans idiom in order to be friendly to dependency injection systems. They also provide alternative mutation methods that enable a more fluid style:
IonCatalog catalog = newCustomCatalog();
IonSystem ion = IonSystemBuilder.standard()
.withCatalog(catalog)
.build();
Configuration Properties
This builder provides the following configurable properties:
-
catalog: The
IonCatalogused as a default when reading Ion data. If null, each system will be built with a newSimpleCatalog. - streamCopyOptimized: When true, this enables optimizations when copying data between two Ion streams. For example, in some cases raw binary-encoded Ion can be copied directly from the input to the output. This can have significant performance benefits when the appropriate conditions are met. This feature is experimental! Please test thoroughly and report any issues.
-
Method Summary
Modifier and TypeMethodDescriptionfinal IonSystembuild()Builds a newIonSysteminstance based on this builder's configuration properties.final IonSystemBuildercopy()Creates a mutable copy of this builder.final IonCatalogGets the catalog to use when building anIonSystem.final IonReaderBuilderGets the reader builder whose options will be used when building anIonSystem.Returns an immutable builder configured exactly like this one.final booleanIndicates whether built systems may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data.mutable()Returns a mutable builder configured exactly like this one.final voidsetCatalog(IonCatalog catalog) Sets the catalog to use when building anIonSystem.final voidsetReaderBuilder(IonReaderBuilder builder) Sets the reader builder whose options will be used to use when building anIonSystem.final voidsetStreamCopyOptimized(boolean optimized) Declares whether built systems may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data.static IonSystemBuilderstandard()The standard builder ofIonSystems.final IonSystemBuilderwithCatalog(IonCatalog catalog) Declares the catalog to use when building anIonSystem, returning a new mutable builder if this is immutable.final IonSystemBuilderwithReaderBuilder(IonReaderBuilder builder) Declares the reader builder whose options will be used to use when building anIonSystem, returning a new mutable builder if this is immutable.final IonSystemBuilderwithStreamCopyOptimized(boolean optimized) Declares whether built systems may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data, returning a new mutable builder if this is immutable.
-
Method Details
-
standard
The standard builder ofIonSystems. See the class documentation for the standard configuration.The returned instance is immutable.
-
copy
Creates a mutable copy of this builder.- Returns:
- a new builder with the same configuration as
this.
-
immutable
Returns an immutable builder configured exactly like this one.- Returns:
- this instance, if immutable; otherwise an immutable copy of this instance.
-
mutable
Returns a mutable builder configured exactly like this one.- Returns:
- this instance, if mutable; otherwise a mutable copy of this instance.
-
getCatalog
Gets the catalog to use when building anIonSystem. By default, this property is null.- See Also:
-
setCatalog
Sets the catalog to use when building anIonSystem.- Parameters:
catalog- the catalog to use in built systems. If null, each system will be built with a newSimpleCatalog.- Throws:
UnsupportedOperationException- if this is immutable.- See Also:
-
withCatalog
Declares the catalog to use when building anIonSystem, returning a new mutable builder if this is immutable.- Parameters:
catalog- the catalog to use in built systems. If null, each system will be built with a newSimpleCatalog.- See Also:
-
isStreamCopyOptimized
public final boolean isStreamCopyOptimized()Indicates whether built systems may attempt to optimizeIonWriter.writeValue(IonReader)by copying raw source data. By default, this property is false.- See Also:
-
setStreamCopyOptimized
public final void setStreamCopyOptimized(boolean optimized) Declares whether built systems 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 systems 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:
-
getReaderBuilder
Gets the reader builder whose options will be used when building anIonSystem. By default,IonReaderBuilder.standard()will be used.- See Also:
-
setReaderBuilder
Sets the reader builder whose options will be used to use when building anIonSystem. The reader builder's catalog will never be used; the catalog provided tosetCatalog(IonCatalog)orwithCatalog(IonCatalog)will always be used instead.- Parameters:
builder- the reader builder to use in built systems. If null, each system will be built withIonReaderBuilder.standard().- Throws:
UnsupportedOperationException- if this is immutable.- See Also:
-
withReaderBuilder
Declares the reader builder whose options will be used to use when building anIonSystem, returning a new mutable builder if this is immutable. The reader builder's catalog will never be used; the catalog provided tosetCatalog(IonCatalog)orwithCatalog(IonCatalog)will always be used instead.- Parameters:
builder- the reader builder to use in built systems. If null, each system will be built withIonReaderBuilder.standard().- See Also:
-
build
Builds a newIonSysteminstance based on this builder's configuration properties.
-