Class Table

  • All Implemented Interfaces:
    SQLStringable

    public class Table
    extends AbstractTable
    A representation of a table that can be present in the FROM section of an SQL query.
    Author:
    Matthew Wakeling, Andrew Varley
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String name  
    • Constructor Summary

      Constructors 
      Constructor Description
      Table​(java.lang.String name)
      Constructor for this Table object, without an alias.
      Table​(java.lang.String name, java.lang.String alias)
      Constructor for this Table object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Overrides Object.equals().
      boolean equalsIgnoreAlias​(AbstractTable obj)
      Compare this Table to another AbstractTable, ignoring alias.
      java.lang.String getName()
      Returns the name of the table
      java.lang.String getSQLString()
      Returns a String representation of this Table object, suitable for forming part of an SQL query.
      int hashCode()
      Overrides Object.hashcode().
      java.lang.String toString()
      A toString method, which helps us when debugging.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        protected java.lang.String name
    • Constructor Detail

      • Table

        public Table​(java.lang.String name,
                     java.lang.String alias)
        Constructor for this Table object.
        Parameters:
        name - the name of the table, as the database knows it
        alias - an arbitrary name that the table has been renamed to for the rest of the query
      • Table

        public Table​(java.lang.String name)
        Constructor for this Table object, without an alias.
        Parameters:
        name - the name of the table, as the database knows it. This name is also used in the rest of the query.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of the table
        Returns:
        the Table name
      • getSQLString

        public java.lang.String getSQLString()
        Returns a String representation of this Table object, suitable for forming part of an SQL query.
        Specified by:
        getSQLString in interface SQLStringable
        Specified by:
        getSQLString in class AbstractTable
        Returns:
        the String representation
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides Object.equals().
        Specified by:
        equals in class AbstractTable
        Parameters:
        obj - an Object to compare to
        Returns:
        true if the object is of the same class, and with the same name
      • hashCode

        public int hashCode()
        Overrides Object.hashcode().
        Specified by:
        hashCode in class AbstractTable
        Returns:
        an arbitrary integer based on the name of the Table
      • equalsIgnoreAlias

        public boolean equalsIgnoreAlias​(AbstractTable obj)
        Compare this Table to another AbstractTable, ignoring alias.
        Specified by:
        equalsIgnoreAlias in class AbstractTable
        Parameters:
        obj - an AbstractTable to compare to
        Returns:
        true if the object is of the same class, and with the same value
      • toString

        public java.lang.String toString()
        A toString method, which helps us when debugging.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the object