Class _Private_IonWriterBase

java.lang.Object
com.amazon.ion.impl._Private_IonWriterBase
All Implemented Interfaces:
Faceted, _Private_ReaderWriter, IonWriter, Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
_Private_IonBinaryWriterImpl

public abstract class _Private_IonWriterBase extends Object implements IonWriter, _Private_ReaderWriter
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 Details

  • Constructor Details

  • Method Details

    • getDepth

      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 depth of container nesting
    • setSymbolTable

      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 - base symbol table for encoding. Must not be null.
      Throws:
      IllegalArgumentException - if symbols is null or a shared symbol table, or if this writer isn't at top level.
      IOException
    • isFieldNameSet

      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:
      true if a field name has been set false otherwise
    • writeBlob

      public void writeBlob(byte[] value) throws IOException
      Description copied from interface: IonWriter
      write the byte array out as an IonBlob value. This copies the byte array.
      Specified by:
      writeBlob in interface IonWriter
      Parameters:
      value - may be null to represent null.blob.
      Throws:
      IOException
    • writeClob

      public void writeClob(byte[] value) throws IOException
      Description copied from interface: IonWriter
      write the byte array out as an IonClob value. This copies the byte array.
      Specified by:
      writeClob in interface IonWriter
      Parameters:
      value - may be null to represent null.clob.
      Throws:
      IOException
    • writeDecimal

      public abstract void writeDecimal(BigDecimal value) throws IOException
      Description copied from interface: IonWriter
      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.

      Specified by:
      writeDecimal in interface IonWriter
      Parameters:
      value - may be null to represent null.decimal.
      Throws:
      IOException
    • writeFloat

      public void writeFloat(float value) throws IOException
      Throws:
      IOException
    • writeNull

      public void writeNull() throws IOException
      Description copied from interface: IonWriter
      Writes a value of Ion's null type (null aka null.null).
      Specified by:
      writeNull in interface IonWriter
      Throws:
      IOException
    • writeSymbolToken

      public final void writeSymbolToken(SymbolToken tok) throws IOException
      Description copied from interface: IonWriter
      Writes the content of an Ion symbol value.
      Specified by:
      writeSymbolToken in interface IonWriter
      Parameters:
      tok - may be null to represent null.symbol.
      Throws:
      IOException
    • writeTimestampUTC

      public void writeTimestampUTC(Date value) throws IOException
      Description copied from interface: IonWriter
      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).
      Specified by:
      writeTimestampUTC in interface IonWriter
      Parameters:
      value - java.util Date holding the UTC timestamp; may be null to represent null.timestamp.
      Throws:
      IOException
    • writeValue

      @Deprecated public void writeValue(IonValue value) throws IOException
      Deprecated.
      Description copied from interface: IonWriter
      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.

      Specified by:
      writeValue in interface IonWriter
      Parameters:
      value - may be null, in which case this method does nothing.
      Throws:
      IOException
    • writeValues

      public void writeValues(IonReader reader) throws IOException
      Description copied from interface: IonWriter
      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.

      Specified by:
      writeValues in interface IonWriter
      Throws:
      IOException
    • isStreamCopyOptimized

      public boolean isStreamCopyOptimized()
    • writeValue

      public void writeValue(IonReader reader) throws IOException
      Overrides can optimize special cases.
      Specified by:
      writeValue in interface IonWriter
      Throws:
      IOException
    • pop_passed_symbol_table

      public final SymbolTable pop_passed_symbol_table()
      Specified by:
      pop_passed_symbol_table in interface _Private_ReaderWriter
    • asFacet

      public <T> T asFacet(Class<T> facetType)
      Description copied from interface: Faceted
      Returns a facet of this subject if supported.
      Specified by:
      asFacet in interface Faceted
      Type Parameters:
      T - The requested facet type.
      Parameters:
      facetType - The type token of the requested facet type.
      Returns:
      An instance of T representing the facet of the subject, or null if the facet is not supported by the subject.
      See Also: