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

public abstract Class _Private_IonWriterBase

extends Object
implements IonWriter, _Private_ReaderWriter
Class Inheritance
All Implemented Interfaces
com.amazon.ion.impl._Private_ReaderWriter, com.amazon.ion.IonWriter, com.amazon.ion.facet.Faceted, java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
com.amazon.ion.impl.IonWriterSystem, com.amazon.ion.impl.IonWriterUser
Imports
com.amazon.ion.IonReader, .IonType, .IonValue, .IonWriter, .SymbolTable, .SymbolToken, .Timestamp, .UnknownSymbolException, java.io.IOException, java.math.BigDecimal, java.util.Date

NOT FOR APPLICATION USE!

Base type for Ion writers. This handles the writeIonEvents and provides default handlers for the list forms of write. This also resolves symbols if a symbol table is available (which it will not be if the underlying writer is a system writer).

Field Summary

Modifier and TypeField and Description
private SymbolTable[]
private int
pack-priv static final String
protected static final String
private final boolean

Constructor Summary

AccessConstructor and Description
public
_Private_IonWriterBase(boolean
true if SID validation should be performed; otherwise, false. See _Private_IonTextWriterBuilder#withInvalidSidsAllowed(boolean)
requireSymbolValidation
)

Method Summary

Modifier and TypeMethod and Description
public <T> T
asFacet(Class<T>
The type token of the requested facet type.
facetType
)

Implements com.amazon.ion.facet.Faceted.asFacet.

Returns a facet of this subject if supported.

pack-priv abstract String

Returns:

not null.
assumeKnownSymbol
(int sid)

Translates a symbol using the current symtab.

private void
pack-priv abstract int

Returns:

the index or -1.
findAnnotation
(String
the annotation to find.
name
)

Returns the given annotation's index in the value's annotations list, or -1 if not present.

protected abstract int

Returns:

int depth of container nesting
getDepth
()

Returns the current depth of containers the writer is at.

pack-priv abstract int[]

Returns:

pending type annotations as symbol ID ints, null if the annotations cannot be expressed as IDs.
getTypeAnnotationIds
()

Gets the current list of pending annotations.

pack-priv abstract String[]

Returns:

pending type annotations as strings, null if the annotations cannot be expressed as strings.
getTypeAnnotations
()

Gets the current list of pending annotations.

public abstract boolean

Returns:

true if a field name has been set false otherwise
isFieldNameSet
()

Returns true if the field name has been set either through setFieldName or setFieldId.

public boolean
public final SymbolTable
private void
public abstract void
setSymbolTable(SymbolTable
base symbol table for encoding. Must not be null.
symbols
)

Sets the symbol table to use for encoding to be the passed in symbol table.

private final void
pack-priv final void
private final void
private final void
public void
writeBlob(byte[]
may be null to represent null.blob.
value
)

Implements com.amazon.ion.IonWriter.writeBlob.

write the byte array out as an IonBlob value.

public void
writeClob(byte[]
may be null to represent null.clob.
value
)

Implements com.amazon.ion.IonWriter.writeClob.

write the byte array out as an IonClob value.

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

Redeclares com.amazon.ion.IonWriter.writeDecimal.

Writes a BigDecimal value as an Ion decimal.

public void
writeFloat(float value)

pack-priv abstract void
writeIonVersionMarker()

Write an Ion version marker symbol to the output.

public void
writeNull()

Implements com.amazon.ion.IonWriter.writeNull.

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

pack-priv abstract void
writeSymbol(int
symbol table id to write
symbolId
)

Write symbolId out as an IonSymbol value.

public final void
writeSymbolToken(SymbolToken
may be null to represent null.symbol.
tok
)

Implements com.amazon.ion.IonWriter.writeSymbolToken.

Writes the content of an Ion symbol value.

public void
writeTimestampUTC(Date
java.util Date holding the UTC timestamp; may be null to represent null.timestamp.
value
)

Implements com.amazon.ion.IonWriter.writeTimestampUTC.

writes the passed in Date (in milliseconds since the epoch) as an IonTimestamp.

public void
writeValue(IonValue
may be null, in which case this method does nothing.
value
)

Implements com.amazon.ion.IonWriter.writeValue.

Deprecated

writes the contents of the passed in Ion value to the output.

public void
writeValue(IonReader reader)

Implements com.amazon.ion.IonWriter.writeValue.

Overrides can optimize special cases.

pack-priv final void
writeValueRecursively(IonReader
The IonReader that will provide a value to write.
reader
)

Writes the provided IonReader's current value including any annotations.

