Top Description Inners Fields Constructors Methods
com.amazon.ion.system

public abstract Class IonTextWriterBuilder

extends IonWriterBuilderBase<IonTextWriterBuilder>
Class Inheritance
Known Direct Subclasses
com.amazon.ion.impl._Private_IonTextWriterBuilder
Static Imports
com.amazon.ion.system.IonWriterBuilder.InitialIvmHandling.SUPPRESS

The builder for creating IonWriters emitting the Ion text syntax.

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.

The most general and correct approach is to use the standard() builder:

    IonWriter w = IonTextWriterBuilder.standard().build(outputStream);
The standard configuration gives a direct representation of what's written, including version markers and local symbol tables. That's good for diagnostics but it may be more than you want in many situations. In such cases the minimal() or pretty() builders (or a combination) may give more satisfying output:
    IonWriter w = IonTextWriterBuilder.minimal()
                                      .withPrettyPrinting()
                                      .build(outputStream);

Configuration properties follow the standard JavaBeans idiom in order to be friendly to dependency injection systems. They also provide alternative with...() mutation methods that enable a more fluid style.

Auto-flushing

IonWriters created by this builder auto-flush to the underlying data sink after writing each top-level value in the context of the writer.

Currently, there is no configuration point available to disable the auto-flushing mechanism. Please vote on issue amazon-ion/ion-java/issues/32 if you require it.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
IonTextWriterBuilder.LstMinimizing

A strategy for minimizing the output of local symbol tables.

public static enum
IonTextWriterBuilder.NewLineType

Represents common new-line separators that are valid in Ion.

Field Summary

Modifier and TypeField and Description
public static final Charset
ASCII

The "US-ASCII" charset.

private Charset
private IonWriterBuilder.InitialIvmHandling
private IonWriterBuilder.IvmMinimizing
private int
private IonTextWriterBuilder.LstMinimizing
private int
private IonTextWriterBuilder.NewLineType
private boolean
public static final Charset
UTF8

The "UTF-8" charset.

Constructor Summary

AccessConstructor and Description
protected
IonTextWriterBuilder()

NOT FOR APPLICATION USE!

protected
IonTextWriterBuilder(IonTextWriterBuilder that)

NOT FOR APPLICATION USE!

Method Summary

Modifier and TypeMethod and Description
public abstract IonWriter

Returns:

a new IonWriter instance; not null.
build
(Appendable
the stream that will receive Ion text data. Must not be null.
out
)

Creates a new writer that will write text to the given output stream.

public abstract IonTextWriterBuilder
copy()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.copy.

Creates a mutable copy of this builder.

public final Charset

Returns:

may be null, denoting the default of UTF-8.
getCharset
()

Gets the charset denoting the output encoding.

public final IonWriterBuilder.InitialIvmHandling

Returns:

the initial IVM strategy. The default value (null) indicates that an initial IVM is emitted if and only if it is received by the writer.
getInitialIvmHandling
()

Implements abstract com.amazon.ion.system.IonWriterBuilder.getInitialIvmHandling.

Gets the strategy for emitting Ion version markers at the start of the stream.

public final IonWriterBuilder.IvmMinimizing

Returns:

the IVM minimizing strategy. The default value (null) indicates that no minimization occurs and IVMs are emitted as received by the writer.
getIvmMinimizing
()

Implements abstract com.amazon.ion.system.IonWriterBuilder.getIvmMinimizing.

Gets the strategy for eliminating Ion version markers mid-stream.

public final int

Returns:

the threshold for printing triple-quoted strings and clobs. Zero means no limit.
getLongStringThreshold
()

Gets the length beyond which string and clob content will be rendered as triple-quoted "long strings".

public final IonTextWriterBuilder.LstMinimizing
getLstMinimizing()

Gets the strategy for reducing or eliminating local symbol tables.

public final int

Returns:

the currently configured maximum.
getMaximumTimestampPrecisionDigits
()

Gets the maximum number of digits of fractional second precision allowed to be written for timestamp values.

public final IonTextWriterBuilder.NewLineType

Returns:

the character sequence to be written between top-level values; null means the default should be used.
getNewLineType
()

Gets the character sequence that will be written as a line separator.

public final boolean

Returns:

value indicating whether standard printing will insert a newline between top-level values
getWriteTopLevelValuesOnNewLines
()

Gets whether each top level value for standard printing should start on a new line.

