Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Writer

Serializes data in Ion text or binary format to an implementation defined buffer.

Hierarchy

  • Writer

Index

Methods

addAnnotation

  • addAnnotation(annotation: string): void
  • Adds an annotation to the list of annotations to be used when writing the next value.

    Parameters

    • annotation: string

    Returns void

close

  • close(): void
  • Flushes data to the internal buffer and finalizes the Ion stream.

    throws

    Error if the Writer is already closed or the writer is not at the top-level (i.e. inside of a container).

    Returns void

depth

  • depth(): number

getBytes

  • getBytes(): Uint8Array
  • Retrieves the serialized buffer as an array of octets. The buffer will be either a UTF-8 encoded buffer for Ion text or Ion binary. The buffer is not well-defined until close is invoked.

    throws

    Error if close has not been invoked.

    Returns Uint8Array

setAnnotations

  • setAnnotations(annotations: string[]): void
  • Specifies the list of annotations to be used when writing the next value. This clears the current annotations set for the next value.

    Parameters

    • annotations: string[]

    Returns void

stepIn

  • Starts a container and positions the writer within that container.

    throws

    Error if type.container is not one of IonTypes.LIST, IonTypes.SEXP, or IonTypes.STRUCT.

    Parameters

    Returns void

stepOut

  • stepOut(): void
  • Steps out of a container and positions the writer after the container.

    throws

    Error if the writer is not inside a container.

    Returns void

writeBlob

  • writeBlob(value: Uint8Array | null): void
  • Writes a Uint8Array as an Ion blob value.

    Parameters

    • value: Uint8Array | null

      The array to write, which may be null to write a null.blob.

    Returns void

writeBoolean

  • writeBoolean(value: boolean | null): void
  • Writes a boolean as an Ion bool value.

    Parameters

    • value: boolean | null

      The boolean to write, which may be null to write a null.bool.

    Returns void

writeClob

  • writeClob(value: Uint8Array | null): void
  • Writes a Uint8Array as an Ion clob value.

    Parameters

    • value: Uint8Array | null

      The array to write, which may be null to write a null.clob.

    Returns void

writeDecimal

  • writeDecimal(value: Decimal | null): void

writeFieldName

  • writeFieldName(fieldName: string): void
  • Writes the field name for a member of a struct.

    throws

    Error if the Writer is not within a struct or this method was already called before a value was written.

    Parameters

    • fieldName: string

    Returns void

writeFloat32

  • writeFloat32(value: number | null): void
  • Writes a number value as an Ion 32-bit binary float value.

    Parameters

    • value: number | null

      The number to write, which may be null to write a null.float. If the number cannot be represented exactly as a 32-bit binary floating point value, an implementation may truncate or round the value.

    Returns void

writeFloat64

  • writeFloat64(value: number | null): void
  • Writes a number value as an Ion 64-bit binary float value.

    Parameters

    • value: number | null

      The number to write, which may be null to write a null.float.

    Returns void

writeInt

  • writeInt(value: number | JSBI | null): void
  • Writes a number value as an Ion int.

    Parameters

    • value: number | JSBI | null

      The number to write, which may be null to write a null.int. If number is not an integer between the range specified by Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER, an implementation may truncate or round the value.

    Returns void

writeNull

writeString

  • writeString(value: string | null): void
  • Writes a string value as an Ion string.

    Parameters

    • value: string | null

      The string to write, which may be null to write a null.string.

    Returns void

writeSymbol

  • writeSymbol(value: string | null): void
  • Writes a string value as an Ion symbol.

    Parameters

    • value: string | null

      The string to write, which may be null to write a null.symbol.

    Returns void

writeTimestamp

  • writeTimestamp(value: Timestamp | null): void

writeValue

  • writeValue(reader: Reader): void
  • Writes a reader's current value.

    If there's no current value, this method does nothing. If the current value is a container, this method will stepIn() recursively, writing each nested value that it encounters.

    It is illegal to call this method if this Writer is positioned within a Struct while the Reader is not.

    Parameters

    Returns void

writeValues

  • writeValues(reader: Reader): void
  • 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 {@link next()} to get started. This method will stepIn() to containers recursively, writing each nested value that it encounters.

    It is illegal to call this method if this Writer is positioned within a Struct while the Reader is not.

    Parameters

    Returns void