Package net.sf.saxon.pattern
Class SimplePositionalPattern
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.PseudoExpression
-
- net.sf.saxon.pattern.Pattern
-
- net.sf.saxon.pattern.SimplePositionalPattern
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public final class SimplePositionalPattern extends Pattern
A SimplePositionalPattern is a pattern of the form A[N] where A is an axis expression using the child axis and P is a numeric literal.
-
-
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 Constructor Description SimplePositionalPattern(NodeTest nodeTest, int position)
Create a SimplePositionalPattern
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeHashCode()
hashcode supporting equals()Pattern
copy(RebindingMap rebindings)
Copy a pattern.boolean
equals(java.lang.Object other)
Determine whether this pattern is the same as another patternvoid
export(ExpressionPresenter presenter)
Diagnostic print of expression structure.int
getFingerprint()
Determine the fingerprint of nodes to which this pattern applies.ItemType
getItemType()
Get an ItemType that all the nodes matching this pattern must satisfyNodeTest
getNodeTest()
Get the node testint
getPosition()
Get the required positionUType
getUType()
Get a UType indicating which kinds of items this Pattern can match.boolean
isMotionless()
Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream.boolean
matches(Item item, XPathContext context)
Determine whether the pattern matches a given item.boolean
matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context)
Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node.java.lang.String
reconstruct()
Get the original pattern text-
Methods inherited from class net.sf.saxon.pattern.Pattern
allocateSlots, bindCurrent, convertToTypedPattern, effectiveBooleanValue, getDefaultPriority, getDependencies, getHostLanguage, getOriginalText, handleDynamicError, isLiftable, isRecoverable, make, matchesCurrentGroup, optimize, patternContainsVariable, replaceCurrent, selectNodes, setOriginalText, setPriority, setRecoverable, simplify, toPattern, toShortString, toString, typeCheck
-
Methods inherited from class net.sf.saxon.expr.PseudoExpression
computeCardinality, evaluateAsString, evaluateItem, getImplementationMethod, iterate, process
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeSpecialProperties, computeStaticProperties, dynamicError, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExpressionName, getExtraProperty, getIntegerBounds, getInterpretedExpression, 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, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers
-
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 Detail
-
SimplePositionalPattern
public SimplePositionalPattern(NodeTest nodeTest, int position)
Create a SimplePositionalPattern- Parameters:
nodeTest
- the test that the node must satisfyposition
- the required position of the node
-
-
Method Detail
-
getPosition
public int getPosition()
Get the required position- Returns:
- the integer appearing as the filter predicate
-
getNodeTest
public NodeTest getNodeTest()
Get the node test- Returns:
- the node test used
-
matches
public boolean matches(Item item, XPathContext context)
Determine whether the pattern matches a given item.
-
getUType
public UType getUType()
Get a UType indicating which kinds of items this Pattern can match.
-
getFingerprint
public int getFingerprint()
Determine the fingerprint of nodes to which this pattern applies. Used for optimisation.- Overrides:
getFingerprint
in classPattern
- Returns:
- the fingerprint of nodes matched by this pattern.
-
getItemType
public ItemType getItemType()
Get an ItemType that all the nodes matching this pattern must satisfy- Specified by:
getItemType
in classPattern
- Returns:
- an ItemType, as specific as possible, which all the matching items satisfy
-
equals
public boolean equals(java.lang.Object other)
Determine whether this pattern is the same as another pattern- Overrides:
equals
in classExpression
- Parameters:
other
- the other object- Returns:
- true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
-
computeHashCode
public int computeHashCode()
hashcode supporting equals()- Overrides:
computeHashCode
in classExpression
- Returns:
- a computed hash code
-
isMotionless
public boolean isMotionless()
Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream. This is a necessary condition for patterns used as the match pattern of a streamed template rule.- Overrides:
isMotionless
in classPattern
- Returns:
- true if the pattern is motionless, that is, if it can be evaluated against a streamed node without changing the position in the streamed input file
-
matchesBeneathAnchor
public boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context)
Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.- Overrides:
matchesBeneathAnchor
in classPattern
- Parameters:
node
- The NodeInfo representing the Element or other node to be tested against the Patternanchor
- The anchor node, which must match any AnchorPattern subpatterncontext
- The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().- Returns:
- true if the node matches the Pattern, false otherwise
-
copy
public Pattern copy(RebindingMap rebindings)
Copy a pattern. This makes a deep copy.
-
reconstruct
public java.lang.String reconstruct()
Get the original pattern text- Overrides:
reconstruct
in classPattern
-
export
public void export(ExpressionPresenter presenter)
Description copied from class:Expression
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classPattern
- Parameters:
presenter
- the expression presenter used to display the structure
-
-