public abstract IonTextWriterBuilder
immutable()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.immutable.

Returns an immutable builder configured exactly like this one.

public static IonTextWriterBuilder

Returns:

a new, mutable builder instance.
json
()

Creates a builder preconfigured for JSON compatibility.

public static IonTextWriterBuilder

Returns:

a new, mutable builder instance.
minimal
()

Creates a builder configured to minimize system data, eliminating local symbol tables and minimizing version markers.

public abstract IonTextWriterBuilder
mutable()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.mutable.

Returns a mutable builder configured exactly like this one.

public static IonTextWriterBuilder

Returns:

a new, mutable builder instance.
pretty
()

Creates a builder preconfigured for basic pretty-printing.

public void
setCharset(Charset
may be null, denoting the default of UTF-8.
charset
)

Sets the charset denoting the output encoding.

public void
setInitialIvmHandling(IonWriterBuilder.InitialIvmHandling
the initial IVM strategy. Null indicates that explicitly-written IVMs will be emitted.
handling
)

Sets the strategy for emitting Ion version markers at the start of the stream.

public void
setIvmMinimizing(IonWriterBuilder.IvmMinimizing
the IVM minimization strategy. Null indicates that all explicitly-written IVMs will be emitted.
minimizing
)

Sets the strategy for reducing or eliminating non-initial Ion version markers.

public void
setLongStringThreshold(int
the new threshold; zero means none.
threshold
)

Sets the length beyond which string and clob content will be rendered as triple-quoted "long strings".

public void
setLstMinimizing(IonTextWriterBuilder.LstMinimizing
the LST minimization strategy. Null indicates that LSTs will be emitted as received.
minimizing
)

Sets the strategy for reducing or eliminating local symbol tables.

public void
setMaximumTimestampPrecisionDigits(int maximumTimestampPrecisionDigits)

Sets the maximum number of digits of fractional second precision allowed to be written for timestamp values.

public void
setNewLineType(IonTextWriterBuilder.NewLineType
the character sequence to be written between top-level values; null means the default should be used.
newLineType
)

Sets the character sequence that will be written as a line separator.

public void
setWriteTopLevelValuesOnNewLines(boolean
value indicating whether standard printing will insert a newline between top-level values
writeTopLevelValuesOnNewLines
)

Sets whether each top level value for standard printing should start on a new line.

public static IonTextWriterBuilder

Returns:

a new, mutable builder instance.
standard
()

The standard builder of text IonWriters, with all configuration properties having their default values.

public final IonTextWriterBuilder
withCatalog(IonCatalog
the catalog to use in built writers. If null, the writer will be unable to resolve manually-written imports and may throw an exception.
catalog
)

Overrides com.amazon.ion.system.IonWriterBuilderBase.withCatalog.

Declares the catalog to use when building an IonWriter, returning a new mutable builder if this is immutable.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withCharset
(Charset
may be null, denoting the default of UTF-8.
charset
)

Declares the charset denoting the output encoding, returning a new mutable builder if this is immutable.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withCharsetAscii
()

Declares the output encoding to be US-ASCII.

public final IonTextWriterBuilder
withImports(SymbolTable...
a sequence of shared symbol tables. The first (and only the first) may be a system table.
imports
)

Overrides com.amazon.ion.system.IonWriterBuilderBase.withImports.

Declares the imports to use when building an IonWriter, returning a new mutable builder if this is immutable.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withInitialIvmHandling
(IonWriterBuilder.InitialIvmHandling
the initial IVM strategy. Null indicates that explicitly-written IVMs will be emitted.
handling
)

Declares the strategy for emitting Ion version markers at the start of the stream, returning a new mutable builder if this is immutable.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withIvmMinimizing
(IonWriterBuilder.IvmMinimizing
the IVM minimization strategy. Null indicates that all explicitly-written IVMs will be emitted.
minimizing
)

Declares the strategy for reducing or eliminating non-initial Ion version markers, returning a new mutable builder if this is immutable.

public abstract IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withJsonDowngrade
()

Declares that this builder should downgrade the writers' output to JSON compatibility.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withLongStringThreshold
(int
the new threshold; zero means none.
threshold
)

Declares the length beyond which string and clob content will be rendered as triple-quoted "long strings".

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withLstMinimizing
(IonTextWriterBuilder.LstMinimizing
the LST minimization strategy. Null indicates that LSTs will be emitted as received.
minimizing
)

