Class CoreOperation

Direct Known Subclasses:
CoreOperationAdd, CoreOperationAnd, CoreOperationCompare, CoreOperationDivide, CoreOperationMod, CoreOperationMultiply, CoreOperationNegate, CoreOperationOr, CoreOperationRelationalExpression, CoreOperationSubtract, CoreOperationUnion

public abstract class CoreOperation extends Operation
The common subclass for tree elements representing core operations like "+", "- ", "*" etc.
Version:
$Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
  • Field Details

    • OR_PRECEDENCE

      protected static final int OR_PRECEDENCE
      or precedence
      See Also:
    • AND_PRECEDENCE

      protected static final int AND_PRECEDENCE
      and precedence
      See Also:
    • COMPARE_PRECEDENCE

      protected static final int COMPARE_PRECEDENCE
      compare precedence
      See Also:
    • RELATIONAL_EXPR_PRECEDENCE

      protected static final int RELATIONAL_EXPR_PRECEDENCE
      relational expression precedence
      See Also:
    • ADD_PRECEDENCE

      protected static final int ADD_PRECEDENCE
      add/subtract precedence
      See Also:
    • MULTIPLY_PRECEDENCE

      protected static final int MULTIPLY_PRECEDENCE
      multiply/divide/mod precedence
      See Also:
    • NEGATE_PRECEDENCE

      protected static final int NEGATE_PRECEDENCE
      negate precedence
      See Also:
    • UNION_PRECEDENCE

      protected static final int UNION_PRECEDENCE
      union precedence
      See Also:
  • Constructor Details

    • CoreOperation

      public CoreOperation(Expression[] args)
      Create a new CoreOperation.
      Parameters:
      args - Expression[]
  • Method Details

    • compute

      public Object compute(EvalContext context)
      Description copied from class: Expression
      Evaluates the expression. If the result is a node set, returns the first element of the node set.
      Specified by:
      compute in class Expression
      Parameters:
      context - evaluation context
      Returns:
      Object
    • computeValue

      public abstract Object computeValue(EvalContext context)
      Description copied from class: Expression
      Evaluates the expression. If the result is a node set, returns the first element of the node set.
      Specified by:
      computeValue in class Expression
      Parameters:
      context - evaluation context
      Returns:
      Object
    • getSymbol

      public abstract String getSymbol()
      Returns the XPath symbol for this operation, e.g. "+", "div", etc.
      Returns:
      String symbol
    • isSymmetric

      protected abstract boolean isSymmetric()
      Returns true if the operation is not sensitive to the order of arguments, e.g. "=", "and" etc, and false if it is, e.g. "<=", "div".
      Returns:
      boolean
    • getPrecedence

      protected abstract int getPrecedence()
      Computes the precedence of the operation.
      Returns:
      int precedence
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parenthesize

      private String parenthesize(Expression expression, boolean left)
      Wrap an expression in parens if necessary.
      Parameters:
      expression - other Expression
      left - whether expression is left of this one.
      Returns:
      String