Class CastExpression

  • All Implemented Interfaces:
    Expression

    public final class CastExpression
    extends AbstractSingleEncapsulatedExpression
    The CAST function cast value to a different type. The database type is the second parameter, and can be any valid database type including size and scale.
    BNF: expression ::= CAST(scalar_expression [AS] database_type)
    Since:
    2.4
    Version:
    2.5
    Author:
    James Sutherland
    See Also:
    DatabaseType
    • Constructor Detail

      • CastExpression

        public CastExpression​(AbstractExpression parent)
        Creates a new CastExpression.
        Parameters:
        parent - The parent of this expression
    • Method Detail

      • getDatabaseType

        public Expression getDatabaseType()
        Returns the database type to cast to.
        Returns:
        The Expression representing the database type
      • hasAs

        public boolean hasAs()
        Determines whether the identifier AS was part of the query.
        Returns:
        true if the identifier AS was parsed; false otherwise
      • hasDatabaseType

        public boolean hasDatabaseType()
        Determines whether the database type was parsed or not.
        Returns:
        true if the database type was parsed; false otherwise
      • hasScalarExpression

        public boolean hasScalarExpression()
        Determines whether something was parsed after the left parenthesis and before the AS identifier.
        Returns:
        true the expression to be cast was parsed; false otherwise
        Since:
        2.5
      • hasSpaceAfterAs

        public boolean hasSpaceAfterAs()
        Determines whether a whitespace parsed after AS.
        Returns:
        true if there was a whitespace parsed after AS; false otherwise
      • hasSpaceAfterExpression

        public boolean hasSpaceAfterExpression()
        Determines whether a whitespace was parsed after the expression.
        Returns:
        true if there was a whitespace parsed after the expression; false otherwise