public final class FilterExpression extends Expression implements ContextSwitchingExpression
Modifier and Type | Field and Description |
---|---|
static OperandRole |
FILTER_PREDICATE |
static int |
FILTERED |
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD
Constructor and Description |
---|
FilterExpression(Expression base,
Expression filter)
Constructor
|
Modifier and Type | Method and Description |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
int |
computeCardinality()
Get the static cardinality of this expression
|
int |
computeDependencies()
Determine which aspects of the context the expression depends on.
|
int |
computeSpecialProperties()
Get the static properties of this expression (other than its type).
|
Expression |
copy()
Copy an expression.
|
boolean |
equals(Object other)
Is this expression the same as another expression?
|
void |
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
|
Expression |
getActionExpression()
Get the subexpression that is evaluated in the new context
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the Filter expression
|
String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
Expression |
getFilter()
Get the filter expression
|
IntegerValue[] |
getIntegerBounds()
For an expression that returns an integer or a sequence of integers, get
a lower and upper bound on the values of the integers that may be returned, from
static analysis.
|
ItemType |
getItemType()
Get the data type of the items returned
|
Expression |
getSelectExpression()
Get the base expression
|
FilterExpressionAdjunct |
getStreamingAdjunct()
Get a class that supports streamed evaluation of this expression
|
int |
hashCode()
get HashCode for comparing two expressions
|
boolean |
isFilterIsPositional() |
boolean |
isIndependentFilter()
Determine whether the filter is independent of the context item and position
|
boolean |
isPositional(TypeHierarchy th)
Determine if the filter is positional
|
static boolean |
isPositionalFilter(Expression exp,
TypeHierarchy th)
Determine whether an expression, when used as a filter, is potentially positional;
that is, where it either contains a call on position() or last(), or where it is capable of returning
a numeric result.
|
boolean |
isSimpleBooleanFilter()
Test if the filter always returns a singleton boolean.
|
SequenceIterator |
iterate(XPathContext context)
Iterate over the results, returning them in the correct order
|
Iterable<Operand> |
operands()
Get the immediate sub-expressions of this expression, with information about the relationship
of each expression to its parent expression.
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.
|
Expression |
promote(PromotionOffer offer,
Expression parent)
Promote this expression if possible
|
boolean |
replaceOperand(Expression original,
Expression replacement)
Replace one subexpression by a replacement subexpression
|
Expression |
simplify(ExpressionVisitor visitor)
Simplify an expression
|
Pattern |
toPattern(Configuration config,
boolean is30)
Convert this expression to an equivalent XSLT pattern
|
String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
String |
toString()
The toString() method for an expression attempts to give a representation of the expression
in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath.
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Type-check the expression
param visitor the expression visitor
|
Expression |
unordered(boolean retainAllNodes,
boolean forStreaming)
Replace this expression by a simpler expression that delivers the results without regard
to order.
|
adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, clearStreamabilityData, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getConfiguration, getConstructType, getContainer, getDependencies, getEvaluationMethod, getHostLanguage, getImplementationMethod, getIntrinsicDependencies, getLineNumber, getLocationId, getObjectName, getPosture, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isIdentical, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, process, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, setPostureAndSweep, staticTypeCheck, suppressValidation, toStreamingPattern, typeError
public static final int FILTERED
public static final OperandRole FILTER_PREDICATE
public FilterExpression(Expression base, Expression filter)
base
- The base expression to be filtered.filter
- An expression defining the filter predicatepublic String getExpressionName()
getExpressionName
in class Expression
public ItemType getItemType()
getItemType
in class Expression
public Expression getSelectExpression()
getSelectExpression
in interface ContextSwitchingExpression
public boolean isFilterIsPositional()
FilterExpressionCompiler
public Expression getActionExpression()
getActionExpression
in interface ContextSwitchingExpression
public Expression getFilter()
public boolean isPositional(TypeHierarchy th)
th
- the Type Hierarchy (for cached access to type information)public boolean isSimpleBooleanFilter()
This information is available only after typeCheck() has been called.
public boolean isIndependentFilter()
This information is available only after typeCheck() has been called.
public Expression simplify(ExpressionVisitor visitor) throws XPathException
simplify
in class Expression
visitor
- the expression visitorXPathException
- if any failure occurspublic Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class Expression
contextInfo
- return the expression after type-checking (potentially modified to add run-time
checks and/or conversions)visitor
- an expression visitorXPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- 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 IntegerValue[] getIntegerBounds()
getIntegerBounds
in class Expression
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
addToPathMap
in class Expression
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be addedpublic Expression promote(PromotionOffer offer, Expression parent) throws XPathException
promote
in class Expression
offer
- details of the promotion that is possibleparent
- the parent of this expression in the expression treeXPathException
- if any error is detectedpublic Expression unordered(boolean retainAllNodes, boolean forStreaming) throws XPathException
unordered
in class Expression
retainAllNodes
- set to true if the result must contain exactly the same nodes as the
original; set to false if the result can eliminate (or introduce) duplicates.forStreaming
- set to true if optimizing for streamingXPathException
- if the rewrite failspublic static boolean isPositionalFilter(Expression exp, TypeHierarchy th)
exp
- the expression to be examinedth
- the type hierarchy cachepublic Iterable<Operand> operands()
operands
in class Expression
public boolean replaceOperand(Expression original, Expression replacement)
replaceOperand
in class Expression
original
- the original subexpressionreplacement
- the replacement subexpressionpublic int computeCardinality()
computeCardinality
in class Expression
public int computeSpecialProperties()
computeSpecialProperties
in class Expression
public boolean equals(Object other)
public int hashCode()
public Pattern toPattern(Configuration config, boolean is30) throws XPathException
toPattern
in class Expression
config
- the Saxon configurationis30
- true if this is XSLT 3.0XPathException
- if conversion is not possiblepublic SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- the dynamic context for the evaluationXPathException
- if any dynamic error occurspublic int computeDependencies()
computeDependencies
in class Expression
public Expression copy()
copy
in class Expression
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
public FilterExpressionAdjunct getStreamingAdjunct()
getStreamingAdjunct
in class Expression
public String toString()
toString
in class Expression
public String toShortString()
Expression
toShortString
in class Expression
public void explain(ExpressionPresenter out)
explain
in class Expression
out
- the ExpressionPresenter to be usedCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.