Class DBIndex

java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBIndex
Direct Known Subclasses:
DBExpressionIndex

public class DBIndex extends DBObject
This class handles the primary key for the tables. The primary key contains one or more columns.
  • Constructor Details

    • DBIndex

      public DBIndex(String name, DBIndex.DBIndexType type, DBColumn[] columns)
      Constructs a DBIndex object set the specified parameters to this object.
      Parameters:
      name - the primary key name
      type - the primary key type (only PRIMARYKEY)
      columns - an array of one or more columns of the primary key
  • Method Details

    • getTable

      public DBTable getTable()
      returns the table this index belongs to. Valid only if the index has been added to a table (DBTable.addIndex)
      Returns:
      the corresponding table
    • getDatabase

      public DBDatabase getDatabase()
      Description copied from class: DBObject
      Returns the database object to which this object belongs to. For the database object itself this function will return the this pointer.
      Specified by:
      getDatabase in class DBObject
      Returns:
      the database object
    • getName

      public String getName()
      Returns the primary key name.
      Returns:
      the primary key name
    • getColumns

      public DBColumn[] getColumns()
      Returns the columns belonging to this index.
      Returns:
      the columns belonging to this index
    • getColumn

      public DBColumn getColumn(int index)
      Returns the columns belonging to this index.
      Parameters:
      index - the index of the desired column
      Returns:
      the columns belonging to this index
    • getColumnCount

      public int getColumnCount()
      Returns the number of columns belonging to this index.
      Returns:
      the number of columns belonging to this index
    • compareColumns

      public boolean compareColumns(DBColumn[] columns)
      checks whether the columns of this index match the supplied columns
      Parameters:
      columns - the columns
      Returns:
      true if columns match or false otherwise
    • getExpressions

      public DBColumnExpr[] getExpressions()
      Returns the columnExpressions belonging to this index.
      Returns:
      the columnExpressions belonging to this index
    • getFullName

      public String getFullName()
      Returns the full qualified table name.
      Returns:
      the full qualified table name
    • getType

      public DBIndex.DBIndexType getType()
      Returns the index type.
      Returns:
      the type of this index
    • getOptions

      public String getOptions()
      Returns additional database specific index options
      Returns:
      the index type options
    • setOptions

      public DBIndex setOptions(String options)
      Sets additional database specific index options
      Parameters:
      options - the index type options
      Returns:
      the index itself (this)
    • contains

      public boolean contains(DBColumn col)
      Checks if this index contains the column col
      Parameters:
      col - the column
      Returns:
      true if this index contains this column
    • getColumnPos

      public int getColumnPos(DBColumn col)
      Gets the position of a specified DBColumn object.
      Parameters:
      col - the column
      Returns:
      the position or -1 if the column was not found