Sets the strategy for reducing or eliminating local symbol tables.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withMaximumTimestampPrecisionDigits
(int maximumTimestampPrecisionDigits)

Sets the maximum number of digits of fractional second precision allowed to be written for timestamp values.

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withMinimalSystemData
()

Declares that this builder should minimize system-level output (Ion version markers and local symbol tables).

public final IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withNewLineType
(IonTextWriterBuilder.NewLineType
the character sequence to be written between top-level values; null means the default should be used.
newLineType
)

Declares the character sequence that will be written as a line separator.

public abstract IonTextWriterBuilder

Returns:

this instance, if mutable; otherwise a mutable copy of this instance.
withPrettyPrinting
()

Declares that this builder should use basic pretty-printing.

public final IonTextWriterBuilder
withWriteTopLevelValuesOnNewLines(boolean
value indicating whether standard printing will insert a newline between top-level values
writeTopLevelValuesOnNewLines
)

Declares whether each top level value for standard printing should start on a new line.

Inherited from com.amazon.ion.system.IonWriterBuilderBase:
getCataloggetImportsmutationChecksetCatalogsetImports

Field Detail

ASCIIback to summary
public static final Charset ASCII

The "US-ASCII" charset.

myCharsetback to summary
private Charset myCharset
myInitialIvmHandlingback to summary
private IonWriterBuilder.InitialIvmHandling myInitialIvmHandling
myIvmMinimizingback to summary
private IonWriterBuilder.IvmMinimizing myIvmMinimizing
myLongStringThresholdback to summary
private int myLongStringThreshold
myLstMinimizingback to summary
private IonTextWriterBuilder.LstMinimizing myLstMinimizing
myMaximumTimestampPrecisionDigitsback to summary
private int myMaximumTimestampPrecisionDigits
myNewLineTypeback to summary
private IonTextWriterBuilder.NewLineType myNewLineType
myTopLevelValuesOnNewLinesback to summary
private boolean myTopLevelValuesOnNewLines
UTF8back to summary
public static final Charset UTF8

The "UTF-8" charset.

Constructor Detail

IonTextWriterBuilderback to summary
protected IonTextWriterBuilder()

NOT FOR APPLICATION USE!

IonTextWriterBuilderback to summary
protected IonTextWriterBuilder(IonTextWriterBuilder that)

NOT FOR APPLICATION USE!

Method Detail

buildback to summary
public abstract IonWriter build(Appendable out)

Creates a new writer that will write text to the given output stream.

If you have an OutputStream, you'll get better performance using build(OutputStream) as opposed to wrapping your stream in an Appendable and calling this method.

Parameters
out:Appendable

the stream that will receive Ion text data. Must not be null.

Returns:IonWriter

a new IonWriter instance; not null.

copyback to summary
public abstract IonTextWriterBuilder copy()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.copy.

Doc from com.amazon.ion.system.IonWriterBuilderBase.copy.

Creates a mutable copy of this builder.

Returns:IonTextWriterBuilder

a new builder with the same configuration as this.

Annotations
@Override
getCharsetback to summary
public final Charset getCharset()

Gets the charset denoting the output encoding. Only ASCII and UTF-8 are supported.

Returns:Charset

may be null, denoting the default of UTF-8.

See Also
setCharset(Charset), withCharset(Charset)
getInitialIvmHandlingback to summary
public final IonWriterBuilder.InitialIvmHandling getInitialIvmHandling()

Implements abstract com.amazon.ion.system.IonWriterBuilder.getInitialIvmHandling.

Doc from com.amazon.ion.system.IonWriterBuilder.getInitialIvmHandling.

Gets 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).

Returns:IonWriterBuilder.InitialIvmHandling

the initial IVM strategy. The default value (null) indicates that an initial IVM is emitted if and only if it is received by the writer.

Annotations
@Override
See Also
setInitialIvmHandling(IonWriterBuilder.InitialIvmHandling), withInitialIvmHandling(IonWriterBuilder.InitialIvmHandling)
getIvmMinimizingback to summary
public final IonWriterBuilder.IvmMinimizing getIvmMinimizing()

Implements abstract com.amazon.ion.system.IonWriterBuilder.getIvmMinimizing.

Doc from com.amazon.ion.system.IonWriterBuilder.getIvmMinimizing.

Gets 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 InitialIvmHandling.

Returns:IonWriterBuilder.IvmMinimizing

