Top Fields Constructors Methods
com.amazon.ion.impl

pack-priv Class IonWriterSystemText

extends IonWriterSystem
Class Inheritance
Known Direct Subclasses
com.amazon.ion.impl.IonWriterSystemTextMarkup
Static Imports
com.amazon.ion.SystemSymbols.SYMBOLS, com.amazon.ion.impl._Private_IonConstants.tidList, ._Private_IonConstants.tidSexp, ._Private_IonConstants.tidStruct

Field Summary

Modifier and TypeField and Description
private boolean
_closed

Ensure we don't use a closed output stream.

private boolean
_following_long_string

True when the last data written was a triple-quoted string, meaning we cannot write another long string lest it be incorrectly concatenated.

pack-priv boolean
_in_struct

True when the current container is a struct, so we write field names.

private boolean
_is_writing_ivm

Indicates whether we're currently writing an IVM.

private final int
private final _Private_IonTextWriterBuilder
_options

Not null.

private final _Private_IonTextAppender
pack-priv boolean
pack-priv CharSequence
pack-priv int[]
pack-priv boolean[]
pack-priv int
Inherited from com.amazon.ion.impl.IonWriterSystem:
_default_system_symbol_table

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements com.amazon.ion.IonWriter.close.

Closes this stream and releases any system resources associated with it.

pack-priv void
closeCollection(char closeChar)

pack-priv void
private boolean
public void
flush()

Implements com.amazon.ion.IonWriter.flush.

Flushes this writer by writing any buffered output to the underlying output target without finalizing the stream's local symbol table.

pack-priv _Private_IonTextWriterBuilder
protected IonType
public int
getDepth()

Implements abstract com.amazon.ion.impl._Private_IonWriterBase.getDepth.

Returns the current depth of containers the writer is at.

pack-priv void
public boolean
isInStruct()

Implements com.amazon.ion.IonWriter.isInStruct.

Determines whether values are being written as fields of a struct.

pack-priv int
pop()

pack-priv void
pack-priv void
push(int typeid)

pack-priv void
public void
stepIn(IonType containerType)

Implements com.amazon.ion.IonWriter.stepIn.

Writes the beginning of a non-null container (list, sexp, or struct).

public void
stepOut()

Implements com.amazon.ion.IonWriter.stepOut.

Writes the end of the current container, returning this writer to the context of parent container.

pack-priv boolean
pack-priv int

Returns:

a tid
topType
()

pack-priv void
pack-priv void
public void
writeBlob(byte[]
bytes to be written. May be null to represent null.blob.
value
,
int
offset of the first byte in value to write
start
,
int
number of bytes to write from value
len
)

Implements com.amazon.ion.IonWriter.writeBlob.

Writes a portion of the byte array out as an IonBlob value.

public void
writeBool(boolean
true or false as desired
value
)

Implements com.amazon.ion.IonWriter.writeBool.

writes a non-null boolean value (true or false) as an IonBool to output.

public void
writeClob(byte[]
bytes to be written. May be null to represent null.clob.
value
,
int
offset of the first byte in value to write
start
,
int
number of bytes to write from value
len
)

Implements com.amazon.ion.IonWriter.writeClob.

Writes a portion of the byte array out as an IonClob value.

public void
writeDecimal(BigDecimal
may be null to represent null.decimal.
value
)

Implements abstract com.amazon.ion.impl._Private_IonWriterBase.writeDecimal.

Implements com.amazon.ion.IonWriter.writeDecimal.

Writes a BigDecimal value as an Ion decimal.

pack-priv void
public void
writeFloat(double
double to write
value
)

Implements com.amazon.ion.IonWriter.writeFloat.

writes a 64 bit binary floating point value, a Java double, as an IonFloat.

public void
writeInt(long
signed int to write
value
)

Implements com.amazon.ion.IonWriter.writeInt.

writes a signed 64 bit value, a Java long, as an IonInt.

public void
writeInt(BigInteger
BigInteger to write
value
)

Implements com.amazon.ion.IonWriter.writeInt.

writes a BigInteger value as an IonInt.

pack-priv void
writeIonVersionMarkerAsIs(SymbolTable systemSymtab)

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeIonVersionMarkerAsIs.

Writes an IVM without checking preconditions or InitialIVMHandling.

pack-priv void
public void
writeNull()

Overrides com.amazon.ion.impl._Private_IonWriterBase.writeNull.

Implements com.amazon.ion.IonWriter.writeNull.

