org.apache.empire.db
Class DBIndex

java.lang.Object
  extended by org.apache.empire.db.DBObject
      extended by org.apache.empire.db.DBIndex
All Implemented Interfaces:
Serializable
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.

See Also:
Serialized Form

Field Summary
static int PRIMARYKEY
          SQL Primary key index
static int STANDARD
          SQL Standard index
static int UNIQUE
          SQL Unique index
 
Constructor Summary
DBIndex(String name, int type, DBColumn[] columns)
          Constructs a DBIndex object set the specified parameters to this object.
 
Method Summary
 boolean contains(DBColumn col)
          Checks if this index contains the column col
 int getColumnPos(DBColumn col)
          Gets the position of a specified DBColumn object.
 DBColumn[] getColumns()
          Returns the columns belonging to this index.
 DBDatabase getDatabase()
          Returns the database object to which this object belongs to.
 DBExpr[] getExpressions()
          Returns the columnExpressions belonging to this index.
 String getFullName()
          Returns the full qualified table name.
 String getName()
          Returns the primary key name.
 DBTable getTable()
          returns the table this index belongs to.
 int getType()
          Returns the index type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD

public static final int STANDARD
SQL Standard index

See Also:
Constant Field Values

UNIQUE

public static final int UNIQUE
SQL Unique index

See Also:
Constant Field Values

PRIMARYKEY

public static final int PRIMARYKEY
SQL Primary key index

See Also:
Constant Field Values
Constructor Detail

DBIndex

public DBIndex(String name,
               int 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 Detail

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

getExpressions

public DBExpr[] 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 int getType()
Returns the index type.

Returns:
the type of this index (PRIMARYKEY, UNIQUE, STANDARD)

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


Copyright © 2008-2012 Apache Software Foundation. All Rights Reserved.