Top Description Fields Constructors Methods
com.amazon.ion.impl

pack-priv final Class IonWriterSystemTree

extends IonWriterSystem
Class Inheritance
Static Imports
com.amazon.ion.impl._Private_Utils.valueIsLocalSymbolTable

Provides a concrete implementation of the IonWriter where the output of the this writer is one or more IonValues, typically an IonDatagram with contents.

Field Summary

Modifier and TypeField and Description
private final IonCatalog
_catalog

Used to construct new local symtabs.

private IonContainer
_current_parent

The container into which we are currently appending values.

private final ValueFactory
private boolean
private final int
private final LocalSymbolTableAsStruct.Factory
_lst_factory

Factory for constructing local symbol tables.

private IonContainer[]
private int
Inherited from com.amazon.ion.impl.IonWriterSystem:
_default_system_symbol_table

Constructor Summary

AccessConstructor and Description
protected
IonWriterSystemTree(SymbolTable
must not be null.
defaultSystemSymbolTable
,
IonCatalog
may be null.
catalog
,
IonContainer
must not be null.
rootContainer
,
IonWriterBuilder.InitialIvmHandling initialIvmHandling)

Method Summary

Modifier and TypeMethod and Description
private void
public void
close()

Implements com.amazon.ion.IonWriter.close.

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

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.

protected IonValue
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 final SymbolTable
inject_local_symbol_table()

Overrides com.amazon.ion.impl.IonWriterSystem.inject_local_symbol_table.

Builds a new local symbol table from the current contextual symtab (a system symtab).

public boolean
isInStruct()

Implements com.amazon.ion.IonWriter.isInStruct.

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

private void
private void
pushParent(IonContainer
must not be null.
newParent
)

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.

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.

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(int value)

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(IonType
type of the null to be written
type
)

Implements com.amazon.ion.IonWriter.writeNull.

Writes a null value of a specified Ion type.

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.

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_symboladdTypeAnnotationannotationCountasFacetassumeFieldNameSymbolassumeKnownSymbolclearAnnotationsclearFieldNameendValueensureAnnotationCapacityfindAnnotationfinishgetDefaultSystemSymtabgetFieldIdgetSymbolTablegetTypeAnnotationIdsgetTypeAnnotationsgetTypeAnnotationSymbolshasAnnotationsinternAnnotationsAndGetSidsisFieldNameSetsetFieldNamesetFieldNameSymbolsetSymbolTablesetTypeAnnotationssetTypeAnnotationSymbolsshouldWriteIvmstartValuewriteIonVersionMarkerwriteIonVersionMarkerwriteSymbolwriteSymbol

Field Detail

_catalogback to summary
private final IonCatalog _catalog

Used to construct new local symtabs. May be null

_current_parentback to summary
private IonContainer _current_parent

The container into which we are currently appending values. Never null.

_factoryback to summary
private final ValueFactory _factory
_in_structback to summary
private boolean _in_struct
_initialDepthback to summary
private final int _initialDepth
_lst_factoryback to summary
private final LocalSymbolTableAsStruct.Factory _lst_factory

Factory for constructing local symbol tables. Not null.

_parent_stackback to summary
private IonContainer[] _parent_stack
_parent_stack_topback to summary
private int _parent_stack_top

Constructor Detail

IonWriterSystemTreeback to summary
protected IonWriterSystemTree(SymbolTable defaultSystemSymbolTable, IonCatalog catalog, IonContainer rootContainer, IonWriterBuilder.InitialIvmHandling initialIvmHandling)
Parameters
defaultSystemSymbolTable:SymbolTable

must not be null.

catalog:IonCatalog

may be null.

rootContainer:IonContainer

must not be null.

Method Detail

appendback to summary
private void append(IonValue value)
closeback to summary
public void close()

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.

flushback to summary
public void flush()

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.

get_rootback to summary
protected IonValue get_root()
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
inject_local_symbol_tableback to summary
pack-priv final SymbolTable inject_local_symbol_table() throws IOException

Overrides com.amazon.ion.impl.IonWriterSystem.inject_local_symbol_table.

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

Builds a new local symbol table from the current contextual symtab (a system symtab).

Returns:SymbolTable

not null.

Annotations
@Override
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.

popParentback to summary
private void popParent()
pushParentback to summary
private void pushParent(IonContainer newParent)
Parameters
newParent:IonContainer

must not be null.

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

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
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(int value) throws IOException
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(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

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)

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)

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