Writes a value of Ion's null type (null aka null.null).

public void
writeNull(IonType
type of the null to be written
type
)

Implements com.amazon.ion.IonWriter.writeNull.

Writes a null value of a specified Ion type.

pack-priv boolean
writeSeparator(boolean followingLongString)

private void
writeSidLiteral(int sid)

public void
writeString(String
may be null to represent null.string.
value
)

Implements com.amazon.ion.IonWriter.writeString.

Writes a java.lang.String as an Ion string.

pack-priv void
writeSymbolAsIs(int symbolId)

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Writes a symbol without checking for system ID.

public void
writeSymbolAsIs(String value)

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Writes a symbol without checking for system ID.

private void
writeSymbolToken(String
must not be null.
value
)

public void
writeTimestamp(Timestamp
may be null to represent null.timestamp.
value
)

Implements com.amazon.ion.IonWriter.writeTimestamp.

Writes a timestamp value.

Inherited from com.amazon.ion.impl.IonWriterSystem:
add_symboladdTypeAnnotationannotationCountasFacetassumeFieldNameSymbolassumeKnownSymbolclearAnnotationsclearFieldNameendValueensureAnnotationCapacityfindAnnotationfinishgetDefaultSystemSymtabgetFieldIdgetSymbolTablegetTypeAnnotationIdsgetTypeAnnotationsgetTypeAnnotationSymbolshasAnnotationsinject_local_symbol_tableinternAnnotationsAndGetSidsisFieldNameSetsetFieldNamesetFieldNameSymbolsetSymbolTablesetTypeAnnotationssetTypeAnnotationSymbolsshouldWriteIvmwriteIonVersionMarkerwriteIonVersionMarkerwriteSymbolwriteSymbol

Field Detail

_closedback to summary
private boolean _closed

Ensure we don't use a closed output stream.

_following_long_stringback to summary
private boolean _following_long_string

True when the last data written was a triple-quoted string, meaning we cannot write another long string lest it be incorrectly concatenated.

_in_structback to summary
pack-priv boolean _in_struct

True when the current container is a struct, so we write field names.

_is_writing_ivmback to summary
private boolean _is_writing_ivm

Indicates whether we're currently writing an IVM.

_long_string_thresholdback to summary
private final int _long_string_threshold

At least one.

_optionsback to summary
private final _Private_IonTextWriterBuilder _options

Not null.

_outputback to summary
private final _Private_IonTextAppender _output
_pending_separatorback to summary
pack-priv boolean _pending_separator
_separator_characterback to summary
pack-priv CharSequence _separator_character
_stack_parent_typeback to summary
pack-priv int[] _stack_parent_type
_stack_pending_commaback to summary
pack-priv boolean[] _stack_pending_comma
_topback to summary
pack-priv int _top

Constructor Detail

IonWriterSystemTextback to summary
protected IonWriterSystemText(SymbolTable defaultSystemSymtab, _Private_IonTextWriterBuilder options, _Private_FastAppendable out)
Exceptions
NullPointerException:
if any parameter is null.

Method Detail

closeback to summary
public void close() throws IOException

Implements com.amazon.ion.IonWriter.close.

Doc from com.amazon.ion.IonWriter.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

If the cursor is between top-level values, this method will finish() before closing the underlying output stream. If not, the resulting data may be incomplete and invalid Ion.

In other words: unless you're recovering from a failure condition, don't close the writer until you've stepped-out back to the starting level.

Exceptions
IOException:
if thrown by the underlying output target.
closeCollectionback to summary
pack-priv void closeCollection(char closeChar) throws IOException
closeValueback to summary
pack-priv void closeValue() throws IOException
containerIsSexpback to summary
private boolean containerIsSexp()
flushback to summary
public void flush() throws IOException

Implements com.amazon.ion.IonWriter.flush.

Doc from com.amazon.ion.IonWriter.flush.

Flushes this writer by writing any buffered output to the underlying output target without finalizing the stream's local symbol table.

For some implementations this may have no effect even when some data is buffered, because it's not always possible to fully write partial data. In particular, when writing binary Ion data, Ion's length-prefixed encoding requires a complete top-level value to be written at once.

