Class DBAliasExpr

All Implemented Interfaces:
Unwrappable<DBColumnExpr>, ColumnExpr, DBPreparable

public class DBAliasExpr extends DBColumnExpr implements DBPreparable, Unwrappable<DBColumnExpr>
This class allows column renaming in SQL.

There is no need to explicitly create instances of this class.
Instead use DBColumnExpr.as(String)

  • Constructor Details

    • DBAliasExpr

      public DBAliasExpr(DBColumnExpr expr, String alias)
      Constructs a DBAliasExpr object combine the DBColumnExpr object with the alias name.
      Parameters:
      expr - an DBColumnExpr object, one column
      alias - the alias name of the column
  • Method Details

    • getDatabase

      public final DBDatabase getDatabase()
      Returns the current DBDatabase object.
      Specified by:
      getDatabase in class DBObject
      Returns:
      the current DBDatabase object
    • getDataType

      public DataType getDataType()
      Returns the data type of the DBColumnExpr object.
      Specified by:
      getDataType in interface ColumnExpr
      Specified by:
      getDataType in class DBColumnExpr
      Returns:
      the data type
      See Also:
    • getEnumType

      public Class<Enum<?>> getEnumType()
      Returns the enum type of this Expression (if any)
      Specified by:
      getEnumType in interface ColumnExpr
      Returns:
      the enum type or null
    • getName

      public String getName()
      This helper function returns the alias name.
      Specified by:
      getName in interface ColumnExpr
      Specified by:
      getName in class DBColumnExpr
      Returns:
      the alias name
    • getRowSet

      public DBRowSet getRowSet()
      Returns the underlying rowset
      Specified by:
      getRowSet in class DBColumnExpr
      Returns:
      a column used for this expression
    • getUpdateColumn

      public DBColumn getUpdateColumn()
      Returns the DBColunm object.
      Specified by:
      getUpdateColumn in interface ColumnExpr
      Specified by:
      getUpdateColumn in class DBColumnExpr
      Returns:
      the DBColunm object
    • isWrapper

      public boolean isWrapper()
      Indicates that we are actually an expression wrapper
      Specified by:
      isWrapper in interface Unwrappable<DBColumnExpr>
      Returns:
      true
    • unwrap

      public DBColumnExpr unwrap()
      Returns the underlying column expression.
      Specified by:
      unwrap in interface Unwrappable<DBColumnExpr>
      Returns:
      the underlying column expression
    • isAggregate

      public boolean isAggregate()
      Forward to expression
      Specified by:
      isAggregate in class DBColumnExpr
      Returns:
      false
    • equals

      public boolean equals(Object other)
      Overrides the equals method
      Overrides:
      equals in class Object
      Returns:
      true if alias name and expression match
    • prepareParams

      public void prepareParams(DBCommand cmd, DBExpr parent)
      Description copied from interface: DBPreparable
      Prepares an expression for a query This function is called by DBCommand in order to add values as query parameters instead of being literally included in the sql statement Please Note: This function is internally called. Do not call yourself!
      Specified by:
      prepareParams in interface DBPreparable
      Parameters:
      cmd - the command to which to add the parameters
      parent - the parent expression holding the value
    • addReferencedColumns

      public void addReferencedColumns(Set<DBColumn> list)
      Description copied from class: DBExpr
      Internal function to obtain all DBColumnExpr-objects used by this expression.
      Specified by:
      addReferencedColumns in class DBExpr
      Parameters:
      list - list to which all used column expressions must be added
      See Also:
    • addSQL

      public void addSQL(DBSQLBuilder sql, long context)
      Creates the SQL-Command adds the alias name to the SQL-Command.
      Specified by:
      addSQL in class DBExpr
      Parameters:
      sql - the SQL statment
      context - the current SQL-Command context
    • addXml

      public Element addXml(Element parent, long flags)
      This function set the alias name to the XML tag.
      Specified by:
      addXml in class DBColumnExpr
      Parameters:
      parent - the parent element to which to append the column description
      flags - currently not used
      Returns:
      the XML tag (with the alias name)
    • toString

      public String toString()
      Overrides the toString method.
      Overrides:
      toString in class DBColumnExpr
      Returns:
      the alias name