Package db

Class Schema

java.lang.Object
db.Schema

public class Schema extends Object
Class for definining the columns in a Ghidra Database table.
  • Constructor Details

    • Schema

      public Schema(int version, Field keyField, String keyName, Field[] fields, String[] fieldNames, int[] sparseColumns)
      Construct a new Schema.
      Parameters:
      version - schema version
      keyField - field associated with primary key (representative instance)
      keyName - primary key name
      fields - array of column fields (representative instances)
      fieldNames - array of column field names
      sparseColumns - column indexes corresponding to those columns which utilize sparse storage (null if no sparse columns). Valid sparse column indexes are in the range 0..127.
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, Field keyField, String keyName, Field[] fields, String[] fieldNames)
      Construct a new Schema.
      Parameters:
      version - schema version
      keyField - field associated with primary key (representative instance)
      keyName - primary key name
      fields - array of column fields (representative instances)
      fieldNames - array of column field names
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, String keyName, Field[] fields, String[] fieldNames)
      Construct a new Schema which uses a long key.
      Parameters:
      version - schema version
      keyName - primary key name
      fields - array of column fields (representative instances)
      fieldNames - array of column field names
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, String keyName, Field[] fields, String[] fieldNames, int[] sparseColumns)
      Construct a new Schema which uses a long key.
      Parameters:
      version - schema version
      keyName - primary key name
      fields - array of column fields (representative instances)
      fieldNames - array of column field names
      sparseColumns - column indexes corresponding to those columns which utilize sparse storage (null if no sparse columns). Valid sparse column indexes are in the range 0..127.
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, Class<?> keyClass, String keyName, Class<?>[] fieldClasses, String[] fieldNames)
      Construct a new Schema.
      Parameters:
      version - schema version
      keyClass - field class associated with primary key
      keyName - primary key name
      fieldClasses - array of column field classes
      fieldNames - array of column field names
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, Class<?> keyClass, String keyName, Class<?>[] fieldClasses, String[] fieldNames, int[] sparseColumns)
      Construct a new Schema.
      Parameters:
      version - schema version
      keyClass - field class associated with primary key
      keyName - primary key name
      fieldClasses - array of column field classes
      fieldNames - array of column field names
      sparseColumns - column indexes corresponding to those columns which utilize sparse storage (null if no sparse columns). Valid sparse column indexes are in the range 0..127.
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, String keyName, Class<?>[] fieldClasses, String[] fieldNames)
      Construct a new Schema which uses a long key.
      Parameters:
      version - schema version
      keyName - primary key name
      fieldClasses - array of column field classes
      fieldNames - array of column field names
      Throws:
      IllegalArgumentException - invalid parameters
    • Schema

      public Schema(int version, String keyName, Class<?>[] fieldClasses, String[] fieldNames, int[] sparseColumns)
      Construct a new Schema which uses a long key.
      Parameters:
      version - schema version
      keyName - primary key name
      fieldClasses - array of column field classes
      fieldNames - array of column field names
      sparseColumns - column indexes corresponding to those columns which utilize sparse storage (null if no sparse columns). Valid sparse column indexes are in the range 0..127.
      Throws:
      IllegalArgumentException - invalid parameters
  • Method Details

    • hasSparseColumns

      public boolean hasSparseColumns()
      Determine if schema employs sparse column storage
      Returns:
      true if schema employs sparse column storage
    • isSparseColumn

      public boolean isSparseColumn(int columnIndex)
      Determine if the specified column index has been designated as a sparse column within the associated record storage
      Parameters:
      columnIndex - column index
      Returns:
      true if designated column uses sparse storage
    • getKeyFieldType

      public Field getKeyFieldType()
      Get the Field type for the key.
      Returns:
      key Field type
    • getKeyName

      public String getKeyName()
      Get the key name
      Returns:
      key name
    • getFields

      public Field[] getFields()
      Get the list of data Field classes for this schema. The returned list is ordered consistent with the schema definition.
      Returns:
      data Field classes
    • getFieldNames

      public String[] getFieldNames()
      Get the list of data Field names for this schema. The returned list is ordered consistent with the schema definition.
      Returns:
      data Field names
    • getFieldCount

      public int getFieldCount()
      Get the number of data Fields
      Returns:
      data Field count
    • getVersion

      public int getVersion()
      Get the schema version.
      Returns:
      schema version
    • isVariableLength

      public boolean isVariableLength()
      Returns true if records for this Schema can be of variable lengths.
      Returns:
      true if records with this Schema are variable length.
    • getFixedLength

      public int getFixedLength()
      Get length of fixed-length schema record.
      Returns:
      record length or 0 for variable length.
    • createRecord

      public DBRecord createRecord(long key)
      Create an empty record for the specified key.
      Parameters:
      key - long key
      Returns:
      new record
    • createRecord

      public DBRecord createRecord(Field key)
      Create an empty record for the specified key.
      Parameters:
      key - record key field
      Returns:
      new record
    • equals

      public boolean equals(Object obj)
      Compare two schemas for equality. Field names are ignored in this comparison. Instance variables such as fixedLength, isVariableLength and forceUseVariableLengthKeyNodes are also ignored.
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object