Package net.sf.saxon.expr
Class CompareToStringConstant
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.UnaryExpression
-
- net.sf.saxon.expr.CompareToConstant
-
- net.sf.saxon.expr.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.
-
-
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 CompareToStringConstant(Expression operand, int operator, java.lang.String comparand)Create the expression
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcomputeCardinality()Determine the static cardinality.intcomputeHashCode()Hashcode supporting equals()Expressioncopy(RebindingMap rebindings)Copy an expression.booleaneffectiveBooleanValue(XPathContext context)Get the effective boolean value of the expression.booleanequals(java.lang.Object other)Is this expression the same as another expression?voidexport(ExpressionPresenter destination)Diagnostic print of expression structure.AtomicComparergetAtomicComparer()Get the AtomicComparer used to compare atomic values.java.lang.StringgetComparand()Get the integer value on the rhs of the expressionjava.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.ExpressiongetRhsExpression()Get the effective right-hand-side expression (so that general logic for comparison expressions can be used)java.lang.StringtoShortString()Produce a short string identifying the expression for use in error messagesjava.lang.StringtoString()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
-
CompareToStringConstant
public CompareToStringConstant(Expression operand, int operator, java.lang.String comparand)
Create the expression
-
-
Method Detail
-
getComparand
public java.lang.String 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:
getRhsExpressionin interfaceComparisonExpression- Specified by:
getRhsExpressionin classCompareToConstant- Returns:
- a Literal representing the RHS expression
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- 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:
equalsin 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:
computeHashCodein 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:
effectiveBooleanValuein 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:UnaryExpressionDetermine the static cardinality. Default implementation returns the cardinality of the operand- Overrides:
computeCardinalityin 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_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif 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:
getExpressionNamein 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:
exportin interfaceExportAgent- Overrides:
exportin 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:
toStringin 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:
toShortStringin 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
-
-