Package ghidra.features.bsim.query.client.tables

# Class OptionalTable

java.lang.Object
ghidra.features.bsim.query.client.tables.OptionalTable

public class OptionalTable extends Object
Database table that has exactly two columns: key and value The column types are variable and are determined upon initialization. They are specified by giving an integer "type code" as listed in java.sql.Types The key column will be marked as UNIQUE. The JDBC driver will map between Java and SQL types. The readValue() writeValue() and deleteValue() methods simply take and return an Object.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OptionalTable(String nm, int kType, int vType, Connection d)`
  Construct this table for a specific connection

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearTable()`
  Clear all rows from the table
  `void`
  `close()`
  Free any resources and relinquish references to the connection
  `void`
  `createTable()`
  Create this specific table in the database
  `void`
  `deleteValue(Object key)`
  Deletes the row corresponding to a given key
  `boolean`
  `exists()`
  Determine whether a given table exists in the database
  `int`
  `getKeyType()`
  `String`
  `getName()`
  `int`
  `getValueType()`
  `void`
  `lockForWrite()`
  Lock the table for writing
  `Object`
  `readValue(Object key)`
  Given a key, retrieve the corresponding value
  `void`
  `writeValue(Object key, Object value)`
  Associate a new value with a given key

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### OptionalTable

    public OptionalTable(String nm, int kType, int vType, Connection d)
    Construct this table for a specific connection
    Parameters:
      `nm` - is the formal SQL name of the table
      `kType` - is the type-code of the key (as specified in java.sql.Types)
      `vType` - is the type-code of the value (as specified in java.sql.Types)
      `d` - is the connection to the SQL server

- ## Method Details

  - ### lockForWrite

    public void lockForWrite() throws SQLException
    Lock the table for writing
    Throws:
      `SQLException` - if the server reports an error

  - ### getName

    public String getName()
    Returns:
      the formal sql name of the table

  - ### getKeyType

    public int getKeyType()
    Returns:
      type-code of key column

  - ### getValueType

    public int getValueType()
    Returns:
      type-code of value column

  - ### close

    public void close()
    Free any resources and relinquish references to the connection

  - ### createTable

    public void createTable() throws SQLException
    Create this specific table in the database
    Throws:
      `SQLException` - for problems with the connection

  - ### clearTable

    public void clearTable() throws SQLException
    Clear all rows from the table
    Throws:
      `SQLException` - for problems with the connection

  - ### exists

    public boolean exists() throws SQLException
    Determine whether a given table exists in the database
    Returns:
      true is the table exists
    Throws:
      `SQLException` - for problems with the connection

  - ### readValue

    public Object readValue(Object key) throws SQLException
    Given a key, retrieve the corresponding value
    Parameters:
      `key` - identifies the table row
    Returns:
      the value corresponding to the key
    Throws:
      `SQLException` - for problems with the connection

  - ### writeValue

    public void writeValue(Object key, Object value) throws SQLException
    Associate a new value with a given key
    Parameters:
      `key` - identifies the table row
      `value` - is stored at that row
    Throws:
      `SQLException` - for problems with the connection

  - ### deleteValue

    public void deleteValue(Object key) throws SQLException
    Deletes the row corresponding to a given key
    Parameters:
      `key` - identifies the table row
    Throws:
      `SQLException` - for problems with the connection