Class GeneralComparison

    • Field Detail

      • singletonOperator

        protected int singletonOperator
      • needsRuntimeCheck

        protected boolean needsRuntimeCheck
      • doneWarnings

        protected boolean doneWarnings
    • Constructor Detail

      • GeneralComparison

        public GeneralComparison​(Expression p0,
                                 int op,
                                 Expression p1)
        Create a relational expression identifying the two operands and the operator
        Parameters:
        p0 - the left-hand operand
        op - the operator, as a token returned by the Tokenizer (e.g. Token.LT)
        p1 - the right-hand operand
    • Method Detail

      • needsRuntimeCheck

        public boolean needsRuntimeCheck()
        Ask whether a runtime check of the types of the operands is needed
        Returns:
        true if the types of the operands need to be checked at run-time
      • setNeedsRuntimeCheck

        public void setNeedsRuntimeCheck​(boolean needsCheck)
        Say whether a runtime check of the types of the operands is needed
        Parameters:
        needsCheck - true if the types of the operands need to be checked at run-time
      • setAtomicComparer

        public void setAtomicComparer​(AtomicComparer comparer)
        Set the comparer to be used
        Parameters:
        comparer - the comparer to be used
      • getExpressionName

        public java.lang.String getExpressionName()
        Get a name identifying the kind of expression, in terms meaningful to a user.
        Overrides:
        getExpressionName in class Expression
        Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
      • getNamespaceResolver

        public NamespaceResolver getNamespaceResolver()
        Get the namespace context for this expression, needed in the event that one operand contains untyped atomic values and the other contains QNames
      • getSingletonOperator

        public int getSingletonOperator()
        Get the primitive (singleton) operator used: one of Token.FEQ, Token.FNE, Token.FLT, Token.FGT, Token.FLE, Token.FGE
        Specified by:
        getSingletonOperator in interface ComparisonExpression
      • convertsUntypedToOther

        public boolean convertsUntypedToOther()
        Determine whether untyped atomic values should be converted to the type of the other operand
        Specified by:
        convertsUntypedToOther in interface ComparisonExpression
        Returns:
        true if untyped values should be converted to the type of the other operand, false if they should be converted to strings.
      • typeCheck

        public Expression typeCheck​(ExpressionVisitor visitor,
                                    ContextItemStaticInfo contextInfo)
                             throws XPathException
        Type-check the expression
        Overrides:
        typeCheck in class BinaryExpression
        Parameters:
        visitor - an expression visitor
        contextInfo - Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.
        Returns:
        the checked expression
        Throws:
        XPathException - if an error is discovered during this phase (typically a type error)
      • getIntrinsicDependencies

        public int getIntrinsicDependencies()
        Description copied from class: Expression
        Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
        Overrides:
        getIntrinsicDependencies in class Expression
        Returns:
        a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from class: BinaryExpression
        Is this expression the same as another expression?
        Overrides:
        equals in class BinaryExpression
        Parameters:
        other - the other operand; the result is false if this is not an Expression
        Returns:
        true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
      • optimize

        public Expression optimize​(ExpressionVisitor visitor,
                                   ContextItemStaticInfo contextInfo)
                            throws XPathException
        Optimize the expression
        Overrides:
        optimize in class BinaryExpression
        Parameters:
        visitor - an expression visitor
        contextInfo - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to Type.ITEM_TYPE
        Returns:
        the checked expression
        Throws:
        XPathException - if an error is discovered during this phase (typically a type error)
      • evaluateItem

        public BooleanValue evaluateItem​(XPathContext context)
                                  throws XPathException
        Evaluate the expression in a given context
        Overrides:
        evaluateItem in class Expression
        Parameters:
        context - the given context for evaluation
        Returns:
        a BooleanValue representing the result of the numeric comparison of the two operands
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • call

        public BooleanValue call​(XPathContext context,
                                 Sequence[] arguments)
                          throws XPathException
        Evaluate the expression
        Specified by:
        call in interface Callable
        Parameters:
        context - the dynamic evaluation context
        arguments - the values of the arguments, supplied as SequenceIterators
        Returns:
        the result of the evaluation, in the form of a SequenceIterator
        Throws:
        XPathException - if a dynamic error occurs during the evaluation of the expression
      • effectiveBooleanValue

        public boolean effectiveBooleanValue​(XPathContext context)
                                      throws XPathException
        Evaluate the expression in a boolean context
        Overrides:
        effectiveBooleanValue in class Expression
        Parameters:
        context - the given context for evaluation
        Returns:
        a boolean representing the result of the numeric comparison of the two operands
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • evaluateManyToMany

        public boolean evaluateManyToMany​(SequenceIterator iter0,
                                          SequenceIterator iter1,
                                          XPathContext context)
                                   throws XPathException
        Evaluate a (zero-or-one)-to-(zero-or-one) comparison
        Parameters:
        iter0 - iterator over the first value
        iter1 - iterator the second value
        context - dynamic evaluation context
        Returns:
        the comparison result
        Throws:
        XPathException - if a dynamic error occurs
      • compare

        public static boolean compare​(AtomicValue a0,
                                      int operator,
                                      AtomicValue a1,
                                      AtomicComparer comparer,
                                      boolean checkTypes,
                                      XPathContext context,
                                      NamespaceResolver nsResolver)
                               throws XPathException
        Compare two atomic values
        Parameters:
        a0 - the first value
        operator - the singleton version of the comparison operator, for example Token.FEQ
        a1 - the second value
        comparer - the comparer to be used to perform the comparison. If the comparer is context-sensitive then the context must already have been bound using comparer.provideContext().
        checkTypes - set to true if the operand types need to be checked for comparability at runtime
        context - the XPath evaluation context
        nsResolver - namespace resolver
        Returns:
        true if the comparison succeeds
        Throws:
        XPathException - if a dynamic error occurs during the comparison
      • getItemType

        public ItemType getItemType()
        Determine the data type of the expression
        Specified by:
        getItemType in class Expression
        Returns:
        the value BuiltInAtomicType.BOOLEAN
      • getStaticUType

        public UType getStaticUType​(UType contextItemType)
        Get the static type of the expression as a UType, following precisely the type inference rules defined in the XSLT 3.0 specification.
        Overrides:
        getStaticUType in class Expression
        Parameters:
        contextItemType - static information about the context item
        Returns:
        the static item type of the expression according to the XSLT 3.0 defined rules
      • getCorrespondingSingletonOperator

        public static int getCorrespondingSingletonOperator​(int op)
        Return the singleton form of the comparison operator, e.g. FEQ for EQUALS, FGT for GT
        Parameters:
        op - the many-to-many form of the operator, for example Token.LE
        Returns:
        the corresponding singleton operator, for example Token.FLE
      • getStreamerName

        public java.lang.String getStreamerName()
        Get the (partial) name of a class that supports streaming of this kind of expression
        Overrides:
        getStreamerName in class Expression
        Returns:
        the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
      • tag

        public java.lang.String tag()
        Get the element name used to identify this expression in exported expression format
        Overrides:
        tag in class BinaryExpression
        Returns:
        the element name used to identify this expression
      • explainExtraAttributes

        protected void explainExtraAttributes​(ExpressionPresenter out)
        Description copied from class: BinaryExpression
        Add subclass-specific attributes to the expression tree explanation. Default implementation does nothing; this is provided for subclasses to override.
        Overrides:
        explainExtraAttributes in class BinaryExpression
        Parameters:
        out - the output destination for the displayed expression tree