Class ParserUtils


  • public class ParserUtils
    extends Object
    Class for holding Parser specific utility functions.
    • Method Detail

      • getFilterType

        public static FilterOperator getFilterType​(Expression expression)
        Utility method that returns the FilterOperator for a given expression. Assumes that the passed in expression is a filter expression.
        Parameters:
        expression - Expression for which to get the filter type
        Returns:
        Filter Operator for the given Expression.
      • getFilterKind

        public static FilterKind getFilterKind​(Expression expression)
        Utility method that returns the FilterKind for a given expression. Assumes that the passed in expression is a filter expression.
        Parameters:
        expression - Expression for which to get the filter type
        Returns:
        Filter Kind for the given Expression.
      • filterKindToOperator

        public static FilterOperator filterKindToOperator​(FilterKind filterKind)
        Utility method to map FilterKind to FilterOperator.
        Parameters:
        filterKind - Filter kind for which to get the Filter Operator
        Returns:
        Filter Operator for the given Filter kind
      • getFilterColumn

        public static String getFilterColumn​(Expression expression)
        Returns the filter column from a given expression. Assumes that the passed expression is a filter expression of form LHS Operator RHS. LHS is expected to be a single column name.
        Parameters:
        expression - Filter expression
        Returns:
      • getFilterValues

        public static List<String> getFilterValues​(Expression filterExpression)
        Utility method that returns the RHS of a filter expression as a list of String's.
        Parameters:
        filterExpression - Filter expression
        Returns:
        RHS of the filter expression
      • getFilterValues

        public static List<String> getFilterValues​(FilterKind filterKind,
                                                   List<Expression> operands)
        Given a expression filter, returns the values (RHS) on which the filter predicate applies.
        Parameters:
        filterKind - Kind of filter
        operands - Filter operands
        Returns:
        Values to filter on, as a list of strings.
      • standardizeExpression

        public static String standardizeExpression​(Expression expression,
                                                   boolean treatLiteralAsIdentifier)
        Standardizes a given expression, by quoting String literals.
        Parameters:
        expression - Expression to standardize
        treatLiteralAsIdentifier - If true, literals are not quoted
        Returns:
        Standardized expression
      • standardizeExpression

        public static String standardizeExpression​(Expression expression,
                                                   boolean treatLiteralAsIdentifier,
                                                   boolean forceSingleQuoteOnNonStringLiteral)
      • standardizeFunction

        public static String standardizeFunction​(Function functionCall)
        Standardizes a function call by quoting literal operands.
        Parameters:
        functionCall - Function call to standardize
        Returns:
        Standardized String equivalent of the Function.