java.lang.Object
com.invirgance.convirgance.olap.sql.Table

public class Table extends Object
Provides support for a database Table representation.
Author:
jbanes
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of the Table object.
    Table(String name)
    Creates a new instance of the Table with the specified name.
    Table(String name, String primaryKey)
    Creates a new instance of the Database with the specified name and primaryKey.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addForeignKey(String foreignKey, Table target)
    Creates and adds the new foreignKey to this table's list of foreign keys.
    boolean
    Compares this Table to another Table first by reference, then by instance fields (associated database, table name, and primary key),
    Returns the Database associated with the table.
    Returns the List of ForeignKey objects associated with the table.
    Returns the name of the Table.
    Returns the String with the primaryKey of the table.
    int
    Returns the hashCode for the Table.
    void
    Sets the provided list of ForeignKey objects to this Table.
    void
    Sets the name for the table.
    void
    setPrimaryKey(String primaryKey)
    Sets the provided string as the primaryKey for the table.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Table

      public Table()
      Creates a new instance of the Table object.
    • Table

      public Table(String name)
      Creates a new instance of the Table with the specified name.
      Parameters:
      name - the String representing the table's name.
    • Table

      public Table(String name, String primaryKey)
      Creates a new instance of the Database with the specified name and primaryKey.
      Parameters:
      name - the String representing the name.
      primaryKey - the String representing the primaryKey.
  • Method Details

    • getDatabase

      public Database getDatabase()
      Returns the Database associated with the table.
      Returns:
      the Database object.
    • getName

      public String getName()
      Returns the name of the Table.
      Returns:
      the String with the table's name.
    • setName

      public void setName(String name)
      Sets the name for the table.
      Parameters:
      name - the String with the name.
    • getPrimaryKey

      public String getPrimaryKey()
      Returns the String with the primaryKey of the table.
      Returns:
      String with the primaryKey.
    • setPrimaryKey

      public void setPrimaryKey(String primaryKey)
      Sets the provided string as the primaryKey for the table.
      Parameters:
      primaryKey - String representing the primary key.
    • getForeignKeys

      public List<ForeignKey> getForeignKeys()
      Returns the List of ForeignKey objects associated with the table.
      Returns:
      the List of ForeignKey objects.
    • addForeignKey

      public void addForeignKey(String foreignKey, Table target)
      Creates and adds the new foreignKey to this table's list of foreign keys. If the table already contains the new key, does nothing.
      Parameters:
      foreignKey - the String representing the foreign key.
      target - the target table associated with the foreign key.
    • setForeignKeys

      public void setForeignKeys(List<ForeignKey> foreignKeys)
      Sets the provided list of ForeignKey objects to this Table.
      Parameters:
      foreignKeys - a list of ForeignKey objects.
    • equals

      public boolean equals(Object obj)
      Compares this Table to another Table first by reference, then by instance fields (associated database, table name, and primary key),
      Overrides:
      equals in class Object
      Parameters:
      obj - A table to compare to.
      Returns:
      true if the databases are the same by memory reference or by instance fields.
    • hashCode

      public int hashCode()
      Returns the hashCode for the Table. The hashCode is based on the database associated with the table, the table's name, and its primary key.
      Overrides:
      hashCode in class Object
      Returns:
      int representing the hashCode.