Class DBScalarExpr

All Implemented Interfaces:
ColumnExpr, DBPreparable

public class DBScalarExpr extends DBColumnExpr implements DBPreparable
This class is used for declaring scalar functions in SQL (like e.g. random).
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • db

      public final DBDatabase db
    • dataType

      public final DataType dataType
    • template

      public final String template
    • params

      protected Object[] params
  • Constructor Details

    • DBScalarExpr

      public DBScalarExpr(DBDatabase db, String template, Object[] params, DataType dataType)
      Constructs a new DBValueExpr object.
      Parameters:
      db - the database
      template - the format template
      params - the format params
      dataType - the data type for this constant
    • DBScalarExpr

      public DBScalarExpr(DBDatabase db, String template, Object param, DataType dataType)
      Constructs a new DBValueExpr object.
      Parameters:
      db - the database
      template - the format template
      param - a format param
      dataType - the data type for this constant
  • Method Details

    • getParams

      public Object[] getParams()
      return the value associated with this value expression
      Returns:
      the current value
    • setParams

      public void setParams(Object[] params)
      set the value associated with this value expression
      Parameters:
      params - the params array
    • 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 null
      Specified by:
      getEnumType in interface ColumnExpr
      Returns:
      the enum type
    • getName

      public String getName()
      Returns the column name.
      Specified by:
      getName in interface ColumnExpr
      Specified by:
      getName in class DBColumnExpr
      Returns:
      the column name
    • getRowSet

      public DBRowSet getRowSet()
      Returns null.
      Specified by:
      getRowSet in class DBColumnExpr
      Returns:
      null
    • getUpdateColumn

      public DBColumn getUpdateColumn()
      Returns null.
      Specified by:
      getUpdateColumn in interface ColumnExpr
      Specified by:
      getUpdateColumn in class DBColumnExpr
      Returns:
      null
    • isAggregate

      public boolean isAggregate()
      Always returns false since value expressions cannot be an aggregate.
      Specified by:
      isAggregate in class DBColumnExpr
      Returns:
      false
    • equals

      public boolean equals(Object other)
      Returns true if other is equal to this expression
      Overrides:
      equals in class Object
    • 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.
      Specified by:
      addSQL in class DBExpr
      Parameters:
      sql - the SQL-Command
      context - the current SQL-Command context
    • addXml

      public Element addXml(Element parent, long flags)
      this helper function calls the DBColumnExpr.addXML(Element, long) method
      Specified by:
      addXml in class DBColumnExpr
      Parameters:
      parent - the parent element to which to append the column description
      flags - currently not used
      Returns:
      the newly created child element