Class _Private_IonWriterBase

  • All Implemented Interfaces:
    Faceted, _Private_ReaderWriter, IonWriter, java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    _Private_IonBinaryWriterImpl

    public abstract class _Private_IonWriterBase
    extends java.lang.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 Detail

      • ERROR_MISSING_FIELD_NAME

        protected static final java.lang.String ERROR_MISSING_FIELD_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • 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 java.io.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:
        java.lang.IllegalArgumentException - if symbols is null or a shared symbol table, or if this writer isn't at top level.
        java.io.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 java.io.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:
        java.io.IOException
      • writeClob

        public void writeClob​(byte[] value)
                       throws java.io.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:
        java.io.IOException
      • writeDecimal

        public abstract void writeDecimal​(java.math.BigDecimal value)
                                   throws java.io.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:
        java.io.IOException
      • writeFloat

        public void writeFloat​(float value)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNull

        public void writeNull()
                       throws java.io.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:
        java.io.IOException
      • writeSymbolToken

        public final void writeSymbolToken​(SymbolToken tok)
                                    throws java.io.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:
        java.io.IOException
      • writeTimestampUTC

        public void writeTimestampUTC​(java.util.Date value)
                               throws java.io.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:
        java.io.IOException
      • writeValue

        @Deprecated
        public void writeValue​(IonValue value)
                        throws java.io.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:
        java.io.IOException
      • writeValues

        public void writeValues​(IonReader reader)
                         throws java.io.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:
        java.io.IOException
      • isStreamCopyOptimized

        public boolean isStreamCopyOptimized()
      • writeValue

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

        public <T> T asFacet​(java.lang.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:
        Facets.asFacet(Class, Faceted), Facets.assumeFacet(Class, Faceted)