Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FieldImpl

A Record V2 field schema entry

Hierarchy

  • FieldImpl

Implements

Index

Constructors

constructor

  • new FieldImpl(name: string, type: Type, min: number, max: number, index: number, scale?: undefined | number): FieldImpl
  • Create a new field

    Parameters

    • name: string

      the name of the field

    • type: Type

      the datatype of the field

    • min: number

      the minimum number of occurrences of the node within its parent

    • max: number

      the maximum number of occurrences of the node within its parent

    • index: number

      the index of the field

    • Optional scale: undefined | number

      an optional scale for decimal field types

    Returns FieldImpl

Properties

index

index: number

The index of the field

isVariable

isVariable: boolean

Flag that indicates if the field can have variable index.

This is true if min is different from max.

max

max: number

The maximum number of occurrences of the node within its parent

min

min: number

The minimum number of occurrences of the node within its parent

name

name: string

The name of the field

Optional scale

scale: undefined | number

An optional scale for decimal field types

type

type: Type

The datatype of the field

Methods

getAbsoluteIndex

  • getAbsoluteIndex(index: number): number
  • Calculate the absolute index of the field

    throws

    an error if the index offset is out of range

    Parameters

    • index: number

      the index offset

    Returns number

    the absolute index

modelValue

  • modelValue(): string
  • Returns a model string representation of the field's data type.

    Returns string

    the zero value or empty string formatted according to the data type

toJSON

  • toJSON(): FieldData
  • Convert the field schema to a raw data object

    Returns FieldData

    a data object that can be serialised into a JSON string

toString

  • toString(): string
  • Convert the field to a string

    Returns string

    a string representation of the field