Class Table

java.lang.Object
net.codecrete.windowsapi.winmd.tables.Table

public class Table extends Object
Metadata table.

Metadata tables consist of multiple integer columns that are either 2 or 4 bytes wide.

This class also serves as an accessor for these tables.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Table(int numRows)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    getRow(int index, int[] values)
    Loads the row data into the array of integers.
    int
    getValue(int rowIndex, int columnIndex)
    Gets the value of the specified row and column.
    boolean
    hasNext(int index, int key, int keyWidth)
    Tests if the row after the specified row has the given (primary) key.
    int
    indexByPrimaryKey(int key, int keyWidth, int keyOffset)
    Finds the first index for the specified (primary) key.
    int
    The width of the indexes for this table.
    int
    Number of rows.
    void
    setColumnWidths(int... widths)
    Sets the width of the columns.
    void
    setData(byte[] data)
    Sets the table data.
    int
    Width of the table (column length).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Table

      public Table(int numRows)
      Creates a new instance.
      Parameters:
      numRows - number of rows
  • Method Details

    • numRows

      public int numRows()
      Number of rows.
      Returns:
      number of rows
    • width

      public int width()
      Width of the table (column length).
      Returns:
      width, in bytes
    • indexWidth

      public int indexWidth()
      The width of the indexes for this table.
      Returns:
      width, in bytes
    • setColumnWidths

      public void setColumnWidths(int... widths)
      Sets the width of the columns.
      Parameters:
      widths - width for each column, in bytes
    • setData

      public void setData(byte[] data)
      Sets the table data.
      Parameters:
      data - table contents as a byte array
    • getRow

      public void getRow(int index, int[] values)
      Loads the row data into the array of integers.
      Parameters:
      index - row index
      values - array to be filled
    • getValue

      public int getValue(int rowIndex, int columnIndex)
      Gets the value of the specified row and column.
      Parameters:
      rowIndex - row index
      columnIndex - column index
      Returns:
      the value
    • indexByPrimaryKey

      public int indexByPrimaryKey(int key, int keyWidth, int keyOffset)
      Finds the first index for the specified (primary) key.

      Only works for sorted tables. See ECMA-335, II.22 Metadata logical format: tables.

      Parameters:
      key - the key to search for
      keyWidth - the width of the key, in bytes
      keyOffset - offset of the key from the start of the row, in bytes
      Returns:
      the row index, or 0 if the key was not found
    • hasNext

      public boolean hasNext(int index, int key, int keyWidth)
      Tests if the row after the specified row has the given (primary) key.
      Parameters:
      index - row index
      key - the key to search for
      keyWidth - the width of the key, in bytes
      Returns:
      true if the next row has the given key, false otherwise