public 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_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 |
---|---|
Sequence |
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
|
Expression |
copy()
Copy an expression.
|
boolean |
effectiveBooleanValue(XPathContext context)
Evaluate the expression in a boolean context
|
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.
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the GeneralComparison expression
|
String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
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
|
GeneralComparisonAdjunct |
getStreamingAdjunct()
Get a class that supports streamed evaluation of this 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
|
static boolean |
quickCompare(UntypedAtomicValue a0,
NumericValue a1,
int operator,
ConversionRules rules)
Optimized routine to compare an untyped atomic value with a numeric value.
|
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
|
Expression |
simplify()
Simplify an expression.
|
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
|
computeSpecialProperties, displayOperator, equals, export, getImplementationMethod, getLhs, getLhsExpression, getOperandRole, getOperator, getRhs, getRhsExpression, hashCode, isAssociative, isCommutative, isInverse, operands, setFlattened, setLhsExpression, setRhsExpression, toShortString, toString
addToPathMap, adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, clearStreamabilityData, computeDependencies, computeStaticProperties, doPromotion, dynamicError, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getConstructType, getCost, getDependencies, getEvaluationMethod, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getPosture, getPostureAndSweepIfKnown, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, optimizeForType, process, promote, promoteChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setFiltered, setLocation, setParentExpression, setPostureAndSweep, setRetainedStaticContext, setRetainedStaticContextLocally, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, toStreamingPattern, typeCheckChildren, typeError, unordered
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 Expression simplify() throws XPathException
Expression
simplify
in class Expression
XPathException
- if an error is discovered during expression
rewritingpublic 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
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 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 Expression copy()
copy
in class Expression
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 Sequence 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 comparisoncheckTypes
- set to true if the operand types need to be checked for comparability at runtimecontext
- the XPath evaluation contextnsResolver
- XPathException
- if a dynamic error occurs during the comparisonpublic ItemType getItemType()
getItemType
in class Expression
public static int getCorrespondingSingletonOperator(int op)
protected GeneralComparison getInverseComparison()
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
public GeneralComparisonAdjunct getStreamingAdjunct()
getStreamingAdjunct
in class Expression
public String tag()
tag
in class BinaryExpression
protected void explainExtraAttributes(ExpressionPresenter out)
BinaryExpression
explainExtraAttributes
in class BinaryExpression
out
- the output destination for the displayed expression treepublic static boolean quickCompare(UntypedAtomicValue a0, NumericValue a1, int operator, ConversionRules rules) throws XPathException
a0
- the untypedAtomic comparanda1
- the numeric comparandoperator
- the comparison operator: a singleton operator such as Token.FEQrules
- the conversion rulesXPathException
- if the first operand is not convertible to a doubleCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.