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:
java.io.Serializable
,javax.xml.transform.SourceLocator
,LocationProvider
,SaxonLocator
,InstructionInfo
,org.xml.sax.Locator
- Direct Known Subclasses:
FirstItemExpression
,LastItemExpression
public abstract class SingleItemFilter extends UnaryExpression
A SingleItemFilter is an expression that selects zero or one items from a supplied sequence- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.UnaryExpression
operand
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description SingleItemFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeCardinality()
Get the static cardinality: this implementation is appropriate for [1] and [last()] which will always return something if the input is non-emptyExpression
optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)
Perform optimisation of an expression and its subexpressions.Expression
promote(PromotionOffer offer, Expression parent)
Promote this expression if possible-
Methods inherited from class net.sf.saxon.expr.UnaryExpression
computeSpecialProperties, displayOperator, equals, explain, getBaseExpression, getItemType, hashCode, iterateSubExpressions, replaceSubExpression, simplify, toString, typeCheck
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getExpressionName, getHostLanguage, getImplementationMethod, getIntegerBounds, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, iterateEvents, iterateSameFocusSubExpressions, markTailFunctionCalls, process, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError
-
-
-
-
Method Detail
-
optimize
public Expression optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) 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 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 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)
-
promote
public Expression promote(PromotionOffer offer, Expression parent) throws XPathException
Promote this expression if possible- Overrides:
promote
in classUnaryExpression
- Parameters:
offer
- details of the offer, for example the offer to move expressions that don't depend on the context to an outer level in the containing expressionparent
- the containing expression in the expression tree- Returns:
- if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression
- Throws:
XPathException
- if any error is detected
-
computeCardinality
public 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
-
-