Class Table
java.lang.Object
net.codecrete.windowsapi.winmd.tables.Table
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidgetRow(int index, int[] values) Loads the row data into the array of integers.intgetValue(int rowIndex, int columnIndex) Gets the value of the specified row and column.booleanhasNext(int index, int key, int keyWidth) Tests if the row after the specified row has the given (primary) key.intindexByPrimaryKey(int key, int keyWidth, int keyOffset) Finds the first index for the specified (primary) key.intThe width of the indexes for this table.intnumRows()Number of rows.voidsetColumnWidths(int... widths) Sets the width of the columns.voidsetData(byte[] data) Sets the table data.intwidth()Width of the table (column length).
-
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 indexvalues- array to be filled
-
getValue
public int getValue(int rowIndex, int columnIndex) Gets the value of the specified row and column.- Parameters:
rowIndex- row indexcolumnIndex- 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 forkeyWidth- the width of the key, in byteskeyOffset- 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 indexkey- the key to search forkeyWidth- the width of the key, in bytes- Returns:
trueif the next row has the given key,falseotherwise
-