Package net.sf.saxon.expr
Class SingleItemFilter
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.UnaryExpression
net.sf.saxon.expr.SingleItemFilter
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
- Direct Known Subclasses:
FirstItemExpression
,LastItemExpression
,SubscriptExpression
A SingleItemFilter is an expression that selects zero or one items from a supplied sequence
-
Field Summary
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Get the static cardinality: this implementation is appropriate for [1] and [last()] which will always return something if the input is non-emptyprotected OperandRole
Get the usage (in terms of streamability analysis) of the single operandoptimize
(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) Perform optimisation of an expression and its subexpressions.Methods inherited from class net.sf.saxon.expr.UnaryExpression
computeHashCode, computeSpecialProperties, displayOperator, emitExtraAttributes, equals, export, getBaseExpression, getItemType, getOperand, operands, setBaseExpression, toShortString, toString, typeCheck
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, dispatchTailCall, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, getCardinality, getConfiguration, getCost, getDependencies, getElaborator, getEvaluationMethod, getExpressionName, getExtraProperty, getImplementationMethod, 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
-
SingleItemFilter
-
-
Method Details
-
getOperandRole
Description copied from class:UnaryExpression
Get the usage (in terms of streamability analysis) of the single operand- Specified by:
getOperandRole
in classUnaryExpression
- Returns:
- the operand usage
-
optimize
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException Perform optimisation of an expression and its subexpressions.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.
- Overrides:
optimize
in classUnaryExpression
- Parameters:
visitor
- an expresion 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 toType.ITEM_TYPE
- Returns:
- the original expression, rewritten if appropriate to optimize execution
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
computeCardinality
protected int computeCardinality()Get the static cardinality: this implementation is appropriate for [1] and [last()] which will always return something if the input is non-empty- 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.
-