the IVM minimizing strategy. The default value (null) indicates that no minimization occurs and IVMs are emitted as received by the writer.

Annotations
@Override
See Also
setIvmMinimizing(IonWriterBuilder.IvmMinimizing), withIvmMinimizing(IonWriterBuilder.IvmMinimizing)
getLongStringThresholdback to summary
public final int getLongStringThreshold()

Gets the length beyond which string and clob content will be rendered as triple-quoted "long strings". At present, such content will only line-break on extant newlines.

Returns:int

the threshold for printing triple-quoted strings and clobs. Zero means no limit.

See Also
setLongStringThreshold(int), withLongStringThreshold(int)
getLstMinimizingback to summary
public final IonTextWriterBuilder.LstMinimizing getLstMinimizing()

Gets the strategy for reducing or eliminating local symbol tables. By default, LST data is emitted as received or when necessary (for example, binary data will always collect and emit local symbols).

See Also
setLstMinimizing(LstMinimizing), withLstMinimizing(LstMinimizing)
getMaximumTimestampPrecisionDigitsback to summary
public final int getMaximumTimestampPrecisionDigits()

Gets the maximum number of digits of fractional second precision allowed to be written for timestamp values.

Returns:int

the currently configured maximum.

See Also
setMaximumTimestampPrecisionDigits(int), withMaximumTimestampPrecisionDigits(int)
getNewLineTypeback to summary
public final IonTextWriterBuilder.NewLineType getNewLineType()

Gets the character sequence that will be written as a line separator. The default is NewLineType#PLATFORM_DEPENDENT

Returns:IonTextWriterBuilder.NewLineType

the character sequence to be written between top-level values; null means the default should be used.

See Also
setNewLineType(NewLineType), withNewLineType(NewLineType)
getWriteTopLevelValuesOnNewLinesback to summary
public final boolean getWriteTopLevelValuesOnNewLines()

Gets whether each top level value for standard printing should start on a new line. The default value is false. When false, the IonTextWriter will insert a single space character (U+0020) between top-level values. When pretty-printing, this setting is ignored; the pretty printer will always start top-level values on a new line.

Returns:boolean

value indicating whether standard printing will insert a newline between top-level values

See Also
setWriteTopLevelValuesOnNewLines(boolean), withWriteTopLevelValuesOnNewLines(boolean)
immutableback to summary
public abstract IonTextWriterBuilder immutable()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.immutable.

Doc from com.amazon.ion.system.IonWriterBuilderBase.immutable.

Returns an immutable builder configured exactly like this one.

Returns:IonTextWriterBuilder

this instance, if immutable; otherwise an immutable copy of this instance.

Annotations
@Override
jsonback to summary
public static IonTextWriterBuilder json()

Creates a builder preconfigured for JSON compatibility.

Returns:IonTextWriterBuilder

a new, mutable builder instance.

See Also
withJsonDowngrade()
minimalback to summary
public static IonTextWriterBuilder minimal()

Creates a builder configured to minimize system data, eliminating local symbol tables and minimizing version markers.

Returns:IonTextWriterBuilder

a new, mutable builder instance.

See Also
withMinimalSystemData()
mutableback to summary
public abstract IonTextWriterBuilder mutable()

Implements abstract com.amazon.ion.system.IonWriterBuilderBase.mutable.

Doc from com.amazon.ion.system.IonWriterBuilderBase.mutable.

Returns a mutable builder configured exactly like this one.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

Annotations
@Override
prettyback to summary
public static IonTextWriterBuilder pretty()

Creates a builder preconfigured for basic pretty-printing.

The specifics of this configuration may change between releases of this library, so automated processes should not depend on the exact output formatting. In particular, there's currently no promise regarding handling of system data.

Returns:IonTextWriterBuilder

a new, mutable builder instance.

See Also
withPrettyPrinting()
setCharsetback to summary
public void setCharset(Charset charset)

Sets the charset denoting the output encoding. Only ASCII and UTF-8 are supported; applications can use the helper constants ASCII and UTF8.

Parameters
charset:Charset

may be null, denoting the default of UTF-8.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getCharset(), withCharset(Charset)
setInitialIvmHandlingback to summary
public void setInitialIvmHandling(IonWriterBuilder.InitialIvmHandling handling)

Sets 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).

Parameters
handling:IonWriterBuilder.InitialIvmHandling

