Package net.sf.saxon.pattern
Class NodeTestPattern
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.PseudoExpression
-
- net.sf.saxon.pattern.Pattern
-
- net.sf.saxon.pattern.NodeTestPattern
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class NodeTestPattern extends Pattern
A NodeTestPattern is a pattern that consists simply of a NodeTest
-
-
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 NodeTestPattern(NodeTest test)
Create an NodeTestPattern that matches all items of a given type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
computeHashCode()
Hashcode supporting equals()Pattern
convertToTypedPattern(java.lang.String val)
Convert the pattern to a typed pattern, in which an element name is treated as schema-element(N)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 name fingerprint of nodes to which this pattern applies.NodeTest
getItemType()
Get a NodeTest that all the nodes matching this pattern must satisfyNodeTest
getNodeTest()
UType
getUType()
Get a UType indicating which kinds of items this Pattern can match.boolean
matches(Item item, XPathContext context)
Determine whether this Pattern matches the given Node.java.lang.String
reconstruct()
Display the pattern for diagnosticsjava.lang.String
toShortString()
Produce a short string identifying the expression for use in error messages-
Methods inherited from class net.sf.saxon.pattern.Pattern
allocateSlots, bindCurrent, effectiveBooleanValue, getDefaultPriority, getDependencies, getElaborator, getHostLanguage, getOriginalText, handleDynamicError, isLiftable, isMotionless, isRecoverable, make, matchesBeneathAnchor, matchesCurrentGroup, matchesItem, optimize, patternContainsVariable, replaceCurrent, selectNodes, setOriginalText, setPriority, setRecoverable, simplify, toPattern, 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, dispatchTailCall, dynamicError, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExpressionName, getExtraProperty, 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, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, 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 Detail
-
NodeTestPattern
public NodeTestPattern(NodeTest test)
Create an NodeTestPattern that matches all items of a given type- Parameters:
test
- the type that the items must satisfy for the pattern to match
-
-
Method Detail
-
matches
public boolean matches(Item item, XPathContext context)
Determine whether this Pattern matches the given Node. This is the main external interface for matching patterns: it sets current() to the node being tested
-
getItemType
public NodeTest getItemType()
Get a NodeTest 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
-
getUType
public UType getUType()
Get a UType indicating which kinds of items this Pattern can match.
-
getFingerprint
public int getFingerprint()
Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.- Overrides:
getFingerprint
in classPattern
- Returns:
- A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints
-
reconstruct
public java.lang.String reconstruct()
Display the pattern for diagnostics- Overrides:
reconstruct
in classPattern
-
toShortString
public java.lang.String toShortString()
Description copied from class:Expression
Produce a short string identifying the expression for use in error messages- Overrides:
toShortString
in classPattern
- Returns:
- a short string, sufficient to identify the expression
-
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
protected int computeHashCode()
Hashcode supporting equals()- Overrides:
computeHashCode
in classExpression
- Returns:
- a computed hash code
-
convertToTypedPattern
public Pattern convertToTypedPattern(java.lang.String val) throws XPathException
Convert the pattern to a typed pattern, in which an element name is treated as schema-element(N)- Overrides:
convertToTypedPattern
in classPattern
- Parameters:
val
- either "strict" or "lax" depending on the value of xsl:mode/@typed- Returns:
- either the original pattern unchanged, or a new pattern as the result of the conversion
- Throws:
XPathException
- if the pattern cannot be converted
-
export
public void export(ExpressionPresenter presenter) throws XPathException
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- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
copy
public Pattern copy(RebindingMap rebindings)
Copy a pattern. This makes a deep copy.
-
getNodeTest
public NodeTest getNodeTest()
-
-