Class DBValueExpr

All Implemented Interfaces:
ColumnExpr, DBPreparable

public class DBValueExpr extends DBColumnExpr implements DBPreparable
This class is used for declaring constant values in SQL.

There is no need to explicitly create instances of this class.
Instead use DBDatabase.getValueExpr(String) or one of it's overloads

  • Field Details

    • IGNORE_CASE_CONTEXT

      public static String IGNORE_CASE_CONTEXT
    • db

      public final DBDatabase db
    • type

      public final DataType type
    • value

      protected Object value
  • Constructor Details

    • DBValueExpr

      @Deprecated public DBValueExpr(DBDatabase db, Object value, DataType type)
      Deprecated.
      please use DBDatabase.getValueExpr(...) The constructor will be made protected in future versions
      Constructs a new DBValueExpr object.
      Parameters:
      db - the database
      value - the value for this constant
      type - the data type for this constant
  • Method Details

    • getValue

      public Object getValue()
      return the value associated with this value expression
      Returns:
      the current value
    • setValue

      public void setValue(Object value)
      set the value associated with this value expression
      Parameters:
      value - the value to set
    • 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 EnumType if the value is an Enum
      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
    • getIgnoreCaseExpr

      public DBColumnExpr getIgnoreCaseExpr(DBColumnExpr context)
      Returns an expression which ignores the case Only for case sensitive columns! Default is upper(expr)
      Parameters:
      context - the column context
      Returns:
      the ignore case expression or the expression itself
    • literal

      public DBValueExpr literal()
      Set literal mode, i.e. the value will be placed in the sql statement Otherwise it may be automatically replaced by a parameter ?
      Returns:
      self (this)
    • autoParam

      public DBValueExpr autoParam()
      Sets literal mode off, i.e. the value may passed as a parameter and referenced by a ? in the sql statement
      Returns:
      self (this)
    • 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