Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Reader

A pull parser interface over Ion data.

Generally, users will use next and stepIn and stepOut to traverse the structure of the data. The Value suffixed methods are used to extract the scalar data out of the current position of the Reader.

Reader instances start before a value, thus you have to invoke next to position a newly created reader on the first value.

Hierarchy

  • Reader

Index

Methods

annotations

  • annotations(): string[]
  • Returns the annotations for the current value.

    Returns string[]

    the empty array if the there are no annotations or the reader is not positioned on a value.

bigIntValue

  • bigIntValue(): JSBI | null
  • Returns the current value as a BigInt. This is only valid if type() == IonTypes.INT.

    throw

    Error when the reader is not positioned on an int typed value.

    Returns JSBI | null

    null if the current Ion value isNull or a BigInt containing the deserialized integer.

booleanValue

  • booleanValue(): boolean | null
  • Returns the current value as a boolean. This is only valid if type() == IonTypes.BOOL.

    throw

    Error when the reader is not positioned on a bool typed value.

    Returns boolean | null

    null if the current Ion value isNull.

byteValue

  • byteValue(): Uint8Array | null
  • Returns the current value as a Uint8Array. This is only valid if type() == IonTypes.CLOB or type() == IonTypes.BLOB.

    throw

    Error when the reader is not positioned on a clob or blob typed value.

    deprecated

    since version 4.2. Use the uInt8ArrayValue method instead.

    Returns Uint8Array | null

    null if the current Ion value isNull.

decimalValue

  • Returns the current value as a Decimal. This is only valid if type() == IonTypes.DECIMAL.

    throw

    Error when the reader is not positioned on a decimal typed value.

    Returns Decimal | null

    null if the current Ion value isNull.

depth

  • depth(): number
  • Returns the depth of the reader. This is 0 if the reader is not inside of a container.

    Returns number

fieldName

  • fieldName(): string | null
  • Returns the field name of the current value.

    Returns string | null

    null if the reader is not positioned on a value or is on a value that has no field name.

intSize

isNull

  • isNull(): boolean
  • Returns true if and only if the reader is positioned on a null value of any type.

    Returns boolean

next

  • Advances the reader to the next value in the stream at the current depth.

    Returns IonType | null

    The corresponding IonType of the value the reader moves to, or null if the reader is at the end of the stream or container.

numberValue

  • numberValue(): number | null
  • Returns the current value as a number. This is only valid if type() == IonTypes.INT or type() == IonTypes.FLOAT.

    throw

    Error when the reader is not positioned on an int or float typed value.

    Returns number | null

    null if the current Ion value isNull. For int values that are outside of the range specified by Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER, this method will truncate the result.

position

  • position(): number
  • Returns the Reader's offset from the beginning of its input.

    For binary Readers, the return value is the number of bytes that have been processed.

    For text Readers, the return value is the number of UTF-16 code units that have been processed, regardless of the input's original encoding. For more on JavaScript's in-memory representation of text, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#Description

    Note that a Reader cannot safely skip to a given position in input without processing the stream leading up to that position. This is because there are mid-stream system level values that must be processed to guarantee that the Reader is in a valid state. It is safe, however, to start at the beginning of a data source and call next() until you reach the desired position, as the reader will still have the opportunity to process system-level values along the way.)

    Returns number

    the [[number]] of bytes or UTF-16 code units that the reader has processed.

stepIn

  • stepIn(): void
  • Steps into the container the reader is currently positioned on. Note that this positions the reader before the first value within the container.

    throw

    Error if the reader is not positioned on a container or the container isNull.

    Returns void

stepOut

  • stepOut(): void
  • Steps out of the current container. This is only valid when the reader is inside of a container (i.e. depth() > 0). Note that the positions the reader after the container that was stepped out of, but before the next value after the container. One should generally call next after invoking this method.

    throw

    Error if the reader is not positioned within a container.

    Returns void

stringValue

  • stringValue(): string | null
  • Returns the current value as a string. This is only valid if type() == IonTypes.STRING or type() == IonTypes.SYMBOL.

    throw

    Error when the reader is not positioned on a string or symbol typed value.

    Returns string | null

    null if the current Ion value isNull.

timestampValue

  • Returns the current value as a Timestamp. This is only valid if type() == IonTypes.TIMESTAMP.

    throw

    Error when the reader is not positioned on a timestamp typed value.

    Returns Timestamp | null

    null if the current Ion value isNull.

type

uInt8ArrayValue

  • uInt8ArrayValue(): Uint8Array | null
  • Returns the current value as a Uint8Array. This is only valid if type() == IonTypes.CLOB or type() == IonTypes.BLOB.

    throw

    Error when the reader is not positioned on a clob or blob typed value.

    Returns Uint8Array | null

    null if the current Ion value isNull.

value

  • Returns the current scalar value. This is only valid when type().scalar == true.

    throw

    Error when the reader is not positioned on a scalar value.

    deprecated

    Since version 3.2. Use the type-specific methods instead (numberValue(), stringValue(), etc.).

    Returns ReaderScalarValue

    null if the current value is isNull, equivalent to the corresponding xxxValue methods for all scalar types.