Class DBDecodeExpr

All Implemented Interfaces:
ColumnExpr, DBPreparable

public class DBDecodeExpr extends DBAbstractFuncExpr
This class is used to decode a set of keys to the corresponding target values. For most drivers this will be performed by the "case ? when A then X else Y end" statement.

There is no need to explicitly create instances of this class.
Instead use DBColumnExpr.when(org.apache.empire.db.expr.compare.DBCompareExpr, Object)

Author:
doebele
  • Constructor Details

    • DBDecodeExpr

      public DBDecodeExpr(DBColumnExpr expr, Map<?,?> valueMap, Object elseExpr, DataType dataType)
      Constructs a DBDecodeExpr
      Parameters:
      expr - the expression to be decoded
      valueMap - a map of keys and values used for decoding
      elseExpr - the expression returned if the condition is false (may be null)
      dataType - the target data type
  • Method Details

    • getFunctionName

      protected String getFunctionName()
      Description copied from class: DBAbstractFuncExpr
      returns the name of the function
      Specified by:
      getFunctionName in class DBAbstractFuncExpr
      Returns:
      the function name
    • getUpdateColumn

      public DBColumn getUpdateColumn()
      Description copied from class: DBAbstractFuncExpr
      Returns the DBColunm object.
      Specified by:
      getUpdateColumn in interface ColumnExpr
      Overrides:
      getUpdateColumn in class DBAbstractFuncExpr
      Returns:
      the DBColunm object
    • getEnumType

      public Class<Enum<?>> getEnumType()
      Description copied from class: DBAbstractFuncExpr
      Maybe an Enum...
      Specified by:
      getEnumType in interface ColumnExpr
      Overrides:
      getEnumType in class DBAbstractFuncExpr
      Returns:
      the enum type
    • autoParam

      public DBDecodeExpr autoParam()
      Automatically converts all literal values into Value expressions
      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
      Overrides:
      prepareParams in class DBAbstractFuncExpr
      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.
      Overrides:
      addReferencedColumns in class DBAbstractFuncExpr
      Parameters:
      list - list to which all used column expressions must be added
      See Also:
    • addSQL

      public void addSQL(DBSQLBuilder sql, long context)
      Description copied from class: DBExpr
      Used to build the SQL command. SQL for this expression must be appended to StringBuilder.
      Specified by:
      addSQL in class DBExpr
      Parameters:
      sql - the string buffer used to build the sql command
      context - context flag for this SQL-Command (see CTX_??? constants).
    • addDecodeParts

      public void addDecodeParts(DBSQLBuilder sql)