Class SqlCase

All Implemented Interfaces:
Cloneable

public class SqlCase extends SqlCall
A SqlCase is a node of a parse tree which represents a case statement. It warrants its own node type just because we have a lot of methods to put somewhere.
  • Constructor Details

    • SqlCase

      public SqlCase(SqlParserPos pos, @Nullable SqlNode value, SqlNodeList whenList, SqlNodeList thenList, @Nullable SqlNode elseExpr)
      Creates a SqlCase expression.
      Parameters:
      pos - Parser position
      value - The value (null for boolean case)
      whenList - List of all WHEN expressions
      thenList - List of all THEN expressions
      elseExpr - The implicit or explicit ELSE expression
  • Method Details

    • createSwitched

      public static SqlCase createSwitched(SqlParserPos pos, @Nullable SqlNode value, SqlNodeList whenList, SqlNodeList thenList, @Nullable SqlNode elseClause)
      Creates a call to the switched form of the CASE operator. For example:
      CASE value
      WHEN whenList[0] THEN thenList[0]
      WHEN whenList[1] THEN thenList[1]
      ...
      ELSE elseClause
      END
    • getKind

      public SqlKind getKind()
      Description copied from class: SqlNode
      Returns the type of node this is, or SqlKind.OTHER if it's nothing special.
      Overrides:
      getKind in class SqlCall
      Returns:
      a SqlKind value, never null
      See Also:
    • getOperator

      public SqlOperator getOperator()
      Specified by:
      getOperator in class SqlCall
    • getOperandList

      public List<SqlNode> getOperandList()
      Description copied from class: SqlCall
      Returns the list of operands. The set and order of operands is call-specific.

      Note: the proper type would be List<@Nullable SqlNode>, however, it would trigger too many changes to the current codebase.

      Specified by:
      getOperandList in class SqlCall
      Returns:
      the list of call operands, never null, the operands can be null
    • setOperand

      public void setOperand(int i, @Nullable SqlNode operand)
      Description copied from class: SqlCall
      Changes the value of an operand. Allows some rewrite by SqlValidator; use sparingly.
      Overrides:
      setOperand in class SqlCall
      Parameters:
      i - Operand index
      operand - Operand value
    • getValueOperand

      public @Nullable SqlNode getValueOperand()
    • getWhenOperands

      public SqlNodeList getWhenOperands()
    • getThenOperands

      public SqlNodeList getThenOperands()
    • getElseOperand

      public @Nullable SqlNode getElseOperand()