the initial IVM strategy. Null indicates that explicitly-written IVMs will be emitted.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getInitialIvmHandling(), withInitialIvmHandling(IonWriterBuilder.InitialIvmHandling)
setIvmMinimizingback to summary
public void setIvmMinimizing(IonWriterBuilder.IvmMinimizing minimizing)

Sets the strategy for reducing or eliminating non-initial Ion version markers. When null, IVMs are emitted as they are written.

Parameters
minimizing:IonWriterBuilder.IvmMinimizing

the IVM minimization strategy. Null indicates that all explicitly-written IVMs will be emitted.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getIvmMinimizing(), withIvmMinimizing(IonWriterBuilder.IvmMinimizing)
setLongStringThresholdback to summary
public void setLongStringThreshold(int threshold)

Sets the length beyond which string and clob content will be rendered as triple-quoted "long strings". At present, such content will only line-break on extant newlines.

Parameters
threshold:int

the new threshold; zero means none.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getLongStringThreshold(), withLongStringThreshold(int)
setLstMinimizingback to summary
public void setLstMinimizing(IonTextWriterBuilder.LstMinimizing minimizing)

Sets the strategy for reducing or eliminating local symbol tables. By default, LST data is emitted as received or when necessary (for example, binary data will always collect and emit local symbols).

Parameters
minimizing:IonTextWriterBuilder.LstMinimizing

the LST minimization strategy. Null indicates that LSTs will be emitted as received.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getLstMinimizing(), withLstMinimizing(LstMinimizing)
setMaximumTimestampPrecisionDigitsback to summary
public void setMaximumTimestampPrecisionDigits(int maximumTimestampPrecisionDigits)

Sets the maximum number of digits of fractional second precision allowed to be written for timestamp values. Default: Timestamp#DEFAULT_MAXIMUM_DIGITS_TEXT.

See Also
getMaximumTimestampPrecisionDigits(), withMaximumTimestampPrecisionDigits(int)
setNewLineTypeback to summary
public void setNewLineType(IonTextWriterBuilder.NewLineType newLineType)

Sets the character sequence that will be written as a line separator. The default is NewLineType#PLATFORM_DEPENDENT

Parameters
newLineType:IonTextWriterBuilder.NewLineType

the character sequence to be written between top-level values; null means the default should be used.

Exceptions
UnsupportedOperationException:
if this is immutable.
See Also
getNewLineType(), withNewLineType(NewLineType)
setWriteTopLevelValuesOnNewLinesback to summary
public void setWriteTopLevelValuesOnNewLines(boolean writeTopLevelValuesOnNewLines)

Sets whether each top level value for standard printing should start on a new line. The default value is false. When false, the IonTextWriter will insert a single space character (U+0020) between top-level values. When pretty-printing, this setting is ignored; the pretty printer will always start top-level values on a new line.

Parameters
writeTopLevelValuesOnNewLines:boolean

value indicating whether standard printing will insert a newline between top-level values

See Also
getWriteTopLevelValuesOnNewLines(), withWriteTopLevelValuesOnNewLines(boolean)
standardback to summary
public static IonTextWriterBuilder standard()

The standard builder of text IonWriters, with all configuration properties having their default values. The resulting output is a direct representation of what's written to the writer, including version markers and local symbol tables.

Returns:IonTextWriterBuilder

a new, mutable builder instance.

See Also
minimal(), pretty(), json()
withCatalogback to summary
public final IonTextWriterBuilder withCatalog(IonCatalog catalog)

Overrides com.amazon.ion.system.IonWriterBuilderBase.withCatalog.

Doc from com.amazon.ion.system.IonWriterBuilderBase.withCatalog.

Declares the catalog to use when building an IonWriter, returning a new mutable builder if this is immutable.

Parameters
catalog:IonCatalog

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:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

Annotations
@Override
withCharsetback to summary
public final IonTextWriterBuilder withCharset(Charset charset)

Declares the charset denoting the output encoding, returning a new mutable builder if this is immutable. Only ASCII and UTF-8 are supported; applications can use the helper constants ASCII and UTF8.

Parameters
charset:Charset

may be null, denoting the default of UTF-8.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
getCharset(), setCharset(Charset)
withCharsetAsciiback to summary
public final IonTextWriterBuilder withCharsetAscii()

Declares the output encoding to be US-ASCII.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

withImportsback to summary
public final IonTextWriterBuilder withImports(SymbolTable... imports)

