Package db
Class Schema
- java.lang.Object
-
- db.Schema
-
public class Schema extends java.lang.Object
Class for definining the columns in a Ghidra Database table.
-
-
Constructor Summary
Constructors Constructor Description Schema(int version, Field keyField, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames)
Construct a new Schema.Schema(int version, Field keyField, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema.Schema(int version, java.lang.Class<?> keyClass, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames)
Construct a new Schema.Schema(int version, java.lang.Class<?> keyClass, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema.Schema(int version, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames)
Construct a new Schema which uses a long key.Schema(int version, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema which uses a long key.Schema(int version, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames)
Construct a new Schema which uses a long key.Schema(int version, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema which uses a long key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DBRecord
createRecord(long key)
Create an empty record for the specified key.DBRecord
createRecord(Field key)
Create an empty record for the specified key.boolean
equals(java.lang.Object obj)
Compare two schemas for equality.int
getFieldCount()
Get the number of data Fieldsjava.lang.String[]
getFieldNames()
Get the list of data Field names for this schema.Field[]
getFields()
Get the list of data Field classes for this schema.int
getFixedLength()
Get length of fixed-length schema record.Field
getKeyFieldType()
Get the Field type for the key.java.lang.String
getKeyName()
Get the key nameint
getVersion()
Get the schema version.int
hashCode()
boolean
hasSparseColumns()
Determine if schema employs sparse column storageboolean
isSparseColumn(int columnIndex)
Determine if the specified column index has been designated as a sparse column within the associated record storageboolean
isVariableLength()
Returns true if records for this Schema can be of variable lengths.java.lang.String
toString()
-
-
-
Constructor Detail
-
Schema
public Schema(int version, Field keyField, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema.- Parameters:
version
- schema versionkeyField
- field associated with primary key (representative instance)keyName
- primary key namefields
- array of column fields (representative instances)fieldNames
- array of column field namessparseColumns
- 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:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, Field keyField, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames)
Construct a new Schema.- Parameters:
version
- schema versionkeyField
- field associated with primary key (representative instance)keyName
- primary key namefields
- array of column fields (representative instances)fieldNames
- array of column field names- Throws:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames)
Construct a new Schema which uses a long key.- Parameters:
version
- schema versionkeyName
- primary key namefields
- array of column fields (representative instances)fieldNames
- array of column field names- Throws:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.String keyName, Field[] fields, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema which uses a long key.- Parameters:
version
- schema versionkeyName
- primary key namefields
- array of column fields (representative instances)fieldNames
- array of column field namessparseColumns
- 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:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.Class<?> keyClass, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames)
Construct a new Schema.- Parameters:
version
- schema versionkeyClass
- field class associated with primary keykeyName
- primary key namefieldClasses
- array of column field classesfieldNames
- array of column field names- Throws:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.Class<?> keyClass, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema.- Parameters:
version
- schema versionkeyClass
- field class associated with primary keykeyName
- primary key namefieldClasses
- array of column field classesfieldNames
- array of column field namessparseColumns
- 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:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames)
Construct a new Schema which uses a long key.- Parameters:
version
- schema versionkeyName
- primary key namefieldClasses
- array of column field classesfieldNames
- array of column field names- Throws:
java.lang.IllegalArgumentException
- invalid parameters
-
Schema
public Schema(int version, java.lang.String keyName, java.lang.Class<?>[] fieldClasses, java.lang.String[] fieldNames, int[] sparseColumns)
Construct a new Schema which uses a long key.- Parameters:
version
- schema versionkeyName
- primary key namefieldClasses
- array of column field classesfieldNames
- array of column field namessparseColumns
- 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:
java.lang.IllegalArgumentException
- invalid parameters
-
-
Method Detail
-
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 java.lang.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 java.lang.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(java.lang.Object obj)
Compare two schemas for equality. Field names are ignored in this comparison. Instance variables such asfixedLength
,isVariableLength
andforceUseVariableLengthKeyNodes
are also ignored.- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-