Class CompareToStringConstant

  • All Implemented Interfaces:
    ComparisonExpression, ExportAgent, Locatable, IdentityComparable, Traceable

    public class CompareToStringConstant
    extends CompareToConstant
    This class implements a comparison of a computed value to a string constant using one of the operators eq, ne, lt, gt, le, ge. The semantics are identical to ValueComparison, with code-point collation, but this is a fast path for an important common case.
    • Constructor Detail

      • CompareToStringConstant

        public CompareToStringConstant​(Expression operand,
                                       int operator,
                                       java.lang.String comparand)
        Create the expression
        Parameters:
        operand - the operand to be compared with an integer constant. This must have a static type of NUMERIC, and a cardinality of EXACTLY ONE
        operator - the comparison operator, one of Token.FEQ, Token.FNE, Token.FGE, Token.FGT, Token.FLE, Token.FLT
        comparand - the integer constant
    • Method Detail

      • getComparand

        public java.lang.String getComparand()
        Get the integer value on the rhs of the expression
        Returns:
        the integer constant
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        Parameters:
        rebindings - variables that need to be re-bound
        Returns:
        the copy of the original expression
      • equals

        public boolean equals​(java.lang.Object other)
        Is this expression the same as another expression?
        Overrides:
        equals in class UnaryExpression
        Parameters:
        other - the expression to be compared with this one
        Returns:
        true if the two expressions are statically equivalent
      • computeHashCode

        public int computeHashCode()
        Hashcode supporting equals()
        Overrides:
        computeHashCode in class UnaryExpression
        Returns:
        a computed hash code
      • effectiveBooleanValue

        public boolean effectiveBooleanValue​(XPathContext context)
                                      throws XPathException
        Get the effective boolean value of the expression. This returns false if the value is the empty sequence, a zero-length string, a number equal to zero, or the boolean false. Otherwise it returns true.
        Overrides:
        effectiveBooleanValue in class Expression
        Parameters:
        context - The context in which the expression is to be evaluated
        Returns:
        the effective boolean value
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • 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 export() output displaying the expression.
      • export

        public void export​(ExpressionPresenter destination)
                    throws XPathException
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Overrides:
        export in class UnaryExpression
        Parameters:
        destination - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
      • toString

        public java.lang.String toString()

        The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

        For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression

        Overrides:
        toString in class UnaryExpression
        Returns:
        a representation of the expression as a string
      • toShortString

        public java.lang.String toShortString()
        Produce a short string identifying the expression for use in error messages
        Overrides:
        toShortString in class UnaryExpression
        Returns:
        a short string, sufficient to identify the expression
      • getAtomicComparer

        public AtomicComparer getAtomicComparer()
        Get the AtomicComparer used to compare atomic values. This encapsulates any collation that is used