public abstract class GeneralComparison extends BinaryExpression implements ComparisonExpression, Callable
Modifier and Type | Field and Description |
---|---|
protected AtomicComparer |
comparer |
protected int |
comparisonCardinality |
protected boolean |
doneWarnings |
static int |
MANY_TO_MANY |
static int |
MANY_TO_ONE |
protected boolean |
needsRuntimeCheck |
static int |
ONE_TO_ONE |
protected int |
singletonOperator |
operator
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 and Description |
---|
GeneralComparison(Expression p0,
int op,
Expression p1)
Create a relational expression identifying the two operands and the operator
|
Modifier and Type | Method and Description |
---|---|
BooleanValue |
call(XPathContext context,
Sequence[] arguments)
Evaluate the expression
|
static boolean |
compare(AtomicValue a0,
int operator,
AtomicValue a1,
AtomicComparer comparer,
boolean checkTypes,
XPathContext context,
NamespaceResolver nsResolver)
Compare two atomic values
|
int |
computeCardinality()
Determine the static cardinality.
|
boolean |
convertsUntypedToOther()
Determine whether untyped atomic values should be converted to the type of the other operand
|
boolean |
effectiveBooleanValue(XPathContext context)
Evaluate the expression in a boolean context
|
boolean |
equals(java.lang.Object other)
Is this expression the same as another expression?
|
BooleanValue |
evaluateItem(XPathContext context)
Evaluate the expression in a given context
|
boolean |
evaluateManyToMany(SequenceIterator iter0,
SequenceIterator iter1,
XPathContext context)
Evaluate a (zero-or-one)-to-(zero-or-one) comparison
|
protected void |
explainExtraAttributes(ExpressionPresenter out)
Add subclass-specific attributes to the expression tree explanation.
|
AtomicComparer |
getAtomicComparer()
Get the AtomicComparer used to compare atomic values.
|
int |
getComparisonCardinality()
Ask whether the comparison is known to be many-to-one, one-to-one, or many-to-many.
|
static int |
getCorrespondingSingletonOperator(int op)
Return the singleton form of the comparison operator, e.g.
|
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
int |
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived
from the dependencies of its subexpressions.
|
protected GeneralComparison |
getInverseComparison() |
ItemType |
getItemType()
Determine the data type of the expression
|
NamespaceResolver |
getNamespaceResolver()
Get the namespace context for this expression, needed in the event that one operand contains untyped
atomic values and the other contains QNames
|
int |
getSingletonOperator()
Get the primitive (singleton) operator used: one of Token.FEQ, Token.FNE, Token.FLT, Token.FGT,
Token.FLE, Token.FGE
|
UType |
getStaticUType(UType contextItemType)
Get the static type of the expression as a UType, following precisely the type
inference rules defined in the XSLT 3.0 specification.
|
java.lang.String |
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression
|
boolean |
needsRuntimeCheck()
Ask whether a runtime check of the types of the operands is needed
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Optimize the expression
|
void |
setAtomicComparer(AtomicComparer comparer)
Set the comparer to be used
|
void |
setComparisonCardinality(int card)
Say whether the comparison is known to be many-to-one, one-to-one, or many-to-many.
|
void |
setNeedsRuntimeCheck(boolean needsCheck)
Say whether a runtime check of the types of the operands is needed
|
java.lang.String |
tag()
Get the element name used to identify this expression in exported expression format
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the expression
|
computeHashCode, computeSpecialProperties, displayOperator, export, getImplementationMethod, getLhs, getLhsExpression, getOperandRole, getOperator, getRhs, getRhsExpression, isAssociative, isCommutative, isInverse, operands, setFlattened, setLhsExpression, setRhsExpression, toShortString, toString
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, dynamicError, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, 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, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLhs, getLhsExpression, getRhs, getRhsExpression
public static final int ONE_TO_ONE
public static final int MANY_TO_ONE
public static final int MANY_TO_MANY
protected int singletonOperator
protected AtomicComparer comparer
protected boolean needsRuntimeCheck
protected int comparisonCardinality
protected boolean doneWarnings
public GeneralComparison(Expression p0, int op, Expression p1)
p0
- the left-hand operandop
- the operator, as a token returned by the Tokenizer (e.g. Token.LT)p1
- the right-hand operandpublic boolean needsRuntimeCheck()
public void setNeedsRuntimeCheck(boolean needsCheck)
needsCheck
- true if the types of the operands need to be checked at run-timepublic int getComparisonCardinality()
ONE_TO_ONE
,
MANY_TO_MANY
, MANY_TO_ONE
public void setComparisonCardinality(int card)
card
- the Cardinality of the comparison as one of the values ONE_TO_ONE
,
MANY_TO_MANY
, MANY_TO_ONE
public void setAtomicComparer(AtomicComparer comparer)
comparer
- the comparer to be usedpublic java.lang.String getExpressionName()
getExpressionName
in class Expression
public NamespaceResolver getNamespaceResolver()
public AtomicComparer getAtomicComparer()
getAtomicComparer
in interface ComparisonExpression
public int getSingletonOperator()
getSingletonOperator
in interface ComparisonExpression
public boolean convertsUntypedToOther()
convertsUntypedToOther
in interface ComparisonExpression
public int computeCardinality()
computeCardinality
in class BinaryExpression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
. May also return StaticProperty.ALLOWS_ZERO
if
the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY
if
if is known to return a sequence of length two or more.public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class BinaryExpression
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException
- if an error is discovered during this phase
(typically a type error)public int getIntrinsicDependencies()
Expression
getIntrinsicDependencies
in class Expression
public boolean equals(java.lang.Object other)
BinaryExpression
equals
in class BinaryExpression
other
- the other operand; the result is false if this is not an Expressionpublic Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
optimize
in class BinaryExpression
visitor
- an expression visitorcontextInfo
- 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
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public BooleanValue evaluateItem(XPathContext context) throws XPathException
evaluateItem
in class Expression
context
- the given context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException
call
in interface Callable
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as SequenceIteratorsXPathException
- if a dynamic error occurs during the evaluation of the expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue
in class Expression
context
- the given context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean evaluateManyToMany(SequenceIterator iter0, SequenceIterator iter1, XPathContext context) throws XPathException
iter0
- iterator over the first valueiter1
- iterator the second valuecontext
- dynamic evaluation contextXPathException
- if a dynamic error occurspublic static boolean compare(AtomicValue a0, int operator, AtomicValue a1, AtomicComparer comparer, boolean checkTypes, XPathContext context, NamespaceResolver nsResolver) throws XPathException
a0
- the first valueoperator
- the singleton version of the comparison operator,
for example Token.FEQ
a1
- the second valuecomparer
- the comparer to be used to perform the comparison. If the comparer is context-sensitive
then the context must already have been bound using comparer.provideContext().checkTypes
- set to true if the operand types need to be checked for comparability at runtimecontext
- the XPath evaluation contextnsResolver
- namespace resolverXPathException
- if a dynamic error occurs during the comparisonpublic ItemType getItemType()
getItemType
in class Expression
public UType getStaticUType(UType contextItemType)
getStaticUType
in class Expression
contextItemType
- static information about the context itempublic static int getCorrespondingSingletonOperator(int op)
protected GeneralComparison getInverseComparison()
public java.lang.String getStreamerName()
getStreamerName
in class Expression
public java.lang.String tag()
tag
in class BinaryExpression
protected void explainExtraAttributes(ExpressionPresenter out)
BinaryExpression
explainExtraAttributes
in class BinaryExpression
out
- the output destination for the displayed expression treeCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.