If localSymbolTableAppend is enabled (see com.amazon.ion.system.IonBinaryWriterBuilder#withLocalSymbolTableAppendEnabled), this feature can be used to flush buffered data before writing more values without subsequently having to redeclare the current local symbol table. Applications that produce long streams of binary Ion may wish to flush occasionally to relieve memory pressure, then continue writing data using the same local symbol table. The symbol table will be appended with newly-encountered symbols as necessary.

The OutputStream spec is mum regarding the behavior of flush on a closed stream, so we shouldn't assume that our stream can handle that.

Exceptions
IOException:
if thrown by the underlying output target.
getBuilderback to summary
pack-priv _Private_IonTextWriterBuilder getBuilder()
getContainerback to summary
protected IonType getContainer()
getDepthback to summary
public int getDepth()

Implements abstract com.amazon.ion.impl._Private_IonWriterBase.getDepth.

Doc from com.amazon.ion.impl._Private_IonWriterBase.getDepth.

Returns the current depth of containers the writer is at. This is 0 if the writer is at top-level.

Returns:int

int depth of container nesting

Annotations
@Override
growStackback to summary
pack-priv void growStack()
isInStructback to summary
public boolean isInStruct()

Implements com.amazon.ion.IonWriter.isInStruct.

Doc from com.amazon.ion.IonWriter.isInStruct.

Determines whether values are being written as fields of a struct. This is especially useful when it is not clear whether field names need to be written or not.

Returns:boolean

true when the parent is a struct.

popback to summary
pack-priv int pop()
printLeadingWhiteSpaceback to summary
pack-priv void printLeadingWhiteSpace() throws IOException
pushback to summary
pack-priv void push(int typeid)
startValueback to summary
pack-priv void startValue() throws IOException

Overrides com.amazon.ion.impl.IonWriterSystem.startValue.

Annotations
@Override
stepInback to summary
public void stepIn(IonType containerType) throws IOException

Implements com.amazon.ion.IonWriter.stepIn.

Doc from com.amazon.ion.IonWriter.stepIn.

Writes the beginning of a non-null container (list, sexp, or struct). This must be matched by a call to stepOut() after the last child value.

This method is not used to write null.list et al. To write null values use writeNull(IonType).

Parameters
containerType:IonType

must be one of IonType#LIST, IonType#SEXP, or IonType#STRUCT.

stepOutback to summary
public void stepOut() throws IOException

Implements com.amazon.ion.IonWriter.stepOut.

Doc from com.amazon.ion.IonWriter.stepOut.

Writes the end of the current container, returning this writer to the context of parent container. Invocation of this method must match a preceding call to stepIn(IonType).

topPendingCommaback to summary
pack-priv boolean topPendingComma()
topTypeback to summary
pack-priv int topType()
Returns:int

a tid

Exceptions
ArrayIndexOutOfBoundsException:
if _top < 1
writeAnnotationsback to summary
pack-priv void writeAnnotations(SymbolToken[] annotations) throws IOException
writeAnnotationTokenback to summary
pack-priv void writeAnnotationToken(SymbolToken ann) throws IOException
writeBlobback to summary
public void writeBlob(byte[] value, int start, int len) throws IOException

Implements com.amazon.ion.IonWriter.writeBlob.

Doc from com.amazon.ion.IonWriter.writeBlob.

Writes a portion of the byte array out as an IonBlob value. This copies the portion of the byte array that is written.

Parameters
value:byte[]

bytes to be written. May be null to represent null.blob.

start:int

offset of the first byte in value to write

len:int

number of bytes to write from value

writeBoolback to summary
public void writeBool(boolean value) throws IOException

Implements com.amazon.ion.IonWriter.writeBool.

Doc from com.amazon.ion.IonWriter.writeBool.

writes a non-null boolean value (true or false) as an IonBool to output.

Parameters
value:boolean

true or false as desired

writeClobback to summary
public void writeClob(byte[] value, int start, int len) throws IOException

Implements com.amazon.ion.IonWriter.writeClob.

Doc from com.amazon.ion.IonWriter.writeClob.

Writes a portion of the byte array out as an IonClob value. This copies the porition of the byte array that is written.

Parameters
value:byte[]

bytes to be written. May be null to represent null.clob.

start:int

offset of the first byte in value to write

len:int

number of bytes to write from value

writeDecimalback to summary
public void writeDecimal(BigDecimal value) throws IOException

Implements abstract com.amazon.ion.impl._Private_IonWriterBase.writeDecimal.

Implements com.amazon.ion.IonWriter.writeDecimal.

Doc from com.amazon.ion.IonWriter.writeDecimal.

Writes a BigDecimal value as an Ion decimal. Ion uses an arbitrarily long sign/value and an arbitrarily long signed exponent to write the value. This preserves all of the BigDecimal digits, the number of significant digits.

To write a negative zero value, pass this method a Decimal instance.

Parameters
value:BigDecimal

may be null to represent null.decimal.

Annotations
@Override
writeFieldNameTokenback to summary
pack-priv void writeFieldNameToken(SymbolToken sym) throws IOException
writeFloatback to summary
public void writeFloat(double value) throws IOException

Implements com.amazon.ion.IonWriter.writeFloat.

Doc from com.amazon.ion.IonWriter.writeFloat.

writes a 64 bit binary floating point value, a Java double, as an IonFloat. Currently IonFloat values are output as 64 bit IEEE 754 big endian values. IonFloat preserves all valid floating point values, including -0.0, Nan and +/-infinity. It does not guarantee preservation of -Nan or other less less "common" values.

Parameters
value:double

double to write

writeIntback to summary
public void writeInt(long value) throws IOException

Implements com.amazon.ion.IonWriter.writeInt.

Doc from com.amazon.ion.IonWriter.writeInt.

writes a signed 64 bit value, a Java long, as an IonInt.

Parameters
value:long

signed int to write

writeIntback to summary
public void writeInt(BigInteger value) throws IOException

Implements com.amazon.ion.IonWriter.writeInt.

Doc from com.amazon.ion.IonWriter.writeInt.

writes a BigInteger value as an IonInt. If the BigInteger value is null this writes a null int.

Parameters
value:BigInteger

BigInteger to write

writeIonVersionMarkerAsIsback to summary
pack-priv void writeIonVersionMarkerAsIs(SymbolTable systemSymtab) throws IOException

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeIonVersionMarkerAsIs.

Doc from com.amazon.ion.impl.IonWriterSystem.writeIonVersionMarkerAsIs.

Writes an IVM without checking preconditions or InitialIVMHandling.

Annotations
@Override
writeLocalSymtabback to summary
pack-priv void writeLocalSymtab(SymbolTable symtab) throws IOException

Overrides com.amazon.ion.impl.IonWriterSystem.writeLocalSymtab.

Annotations
@Override
writeNullback to summary
public void writeNull() throws IOException

Overrides com.amazon.ion.impl._Private_IonWriterBase.writeNull.

Implements com.amazon.ion.IonWriter.writeNull.

Doc from com.amazon.ion.IonWriter.writeNull.

Writes a value of Ion's null type (null aka null.null).

Annotations
@Override
writeNullback to summary
public void writeNull(IonType type) throws IOException

Implements com.amazon.ion.IonWriter.writeNull.

Doc from com.amazon.ion.IonWriter.writeNull.

Writes a null value of a specified Ion type.

Parameters
type:IonType

type of the null to be written

writeSeparatorback to summary
pack-priv boolean writeSeparator(boolean followingLongString) throws IOException
writeSidLiteralback to summary
private void writeSidLiteral(int sid) throws IOException
writeStringback to summary
public void writeString(String value) throws IOException

Implements com.amazon.ion.IonWriter.writeString.

Doc from com.amazon.ion.IonWriter.writeString.

Writes a java.lang.String as an Ion string. Since Ion strings are UTF-8 and Java Strings are Unicode 16. As such the resulting lengths may not match. In addition some Java strings are not valid as they may contain only one of the two needed surrogate code units necessary to define the Unicode code point to be output, an exception will be raised if this case is encountered.

Parameters
value:String

may be null to represent null.string.

writeSymbolAsIsback to summary
pack-priv void writeSymbolAsIs(int symbolId) throws IOException

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Doc from com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Writes a symbol without checking for system ID.

Annotations
@Override
writeSymbolAsIsback to summary
public void writeSymbolAsIs(String value) throws IOException

Implements abstract com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Doc from com.amazon.ion.impl.IonWriterSystem.writeSymbolAsIs.

Writes a symbol without checking for system ID.

Annotations
@Override
writeSymbolTokenback to summary
private void writeSymbolToken(String value) throws IOException
Parameters
value:String

must not be null.

writeTimestampback to summary
public void writeTimestamp(Timestamp value) throws IOException

Implements com.amazon.ion.IonWriter.writeTimestamp.

Doc from com.amazon.ion.IonWriter.writeTimestamp.

Writes a timestamp value.

Parameters
value:Timestamp

may be null to represent null.timestamp.