public void
writeValues(IonReader reader)

Implements com.amazon.ion.IonWriter.writeValues.

Writes a reader's current value, and all following values until the end of the current container.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_symbol_table_stackback to summary
private SymbolTable[] _symbol_table_stack
_symbol_table_topback to summary
private int _symbol_table_top
ERROR_FINISH_NOT_AT_TOP_LEVELback to summary
pack-priv static final String ERROR_FINISH_NOT_AT_TOP_LEVEL
ERROR_MISSING_FIELD_NAMEback to summary
protected static final String ERROR_MISSING_FIELD_NAME
requireSymbolValidationback to summary
private final boolean requireSymbolValidation

Constructor Detail

_Private_IonWriterBaseback to summary
public _Private_IonWriterBase(boolean requireSymbolValidation)
Parameters
requireSymbolValidation:boolean

true if SID validation should be performed; otherwise, false. See _Private_IonTextWriterBuilder#withInvalidSidsAllowed(boolean)

Method Detail

asFacetback to summary
public <T> T asFacet(Class<T> facetType)

Implements com.amazon.ion.facet.Faceted.asFacet.

Doc from com.amazon.ion.facet.Faceted.asFacet.

Returns a facet of this subject if supported.

Parameters
<T>
The requested facet type.
facetType:Class<T>

The type token of the requested facet type.

Returns:T

An instance of T representing the facet of the subject, or null if the facet is not supported by the subject.

assumeKnownSymbolback to summary
pack-priv abstract String assumeKnownSymbol(int sid)

Translates a symbol using the current symtab.

Returns:String

not null.

Exceptions
UnknownSymbolException:
if the text is unknown.
See Also
SymbolTable#findKnownSymbol(int)
clear_system_value_stackback to summary
private void clear_system_value_stack()
findAnnotationback to summary
pack-priv abstract int findAnnotation(String name)

Returns the given annotation's index in the value's annotations list, or -1 if not present.

Parameters
name:String

the annotation to find.

Returns:int

the index or -1.

getDepthback to summary
protected abstract int 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

getTypeAnnotationIdsback to summary
pack-priv abstract int[] getTypeAnnotationIds()

Gets the current list of pending annotations. This is the contents of the current annotations array of this writer.

If the annotations were set as string they will be converted to symbol IDs (ints) if a symbol table is available. In the event a symbol table is not available a null array will be returned. If no annotations are set a 0 length array will be returned.

Returns:int[]

pending type annotations as symbol ID ints, null if the annotations cannot be expressed as IDs.

getTypeAnnotationsback to summary
pack-priv abstract String[] getTypeAnnotations()

Gets the current list of pending annotations. This is the contents of the current annotations array of this writer.

If the annotations were set as IDs they will be converted if a symbol table is available. In the event a symbol table is not available a null array will be returned. If no annotations are set a 0 length array will be returned.

Returns:String[]

pending type annotations as strings, null if the annotations cannot be expressed as strings.

isFieldNameSetback to summary
public abstract boolean isFieldNameSet()

Returns true if the field name has been set either through setFieldName or setFieldId. This is generally more efficient than calling getFieldName or getFieldId and checking the return type as it does not need to resolve the name through a symbol table. This returns false if the field name has not been set.

Returns:boolean

true if a field name has been set false otherwise

isStreamCopyOptimizedback to summary
public boolean isStreamCopyOptimized()
pop_passed_symbol_tableback to summary
public final SymbolTable pop_passed_symbol_table()

Implements com.amazon.ion.impl._Private_ReaderWriter.pop_passed_symbol_table.

push_symbol_tableback to summary
private void push_symbol_table(SymbolTable symbols)
setSymbolTableback to summary
public abstract void setSymbolTable(SymbolTable symbols) throws IOException

Sets the symbol table to use for encoding to be the passed in symbol table. The can only be done between top-level values. As symbols are written this symbol table is used to resolve them. If the symbols are undefined this symbol table is updated to include them as local symbols. The updated symbol table will be written before any of the local values are emitted.

If the symbol table is the system symbol table an Ion version marker will be written to the output. If symbols not in the system symbol table are written a local symbol table will be created and written before the current top level value.

Parameters
symbols:SymbolTable

base symbol table for encoding. Must not be null.

