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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Elaborator for a "compare to string constant" expression -
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
ConstructorsConstructorDescriptionCompareToStringConstant
(Expression operand, int operator, UnicodeString comparand) Create the expression -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Determine the static cardinality.protected int
Hashcode supporting equals()copy
(RebindingMap rebindings) Copy an expression.boolean
effectiveBooleanValue
(XPathContext context) Get the effective boolean value of the expression.boolean
Is this expression the same as another expression?void
export
(ExpressionPresenter destination) Diagnostic print of expression structure.Get the AtomicComparer used to compare atomic values.Get the string value on the rhs of the expressionMake an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.Get the effective right-hand-side expression (so that general logic for comparison expressions can be used)Get the StringCollator used to compare string values.Produce a short string identifying the expression for use in error messagestoString()
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, interpretComparisonResult, 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, dispatchTailCall, dynamicError, evaluateAsString, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, 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, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
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 Details
-
CompareToStringConstant
Create the expression
-
-
Method Details
-
getComparand
Get the string value on the rhs of the expression- Returns:
- the integer constant
-
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
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- variables that need to be re-bound- Returns:
- the copy of the original expression
-
equals
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
protected int computeHashCode()Hashcode supporting equals()- Overrides:
computeHashCode
in classUnaryExpression
- Returns:
- a computed hash code
-
effectiveBooleanValue
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
protected 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
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
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
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
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
Get the AtomicComparer used to compare atomic values. This encapsulates any collation that is used- Returns:
- the comparer
-
getStringCollator
Get the StringCollator used to compare string values.- Returns:
- the collator.
-
getElaborator
Make an elaborator for this expression- Overrides:
getElaborator
in classExpression
- Returns:
- a suitable elaborator
-