Class ExpressionOperator

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    ListExpressionOperator

    public class ExpressionOperator
    extends java.lang.Object
    implements java.io.Serializable

    Purpose: ADVANCED: The expression operator is used internally to define SQL operations and functions. It is possible for an advanced user to define their own operators.

    See Also:
    Serialized Form
    • Constructor Detail

      • ExpressionOperator

        public ExpressionOperator()
        ADVANCED: Create a new operator.
      • ExpressionOperator

        public ExpressionOperator​(int selector,
                                  java.util.Vector newDatabaseStrings)
        ADVANCED: Create a new operator with the given name(s) and strings to print.
    • Method Detail

      • isBindingSupported

        public java.lang.Boolean isBindingSupported()
        PUBLIC: Return if binding is compatible with this operator.
      • setIsBindingSupported

        @Deprecated
        public void setIsBindingSupported​(java.lang.Boolean isBindingSupported)
        Deprecated.
        PUBLIC: Set if binding is compatible with this operator. Some databases do not allow binding, or require casting with certain operators.
      • equals

        public boolean equals​(java.lang.Object object)
        INTERNAL: Return if the operator is equal to the other.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        INTERNAL: Return the hash-code based on the unique selector.
        Overrides:
        hashCode in class java.lang.Object
      • addOperator

        public static void addOperator​(ExpressionOperator exOperator)
        ADVANCED: Add an operator to the user defined list of operators.
      • registerOperator

        public static void registerOperator​(int selector,
                                            java.lang.String name)
        ADVANCED: Define a name for a user defined operator.
      • applyFunction

        public java.lang.Object applyFunction​(java.lang.Object source,
                                              java.util.Vector arguments)
        INTERNAL: Apply this to an object in memory. Throw an error if the function is not supported.
      • ascending

        public static ExpressionOperator ascending()
        INTERNAL: Create the ASCENDING operator.
      • nullsFirst

        public static ExpressionOperator nullsFirst()
        INTERNAL: Create the NULLS FIRST ordering operator.
      • nullsLast

        public static ExpressionOperator nullsLast()
        INTERNAL: Create the NULLS LAST ordering operator.
      • average

        public static ExpressionOperator average()
        INTERNAL: Create the AVERAGE operator.
      • bePostfix

        public void bePostfix()
        ADVANCED: Tell the operator to be postfix, i.e. its strings start printing after those of its first argument.
      • bePrefix

        public void bePrefix()
        ADVANCED: Tell the operator to be pretfix, i.e. its strings start printing before those of its first argument.
      • beRepeating

        public void beRepeating()
        INTERNAL: Make this a repeating argument. Currently unused.
      • between

        public static ExpressionOperator between()
        INTERNAL: Create the BETWEEN Operator
      • notBetween

        public static ExpressionOperator notBetween()
        INTERNAL: Create the NOT BETWEEN Operator
      • conformBetween

        public boolean conformBetween​(java.lang.Object left,
                                      java.lang.Object right)
        INTERNAL: Compare between in memory.
      • conformLike

        public boolean conformLike​(java.lang.Object left,
                                   java.lang.Object right)
        INTERNAL: Compare like in memory. This only works for % not _.
        Author:
        Christian Weeks aka ChristianLink
      • dateDifference

        public static ExpressionOperator dateDifference()
        INTERNAL: Build operator.
      • oracleDateName

        @Deprecated
        public static ExpressionOperator oracleDateName()
        Deprecated.
        INTERNAL: Oracle equivalent to DATENAME is TO_CHAR.
      • dateToString

        public static ExpressionOperator dateToString()
        INTERNAL: Build operator.
      • toCharWithFormat

        public static ExpressionOperator toCharWithFormat()
        INTERNAL: Build operator.
      • descending

        public static ExpressionOperator descending()
        INTERNAL: Create the DESCENDING operator.
      • distinct

        public static ExpressionOperator distinct()
        INTERNAL: Create the DISTINCT operator.
      • divide

        public static ExpressionOperator divide()
        INTERNAL: Create the DISTINCT operator.
      • doesRelationConform

        public boolean doesRelationConform​(java.lang.Object left,
                                           java.lang.Object right)
        INTERNAL: Compare the values in memory. Used for in-memory querying, all operators are not support.
      • equalOuterJoin

        public static ExpressionOperator equalOuterJoin()
        INTERNAL: Initialize the outer join operator Note: This is merely a shell which is incomplete, and so will be replaced by the platform's operator when we go to print. We need to create this here so that the expression class is correct, normally it assumes functions for unknown operators.
      • exists

        public static ExpressionOperator exists()
        INTERNAL: Create the EXISTS operator.
      • expressionFor

        public Expression expressionFor​(Expression base)
        INTERNAL: Create an expression for this operator, using the given base.
      • expressionFor

        public Expression expressionFor​(Expression base,
                                        java.lang.Object value)
        INTERNAL: Create an expression for this operator, using the given base and a single argument.
      • expressionForWithBaseLast

        public Expression expressionForWithBaseLast​(Expression base,
                                                    java.lang.Object value)
        INTERNAL: Create an expression for this operator, using the given base and a single argument. Base is used last in the expression
      • expressionForArguments

        @Deprecated
        public Expression expressionForArguments​(Expression base,
                                                 java.util.Vector arguments)
        Deprecated.
        INTERNAL: Create an expression for this operator, using the given base and arguments.
      • expressionForArguments

        public Expression expressionForArguments​(Expression base,
                                                 java.util.List arguments)
        INTERNAL: Create an expression for this operator, using the given base and arguments.
      • extractXml

        public static ExpressionOperator extractXml()
        INTERNAL: Create the extract expression operator
      • extractValue

        public static ExpressionOperator extractValue()
        INTERNAL: Create the extractValue expression operator
      • existsNode

        public static ExpressionOperator existsNode()
        INTERNAL: Create the existsNode expression operator
      • getAllOperators

        public static java.util.Map<java.lang.Integer,​ExpressionOperator> getAllOperators()
        ADVANCED: Return the map of all operators.
      • getAllInternalOperators

        public static java.util.Map<java.lang.Integer,​ExpressionOperator> getAllInternalOperators()
        INTERNAL:
      • getPlatformOperatorSelectors

        public static java.util.Map<java.lang.String,​java.lang.Integer> getPlatformOperatorSelectors()
      • getDatabaseStrings

        @Deprecated
        public java.lang.String[] getDatabaseStrings()
        Deprecated.
        INTERNAL:
      • getDatabaseStrings

        public java.lang.String[] getDatabaseStrings​(int arguments)
        INTERNAL:
      • getJavaStrings

        public java.lang.String[] getJavaStrings()
        INTERNAL:
      • getNodeClass

        public java.lang.Class getNodeClass()
        INTERNAL:
      • getOperator

        public static ExpressionOperator getOperator​(java.lang.Integer selector)
        INTERNAL: Lookup the operator with the given id.

        This will only check user defined operators. For operators defined internally, see ExpressionOperator#getInternalOperator()

      • getInternalOperator

        public static ExpressionOperator getInternalOperator​(java.lang.Integer selector)
        INTERNAL: Lookup the internal operator with the given id.
      • getSelector

        public int getSelector()
        INTERNAL: Return the selector id.
      • getName

        public java.lang.String getName()
        INTERNAL: Return the name.
      • setName

        public void setName​(java.lang.String name)
        INTERNAL: Set the name.
      • getType

        public int getType()
        ADVANCED: Return the type of function. This must be one of the static function types defined in this class.
      • greaterThanEqual

        public static ExpressionOperator greaterThanEqual()
        INTERNAL: Build operator.
      • inSubQuery

        public static ExpressionOperator inSubQuery()
        INTERNAL: Create the IN operator taking a subquery. Note, the subquery itself comes with parenethesis, so the IN operator should not add any parenethesis.
      • initializeAggregateFunctionOperators

        protected static void initializeAggregateFunctionOperators()
        INTERNAL:
      • initializeComparisonOperators

        protected static void initializeComparisonOperators()
        INTERNAL:
      • initializeFunctionOperators

        protected static void initializeFunctionOperators()
        INTERNAL:
      • initializeLogicalOperators

        protected static void initializeLogicalOperators()
        INTERNAL:
      • initializeOrderOperators

        protected static void initializeOrderOperators()
        INTERNAL:
      • initializeRelationOperators

        protected static void initializeRelationOperators()
        INTERNAL:
      • initializeOperators

        public static java.util.Map initializeOperators()
        INTERNAL:
      • getPlatformOperatorName

        public static java.lang.String getPlatformOperatorName​(int operator)
        INTERNAL: Initialize a mapping to the platform operator names for usage with exceptions.
      • getPlatformOperatorNames

        public static java.util.Map getPlatformOperatorNames()
        INTERNAL: Initialize a mapping to the platform operator names for usage with exceptions.
      • initializePlatformOperatorNames

        public static java.util.Map<java.lang.Integer,​java.lang.String> initializePlatformOperatorNames()
        INTERNAL: Initialize a mapping to the platform operator names for usage with exceptions.
      • initializePlatformOperatorSelectors

        public static java.util.Map<java.lang.String,​java.lang.Integer> initializePlatformOperatorSelectors()
        INTERNAL: Initialize a mapping to the platform operator names for usage with exceptions.
      • isAggregateOperator

        public boolean isAggregateOperator()
        Aggregate functions are function in the select such as COUNT.
      • isComparisonOperator

        public boolean isComparisonOperator()
        Comparison functions are functions such as = and >.
      • isComplete

        public boolean isComplete()
        INTERNAL: If we have all the required information, this operator is complete and can be used as is. Otherwise we will need to look up a platform- specific operator.
      • isFunctionOperator

        public boolean isFunctionOperator()
        General functions are any normal function such as UPPER.
      • isLogicalOperator

        public boolean isLogicalOperator()
        Logical functions are functions such as and and or.
      • isNull

        public static ExpressionOperator isNull()
        INTERNAL: Create the ISNULL operator.
      • isOrderOperator

        public boolean isOrderOperator()
        Order functions are used in the order by such as ASC.
      • isPrefix

        public boolean isPrefix()
        ADVANCED: Return true if this is a prefix operator.
      • leftTrim2

        public static ExpressionOperator leftTrim2()
        INTERNAL: Build leftTrim operator that takes one parameter.
      • regexp

        public static ExpressionOperator regexp()
        INTERNAL: Create the REGEXP operator. REGEXP allows for comparison through regular expression, this is supported by many databases and with be part of the next SQL standard.
      • likeEscape

        public static ExpressionOperator likeEscape()
        INTERNAL: Create the LIKE operator with ESCAPE.
      • notLikeEscape

        public static ExpressionOperator notLikeEscape()
        INTERNAL: Create the LIKE operator with ESCAPE.
      • locate

        public static ExpressionOperator locate()
        INTERNAL: Build locate operator i.e. LOCATE("ob", t0.F_NAME)
      • locate2

        public static ExpressionOperator locate2()
        INTERNAL: Build locate operator with 3 params i.e. LOCATE("coffee", t0.DESCRIP, 4). Last parameter is a start at.
      • maximum

        public static ExpressionOperator maximum()
        INTERNAL: Create the MAXIMUM operator.
      • minimum

        public static ExpressionOperator minimum()
        INTERNAL: Create the MINIMUM operator.
      • monthsBetween

        public static ExpressionOperator monthsBetween()
        INTERNAL: Build operator.
      • newExpressionForArgument

        public Expression newExpressionForArgument​(Expression base,
                                                   java.lang.Object singleArgument)
        INTERNAL: Create a new expression. Optimized for the single argument case.
      • createNode

        protected Expression createNode()
        INTERNAL: Instantiate an instance of the operator's node class.
      • newExpressionForArgumentWithBaseLast

        public Expression newExpressionForArgumentWithBaseLast​(Expression base,
                                                               java.lang.Object singleArgument)
        INTERNAL: Create a new expression. Optimized for the single argument case with base last
      • newExpressionForArguments

        public Expression newExpressionForArguments​(Expression base,
                                                    java.util.List arguments)
        INTERNAL: The general case.
      • notExists

        public static ExpressionOperator notExists()
        INTERNAL: Create the NOT EXISTS operator.
      • notInSubQuery

        public static ExpressionOperator notInSubQuery()
        INTERNAL: Create the NOTIN operator taking a subQuery. Note, the subquery itself comes with parenethesis, so the IN operator should not add any parenethesis.
      • notLike

        public static ExpressionOperator notLike()
        INTERNAL: Create the NOTLIKE operator.
      • notNull

        public static ExpressionOperator notNull()
        INTERNAL: Create the NOTNULL operator.
      • notOperator

        public static ExpressionOperator notOperator()
        INTERNAL: Create the NOT operator.
      • printCollection

        public void printCollection​(java.util.List<Expression> items,
                                    org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter printer)
        INTERNAL: Print the collection onto the SQL stream.
      • printJavaCollection

        public void printJavaCollection​(java.util.Vector<Expression> items,
                                        org.eclipse.persistence.internal.expressions.ExpressionJavaPrinter printer)
        INTERNAL: Print the collection onto the SQL stream.
      • printDuo

        public void printDuo​(Expression first,
                             Expression second,
                             org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter printer)
        INTERNAL: For performance, special case printing two children, since it's by far the most common
      • printJavaDuo

        public void printJavaDuo​(Expression first,
                                 Expression second,
                                 org.eclipse.persistence.internal.expressions.ExpressionJavaPrinter printer)
        INTERNAL: For performance, special case printing two children, since it's by far the most common
      • printsAs

        public void printsAs​(java.lang.String s)
        ADVANCED: Set the single string for this operator.
      • printsAs

        public void printsAs​(java.util.Vector dbStrings)
        ADVANCED: Set the strings for this operator.
      • printsJavaAs

        public void printsJavaAs​(java.lang.String s)
        ADVANCED: Set the single string for this operator.
      • printsJavaAs

        public void printsJavaAs​(java.util.Vector dbStrings)
        ADVANCED: Set the strings for this operator.
      • resetOperators

        public static void resetOperators()
        INTERNAL: Reset all the operators.
      • rightTrim2

        public static ExpressionOperator rightTrim2()
        INTERNAL: Build rightTrim operator that takes one parameter.
        Related Bugs:
        2916893 rightTrim(substring) broken.
      • setArgumentIndices

        public void setArgumentIndices​(int[] indices)
        ADVANCED: Set the array of indexes to use when building the SQL function. The index of the array is the position in the printout, from left to right, starting with zero. The value of the array entry is the number of the argument to print at that particular output position. So each argument can be used zero, one or many times.
      • setNodeClass

        public void setNodeClass​(java.lang.Class nodeClass)
        ADVANCED: Set the node class for this operator. For user-defined functions this is set automatically but can be changed.

        A list of Operator types, an example, and the node class used follows.

        LogicalOperator AND LogicalExpression

        ComparisonOperator <> RelationExpression

        AggregateOperator COUNT FunctionExpression

        OrderOperator ASCENDING "

        FunctionOperator RTRIM "

        Node classes given belong to org.eclipse.persistence.internal.expressions.

      • setSelector

        public void setSelector​(int selector)
        INTERNAL: Set the selector id.
      • setType

        public void setType​(int type)
        ADVANCED: Set the type of function. This must be one of the static function types defined in this class.
      • simpleAggregate

        public static ExpressionOperator simpleAggregate​(int selector,
                                                         java.lang.String databaseName,
                                                         java.lang.String javaName)
        INTERNAL: Create an operator for a simple aggregate given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleFunction

        public static ExpressionOperator simpleFunction​(int selector,
                                                        java.lang.String databaseName)
        INTERNAL: Create an operator for a simple function given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleFunctionNoParentheses

        public static ExpressionOperator simpleFunctionNoParentheses​(int selector,
                                                                     java.lang.String databaseName)
        INTERNAL: Create an operator for a simple function call without parentheses
      • simpleFunction

        public static ExpressionOperator simpleFunction​(int selector,
                                                        java.lang.String databaseName,
                                                        java.lang.String javaName)
        INTERNAL: Create an operator for a simple function given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleLogical

        public static ExpressionOperator simpleLogical​(int selector,
                                                       java.lang.String databaseName,
                                                       java.lang.String javaName)
        INTERNAL: Create an operator for a simple logical given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleMath

        public static ExpressionOperator simpleMath​(int selector,
                                                    java.lang.String databaseName)
        INTERNAL: Create an operator for a simple math operation, i.e. +, -, *, /
      • simpleOrdering

        public static ExpressionOperator simpleOrdering​(int selector,
                                                        java.lang.String databaseName,
                                                        java.lang.String javaName)
        INTERNAL: Create an operator for a simple ordering given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleRelation

        public static ExpressionOperator simpleRelation​(int selector,
                                                        java.lang.String databaseName)
        INTERNAL: Create an operator for a simple relation given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleRelation

        public static ExpressionOperator simpleRelation​(int selector,
                                                        java.lang.String databaseName,
                                                        java.lang.String javaName)
        INTERNAL: Create an operator for a simple relation given a Java name and a single String for the database (parentheses will be added automatically).
      • simpleThreeArgumentFunction

        public static ExpressionOperator simpleThreeArgumentFunction​(int selector,
                                                                     java.lang.String dbString)
        INTERNAL: Build operator.
      • simpleTwoArgumentFunction

        public static ExpressionOperator simpleTwoArgumentFunction​(int selector,
                                                                   java.lang.String dbString)
        INTERNAL: Build operator.
      • simpleLogicalNoParens

        public static ExpressionOperator simpleLogicalNoParens​(int selector,
                                                               java.lang.String dbString)
        INTERNAL: e.g.: ... "Bob" CONCAT "Smith" ... Parentheses will not be addded. [RMB - March 5 2000]
      • standardDeviation

        public static ExpressionOperator standardDeviation()
        INTERNAL: Build operator.
      • substringSingleArg

        public static ExpressionOperator substringSingleArg()
        INTERNAL: Build operator.
      • sybaseAddMonthsOperator

        @Deprecated
        public static ExpressionOperator sybaseAddMonthsOperator()
        Deprecated.
        INTERNAL: Function, to add months to a date.
      • sybaseAtan2Operator

        @Deprecated
        public static ExpressionOperator sybaseAtan2Operator()
        Deprecated.
        INTERNAL: Build operator.
      • sybaseInStringOperator

        @Deprecated
        public static ExpressionOperator sybaseInStringOperator()
        Deprecated.
        INTERNAL: Build instring operator
      • sybaseToNumberOperator

        @Deprecated
        public static ExpressionOperator sybaseToNumberOperator()
        Deprecated.
        INTERNAL: Build Sybase equivalent to TO_NUMBER.
      • sybaseToDateToStringOperator

        @Deprecated
        public static ExpressionOperator sybaseToDateToStringOperator()
        Deprecated.
        INTERNAL: Build Sybase equivalent to TO_CHAR.
      • sybaseToDateOperator

        @Deprecated
        public static ExpressionOperator sybaseToDateOperator()
        Deprecated.
        INTERNAL: Build Sybase equivalent to TO_DATE.
      • sybaseToCharOperator

        @Deprecated
        public static ExpressionOperator sybaseToCharOperator()
        Deprecated.
        INTERNAL: Build Sybase equivalent to TO_CHAR.
      • sybaseToCharWithFormatOperator

        @Deprecated
        public static ExpressionOperator sybaseToCharWithFormatOperator()
        Deprecated.
        INTERNAL: Build Sybase equivalent to TO_CHAR.
      • sybaseLocateOperator

        @Deprecated
        public static ExpressionOperator sybaseLocateOperator()
        Deprecated.
        INTERNAL: Build the Sybase equivalent to Locate
      • sybaseLocate2Operator

        @Deprecated
        public static ExpressionOperator sybaseLocate2Operator()
        Deprecated.
        INTERNAL: Build the Sybase equivalent to Locate with a start index. Sybase does not define this, so this gets a little complex...
      • currentTimeStamp

        public static ExpressionOperator currentTimeStamp()
        INTERNAL: Build operator.
      • toLowerCase

        public static ExpressionOperator toLowerCase()
        INTERNAL: Create the toLowerCase operator.
      • toString

        public java.lang.String toString()
        Print a debug representation of this operator.
        Overrides:
        toString in class java.lang.Object
      • toUpperCase

        public static ExpressionOperator toUpperCase()
        INTERNAL: Create the TOUPPERCASE operator.
      • truncateDate

        public static ExpressionOperator truncateDate()
        INTERNAL: Build operator.
      • unionAll

        public static ExpressionOperator unionAll()
        INTERNAL: Create the UNION ALL operator.
      • intersect

        public static ExpressionOperator intersect()
        INTERNAL: Create the INTERSECT operator.
      • intersectAll

        public static ExpressionOperator intersectAll()
        INTERNAL: Create the INTERSECT ALL operator.
      • except

        public static ExpressionOperator except()
        INTERNAL: Create the EXCEPT operator.
      • exceptAll

        public static ExpressionOperator exceptAll()
        INTERNAL: Create the EXCEPT ALL operator.
      • isAny

        public boolean isAny()
        INTERNAL: Indicates whether operator has selector Any or Some
      • isAll

        public boolean isAll()
        INTERNAL: Indicates whether operator has selector All
      • isAnyOrAll

        public boolean isAnyOrAll()
        INTERNAL: Indicates whether operator has selector Any, Some or All