Exceptions
IllegalArgumentException:
if symbols is null or a shared symbol table, or if this writer isn't at top level.
transfer_symbol_tablesback to summary
private final void transfer_symbol_tables(_Private_ReaderWriter reader) throws IOException
validateSymbolIdback to summary
pack-priv final void validateSymbolId(int sid)
write_value_annotations_helperback to summary
private final void write_value_annotations_helper(IonReader reader)
write_value_field_name_helperback to summary
private final void write_value_field_name_helper(IonReader reader)
Exceptions
UnknownSymbolException:
if the text of the field name is unknown.
writeBlobback to summary
public void writeBlob(byte[] value) throws IOException

Implements com.amazon.ion.IonWriter.writeBlob.

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

write the byte array out as an IonBlob value. This copies the byte array.

Parameters
value:byte[]

may be null to represent null.blob.

writeClobback to summary
public void writeClob(byte[] value) throws IOException

Implements com.amazon.ion.IonWriter.writeClob.

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

write the byte array out as an IonClob value. This copies the byte array.

Parameters
value:byte[]

may be null to represent null.clob.

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

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

writeFloatback to summary
public void writeFloat(float value) throws IOException
writeIonVersionMarkerback to summary
pack-priv abstract void writeIonVersionMarker() throws IOException

Write an Ion version marker symbol to the output. This is the $ion_1_0 value currently (in later versions the number may change). In text output this appears as the text symbol. In binary this will be the symbol id if the writer is in a list, sexp or struct. If the writer is currently at the top level this will write the "magic cookie" value. Writing a version marker will reset the symbol table to be the system symbol table.

writeNullback to summary
public void writeNull() throws IOException

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

writeSymbolback to summary
pack-priv abstract void writeSymbol(int symbolId) throws IOException

Write symbolId out as an IonSymbol value. The value must be valid in the symbol table.

Parameters
symbolId:int

symbol table id to write

writeSymbolTokenback to summary
public final void writeSymbolToken(SymbolToken tok) throws IOException

Implements com.amazon.ion.IonWriter.writeSymbolToken.

Doc from com.amazon.ion.IonWriter.writeSymbolToken.

Writes the content of an Ion symbol value.

Parameters
tok:SymbolToken

may be null to represent null.symbol.

writeTimestampUTCback to summary
public void writeTimestampUTC(Date value) throws IOException

Implements com.amazon.ion.IonWriter.writeTimestampUTC.

Doc from com.amazon.ion.IonWriter.writeTimestampUTC.

writes the passed in Date (in milliseconds since the epoch) as an IonTimestamp. The Date value is treated as a UTC value with an unknown timezone offset (a z value).

Parameters
value:Date

java.util Date holding the UTC timestamp; may be null to represent null.timestamp.

writeValueback to summary
public void writeValue(IonValue value) throws IOException

Implements com.amazon.ion.IonWriter.writeValue.

Doc from com.amazon.ion.IonWriter.writeValue.

Deprecated

writes the contents of the passed in Ion value to the output.

This method also writes annotations and field names (if in a struct), and performs a deep write, including the contents of any containers encountered.

Parameters
value:IonValue

may be null, in which case this method does nothing.

Annotations
@Deprecated
writeValueback to summary
public void writeValue(IonReader reader) throws IOException

Implements com.amazon.ion.IonWriter.writeValue.

Overrides can optimize special cases.

writeValueRecursivelyback to summary
pack-priv final void writeValueRecursively(IonReader reader) throws IOException

Writes the provided IonReader's current value including any annotations. This function will not advance the IonReader beyond the end of the current value; users wishing to continue using the IonReader at the current depth will need to call IonReader#next() again. - If the IonReader is not positioned over a value (for example: because it is at the beginning or end of a stream), then this function does nothing. - If the current value is a container, this function will visit all of its child values and write those too, advancing the IonReader to the end of the container in the process. - If both this writer and the IonReader are in a struct, the writer will write the current value's field name. - If the writer is not in a struct but the reader is, the writer will ignore the current value's field name. - If the writer is in a struct but the IonReader is not, this function throws an IllegalStateException.

Parameters
reader:IonReader

The IonReader that will provide a value to write.

Exceptions
IOException:
if either the provided IonReader or this writer's underlying OutputStream throw an IOException.
IllegalStateException:
if this writer is inside a struct but the IonReader is not.
writeValuesback to summary
public void writeValues(IonReader reader) throws IOException

Implements com.amazon.ion.IonWriter.writeValues.

Doc from com.amazon.ion.IonWriter.writeValues.

Writes a reader's current value, and all following values until the end of the current container. If there's no current value then this method calls IonReader#next() to get going.

This method iterates until IonReader#next() returns null and does not step out to the container of the current cursor position.

This method also writes annotations and field names (if in a struct), and performs a deep write, including the contents of any containers encountered.