Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Table

Maven Table class Table supports grouping by rows, and column type annotations.

Hierarchy

  • Table

Index

Constructors

constructor

Properties

Private _columnLookup

_columnLookup: object

Column name to data index map. c.f. Row.getValue()

Type declaration

  • [key: string]: number

Private _columnNames

_columnNames: string[]

Private _columnTypes

_columnTypes: Type[]

Private _length

_length: number = 0

Number of all rows in this table (including children of rows)

type

{number}

Private _rows

_rows: Row[]

Accessors

Cols

  • get Cols(): string[]
  • A list of all column names in this table

    deprecated

    Use Table#columnNames instead

    type

    {string[]}

    Returns string[]

Rows

  • get Rows(): object[]
  • Returns all the top-level rows as an array of objects, keyed on columns. Eg, [{col1: "val1", col2: "val2"}, {col1:"val3", col2: "val4"}, ...]

    deprecated

    Use TableHelper.toObjectArray instead, for explicit conversions

    type

    {any[]}

    Returns object[]

columnNames

  • get columnNames(): string[]
  • A list of the column names of this table

    type

    {string[]}

    Returns string[]

columnTypes

  • get columnTypes(): Type[]
  • The per-column type annotations for this table

    type

    {Type[]}

    Returns Type[]

length

  • get length(): number
  • The number of all the rows in this table, including child rows

    type

    {number}

    Returns number

rows

  • get rows(): Row[]
  • All top-level rows of this table Note that this does NOT include child rows!

    type

    {Row[]}

    Returns Row[]

Methods

CopyTable

  • Copies the table

    deprecated

    use Table#copyTable()

    constructor

    Returns Table

appendColumn

  • appendColumn(name: string, type?: Type): number
  • Non-destructively appends a new column to the Table

    Parameters

    • name: string

      The name of the new column

    • Default value type: Type = Types.Any

    Returns number

    The index of the new column, as reflected in Table#columnNames

appendRow

  • appendRow(row: Row): void
  • Append a new row to the table, as a root-level row. Note that a Row can only be owned by a single Table

    Parameters

    • row: Row

      The row to append

    Returns void

copyTable

  • Copies the table and all child rows deeply, returning an entirely new instance This is useful to break object references where required, so that multiple functions in the same context can edit the same source table without stomping on each other's changes

    Returns Table

    A completely new instance of a Table

Private createColumnLookup

  • createColumnLookup(): void

createRow

  • createRow(name: string | null): Row
  • Creates a new Row, with the given name, and the owner set to the current table. This does NOT add it to the Table!

    Parameters

    • name: string | null

    Returns Row

dropInvalidTypes

  • dropInvalidTypes(): void
  • Iterate through the table, removing any cells with invalid types.

    Returns void

Private ensureRowDataLength

  • ensureRowDataLength(len: number): void
  • Parameters

    • len: number

    Returns void

Private ensureRowDataType

  • ensureRowDataType(): void

insertRow

  • insertRow(row: Row, index: number): void
  • Inserts a root row at the given index

    Parameters

    • row: Row
    • index: number

    Returns void

setColumns

  • setColumns(names: string[], types?: Type[]): void
  • Replace the columns of this table, and pad/truncate the rows as appropriate The row data are only cleared if truncated. Otherwise, they retain their old value at that index.

    Parameters

    • names: string[]

      The new columnNames to use

    • Optional types: Type[]

    Returns void

toString

  • toString(): string

Static CopyTable

  • Deeply copy the table and all rows, producing a new instance

    deprecated

    Use table#copyTable() instead

    Parameters

    • table: Table

      Table to copy

    Returns Table

Static NullTable

  • Returns a single-row, single-column 'empty' table.

    This is what the query SELECT null FROM dual would return, and is useful for parts that want a 'default' table since it allows them to display a column and row (and thus surface to the user what they look like, and how to interact with them).

    Returns Table

Static Protected _copyRowAndChildren

  • _copyRowAndChildren(table: Table, parent: Row | null, row: Row): void

Static copyTable

  • Deeply copy the table and all rows, producing a new instance

    deprecated

    Use table#copyTable() instead

    Parameters

    • table: Table

      Table to copy

    Returns Table

Generated using TypeDoc