/** * Is this expression the same as another expression? * * @param other the expression to be compared with this one * @return true if the two expressions are statically equivalent */ @Override public boolean equals(Object other) { return other instanceof CompareToIntegerConstant && ((CompareToIntegerConstant)other).getLhsExpression().isEqual(getLhsExpression()) && ((CompareToIntegerConstant)other).comparand == comparand && ((CompareToIntegerConstant)other).operator == operator; }
/** * Is this expression the same as another expression? * * @param other the expression to be compared with this one * @return true if the two expressions are statically equivalent */ @Override public boolean equals(Object other) { return other instanceof CompareToIntegerConstant && ((CompareToIntegerConstant)other).getLhsExpression().isEqual(getLhsExpression()) && ((CompareToIntegerConstant)other).comparand == comparand && ((CompareToIntegerConstant)other).operator == operator; }
/** * Produce a short string identifying the expression for use in error messages * * @return a short string, sufficient to identify the expression */ @Override public String toShortString() { return getLhsExpression().toShortString() + " " + Token.tokens[operator] + " " + comparand; }
/** * Hashcode supporting equals() */ public int computeHashCode() { int h = 0x836b12a0; return h + getLhsExpression().hashCode() ^ (int)comparand; }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression</p> * * @return a representation of the expression as a string */ @Override public String toString() { return ExpressionTool.parenthesize(getLhsExpression()) + " " + Token.tokens[operator] + " " + comparand; }
/** * Hashcode supporting equals() */ public int computeHashCode() { int h = 0x836b12a0; return h + getLhsExpression().hashCode() ^ (int)comparand; }
/** * Produce a short string identifying the expression for use in error messages * * @return a short string, sufficient to identify the expression */ @Override public String toShortString() { return getLhsExpression().toShortString() + " " + Token.tokens[operator] + " " + comparand; }
/** * <p>The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form.</p> * <p>For subclasses of Expression that represent XPath expressions, the result should always be a string that * parses as an XPath 3.0 expression</p> * * @return a representation of the expression as a string */ @Override public String toString() { return ExpressionTool.parenthesize(getLhsExpression()) + " " + Token.tokens[operator] + " " + comparand; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { CompareToIntegerConstant c2 = new CompareToIntegerConstant(getLhsExpression().copy(rebindings), operator, comparand); ExpressionTool.copyLocationInfo(this, c2); return c2; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { CompareToIntegerConstant c2 = new CompareToIntegerConstant(getLhsExpression().copy(rebindings), operator, comparand); ExpressionTool.copyLocationInfo(this, c2); return c2; }
NumericValue n = (NumericValue) getLhsExpression().evaluateItem(context); if (n.isNaN()) { return operator == Token.FNE;
NumericValue n = (NumericValue) getLhsExpression().evaluateItem(context); if (n.isNaN()) { return operator == Token.FNE;
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter destination) throws XPathException { destination.startElement("compareToInt", this); destination.emitAttribute("op", Token.tokens[operator]); destination.emitAttribute("val", comparand + ""); getLhsExpression().export(destination); destination.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter destination) throws XPathException { destination.startElement("compareToInt", this); destination.emitAttribute("op", Token.tokens[operator]); destination.emitAttribute("val", comparand + ""); getLhsExpression().export(destination); destination.endElement(); }
/** * Perform optimisation of an expression and its subexpressions. This is the third and final * phase of static optimization. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor the expression visitor * @param 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 * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getLhsExpression() instanceof Literal) { return Literal.makeLiteral(BooleanValue.get(effectiveBooleanValue(null)), this); } return this; }
/** * Perform optimisation of an expression and its subexpressions. This is the third and final * phase of static optimization. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor the expression visitor * @param 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 * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getLhsExpression() instanceof Literal) { return Literal.makeLiteral(BooleanValue.get(effectiveBooleanValue(null)), this); } return this; }