Package net.sf.saxon.expr
Class CompareToIntegerConstant
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.UnaryExpression
-
- net.sf.saxon.expr.CompareToConstant
-
- net.sf.saxon.expr.CompareToIntegerConstant
-
- All Implemented Interfaces:
ComparisonExpression
,ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class CompareToIntegerConstant extends CompareToConstant
This class implements a comparison of a numeric value to an integer constant using one of the operators eq, ne, lt, gt, le, ge. The semantics are identical to ValueComparison, but this is a fast path for an important common case.
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.CompareToConstant
operator
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description CompareToIntegerConstant(Expression operand, int operator, long comparand)
Create the expression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeCardinality()
Determine the static cardinality.int
computeHashCode()
Hashcode supporting equals()Expression
copy(RebindingMap rebindings)
Copy an expression.boolean
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.boolean
equals(java.lang.Object other)
Is this expression the same as another expression?void
export(ExpressionPresenter destination)
Diagnostic print of expression structure.AtomicComparer
getAtomicComparer()
Get the AtomicComparer used to compare atomic values.long
getComparand()
Get the integer value on the rhs of the expressionjava.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.Expression
getRhsExpression()
Get the effective right-hand-side expression (so that general logic for comparison expressions can be used)java.lang.String
toShortString()
Produce a short string identifying the expression for use in error messagesjava.lang.String
toString()
The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.-
Methods inherited from class net.sf.saxon.expr.CompareToConstant
computeSpecialProperties, convertsUntypedToOther, evaluateItem, getComparisonOperator, getImplementationMethod, getItemType, getLhs, getLhsExpression, getOperandRole, getRhs, getSingletonOperator, optimize
-
Methods inherited from class net.sf.saxon.expr.UnaryExpression
displayOperator, emitExtraAttributes, getBaseExpression, getOperand, operands, setBaseExpression, typeCheck
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
CompareToIntegerConstant
public CompareToIntegerConstant(Expression operand, int operator, long comparand)
Create the expression
-
-
Method Detail
-
getComparand
public long getComparand()
Get the integer value on the rhs of the expression- Returns:
- the integer constant
-
getRhsExpression
public Expression getRhsExpression()
Get the effective right-hand-side expression (so that general logic for comparison expressions can be used)- Specified by:
getRhsExpression
in interfaceComparisonExpression
- Specified by:
getRhsExpression
in classCompareToConstant
- Returns:
- a Literal representing the RHS expression
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
-- 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 classUnaryExpression
- 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 classUnaryExpression
- 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 classExpression
- 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
-
computeCardinality
public int computeCardinality()
Description copied from class:UnaryExpression
Determine the static cardinality. Default implementation returns the cardinality of the operand- Overrides:
computeCardinality
in classUnaryExpression
- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE
,StaticProperty.EXACTLY_ONE
,StaticProperty.ALLOWS_ONE_OR_MORE
,StaticProperty.ALLOWS_ZERO_OR_MORE
. May also returnStaticProperty.ALLOWS_ZERO
if the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANY
if if is known to return a sequence of length two or more.
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classExpression
- 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 interfaceExportAgent
- Overrides:
export
in classUnaryExpression
- 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 classUnaryExpression
- 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 classUnaryExpression
- 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
-
-