Overrides com.amazon.ion.system.IonWriterBuilderBase.withImports.

Doc from com.amazon.ion.system.IonWriterBuilderBase.withImports.

Declares the imports to use when building an IonWriter, 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:SymbolTable[]

a sequence of shared symbol tables. The first (and only the first) may be a system table.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

Annotations
@Override
withInitialIvmHandlingback to summary
public final IonTextWriterBuilder withInitialIvmHandling(IonWriterBuilder.InitialIvmHandling handling)

Declares the strategy for emitting Ion version markers at the start of the stream, returning a new mutable builder if this is immutable. By default, IVMs are emitted only when explicitly written or when necessary (for example, before data that's not Ion 1.0).

Parameters
handling:IonWriterBuilder.InitialIvmHandling

the initial IVM strategy. Null indicates that explicitly-written IVMs will be emitted.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
setInitialIvmHandling(IonWriterBuilder.InitialIvmHandling), withInitialIvmHandling(IonWriterBuilder.InitialIvmHandling)
withIvmMinimizingback to summary
public final IonTextWriterBuilder withIvmMinimizing(IonWriterBuilder.IvmMinimizing minimizing)

Declares the strategy for reducing or eliminating non-initial Ion version markers, returning a new mutable builder if this is immutable. When null, IVMs are emitted as they are written.

Parameters
minimizing:IonWriterBuilder.IvmMinimizing

the IVM minimization strategy. Null indicates that all explicitly-written IVMs will be emitted.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
setIvmMinimizing(IonWriterBuilder.IvmMinimizing), getIvmMinimizing()
withJsonDowngradeback to summary
public abstract IonTextWriterBuilder withJsonDowngrade()

Declares that this builder should downgrade the writers' output to JSON compatibility. This format cannot round-trip back to Ion with full fidelity.

The specific conversions are as follows:

  • System data is suppressed per withMinimalSystemData().
  • All annotations are suppressed.
  • Nulls of any type are printed as JSON null.
  • Blobs are printed as strings, containing Base64.
  • Clobs are printed as strings, containing only Unicode code points U+00 through U+FF.
  • Sexps are printed as lists.
  • Symbols are printed as strings.
  • Timestamps are printed as strings, using Ion timestamp format.
Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

withLongStringThresholdback to summary
public final IonTextWriterBuilder withLongStringThreshold(int threshold)

Declares the length beyond which string and clob content will be rendered as triple-quoted "long strings". At present, such content will only line-break on extant newlines.

Parameters
threshold:int

the new threshold; zero means none.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
getLongStringThreshold(), setLongStringThreshold(int)
withLstMinimizingback to summary
public final IonTextWriterBuilder withLstMinimizing(IonTextWriterBuilder.LstMinimizing minimizing)

Sets the strategy for reducing or eliminating local symbol tables. By default, LST data is emitted as received or when necessary (for example, binary data will always collect and emit local symbols).

Parameters
minimizing:IonTextWriterBuilder.LstMinimizing

the LST minimization strategy. Null indicates that LSTs will be emitted as received.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
getLstMinimizing(), setLstMinimizing(LstMinimizing)
withMaximumTimestampPrecisionDigitsback to summary
public final IonTextWriterBuilder withMaximumTimestampPrecisionDigits(int maximumTimestampPrecisionDigits)

Sets the maximum number of digits of fractional second precision allowed to be written for timestamp values. Default: Timestamp#DEFAULT_MAXIMUM_DIGITS_TEXT.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
getMaximumTimestampPrecisionDigits(), setMaximumTimestampPrecisionDigits(int)
withMinimalSystemDataback to summary
public final IonTextWriterBuilder withMinimalSystemData()

Declares that this builder should minimize system-level output (Ion version markers and local symbol tables).

This is equivalent to:

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

withNewLineTypeback to summary
public final IonTextWriterBuilder withNewLineType(IonTextWriterBuilder.NewLineType newLineType)

Declares the character sequence that will be written as a line separator. The default is NewLineType#PLATFORM_DEPENDENT

Parameters
newLineType:IonTextWriterBuilder.NewLineType

the character sequence to be written between top-level values; null means the default should be used.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

See Also
getNewLineType(), setNewLineType(NewLineType)
withPrettyPrintingback to summary
public abstract IonTextWriterBuilder withPrettyPrinting()

Declares that this builder should use basic pretty-printing. Does not alter the handling of system data. Calling this method alters several other configuration properties, so code should call it first, then make any necessary overrides.

The specifics of this configuration may change between releases of this library, so automated processes should not depend on the exact output formatting.

Returns:IonTextWriterBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

withWriteTopLevelValuesOnNewLinesback to summary
public final IonTextWriterBuilder withWriteTopLevelValuesOnNewLines(boolean writeTopLevelValuesOnNewLines)

Declares whether each top level value for standard printing should start on a new line. The default value is false. When false, the IonTextWriter will insert a single space character (U+0020) between top-level values. When pretty-printing, this setting is ignored; the pretty printer will always start top-level values on a new line.

Parameters
writeTopLevelValuesOnNewLines:boolean

value indicating whether standard printing will insert a newline between top-level values

See Also
getWriteTopLevelValuesOnNewLines(), setWriteTopLevelValuesOnNewLines(boolean)
com.amazon.ion.system back to summary

public final Enum IonTextWriterBuilder.LstMinimizing

extends Enum<IonTextWriterBuilder.LstMinimizing>
Class Inheritance

A strategy for minimizing the output of local symbol tables. By default, no minimization takes place and the writer outputs all data as-is.

Field Summary

Modifier and TypeField and Description
public static final IonTextWriterBuilder.LstMinimizing
EVERYTHING

Discards everything, collapsing the LST to an IVM.

public static final IonTextWriterBuilder.LstMinimizing
LOCALS

Discards local symbols, retains imports.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static IonTextWriterBuilder.LstMinimizing
public static IonTextWriterBuilder.LstMinimizing[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EVERYTHINGback to summary
public static final IonTextWriterBuilder.LstMinimizing EVERYTHING

Discards everything, collapsing the LST to an IVM. If com.amazon.ion.system.IonWriterBuilder.IvmMinimizing is also in effect, then even that IVM may be suppressed.

See Also
IonTextWriterBuilder#setIvmMinimizing(IonWriterBuilder.IvmMinimizing)
LOCALSback to summary
public static final IonTextWriterBuilder.LstMinimizing LOCALS

Discards local symbols, retains imports.

Constructor Detail

LstMinimizingback to summary
private LstMinimizing()

Method Detail

valueOfback to summary
public static IonTextWriterBuilder.LstMinimizing valueOf(String name)
valuesback to summary
public static IonTextWriterBuilder.LstMinimizing[] values()
com.amazon.ion.system back to summary

public final Enum IonTextWriterBuilder.NewLineType

extends Enum<IonTextWriterBuilder.NewLineType>
Class Inheritance

Represents common new-line separators that are valid in Ion. Unicode defines several characters that can represent a new line, but only carriage return (CR) and linefeed (LF) are valid whitespace in Ion. Using other new-line characters (such as NEL) will result in printing invalid Ion.

Field Summary

Modifier and TypeField and Description
private final CharSequence
public static final IonTextWriterBuilder.NewLineType
CRLF

A carriage return and linefeed (U+000D followed by U+000A).

public static final IonTextWriterBuilder.NewLineType
LF

A single linefeed (U+000A).

public static final IonTextWriterBuilder.NewLineType
PLATFORM_DEPENDENT

The new-line separator specified in the "line.separator" system property.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public CharSequence
public static IonTextWriterBuilder.NewLineType
public static IonTextWriterBuilder.NewLineType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

charSequenceback to summary
private final CharSequence charSequence
CRLFback to summary
public static final IonTextWriterBuilder.NewLineType CRLF

A carriage return and linefeed (U+000D followed by U+000A).

LFback to summary
public static final IonTextWriterBuilder.NewLineType LF

A single linefeed (U+000A).

PLATFORM_DEPENDENTback to summary
public static final IonTextWriterBuilder.NewLineType PLATFORM_DEPENDENT

The new-line separator specified in the "line.separator" system property. Using this will result in writing invalid Ion if the platform uses anything other than CR and/or LF as the line separator and the IonTextWriter is configured to use pretty printing or to write each top-level value on a separate line.

Constructor Detail

NewLineTypeback to summary
private NewLineType(CharSequence cs)

Method Detail

getCharSequenceback to summary
public CharSequence getCharSequence()
valueOfback to summary
public static IonTextWriterBuilder.NewLineType valueOf(String name)
valuesback to summary
public static IonTextWriterBuilder.NewLineType[] values()