Package net.sf.saxon.pattern
Class ItemTypePattern
- java.lang.Object
-
- net.sf.saxon.pattern.Pattern
-
- net.sf.saxon.pattern.ItemTypePattern
-
- All Implemented Interfaces:
java.io.Serializable,javax.xml.transform.SourceLocator,Container,PatternFinder
public class ItemTypePattern extends Pattern
A ItemTypePattern is a pattern that consists simply of an ItemType. In the past the ItemType was always a NodeTest, but XSLT 3.0 introduces the ability for a pattern to also match atomic values.- Author:
- Michael H. Kay
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ItemTypePattern(ItemType test)Create an ItemTypePattern that matches all items of a given type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)Determine whether this pattern is the same as another patterndoublegetDefaultPriority()Determine the default priority of this item type test when used on its own as a PatternintgetFingerprint()Determine the name fingerprint of nodes to which this pattern applies.ItemTypegetItemType()Get a NodeTest that all the nodes matching this pattern must satisfyintgetNodeKind()Determine the types of nodes to which this pattern applies.inthashCode()Hashcode supporting equals()booleanmatches(Item item, XPathContext context)Determine whether this Pattern matches the given Node.voidsetPriority(double priority)Set a priority to override the default priority.java.lang.StringtoString()Display the pattern for diagnostics-
Methods inherited from class net.sf.saxon.pattern.Pattern
allocateSlots, analyze, getColumnNumber, getContainerGranularity, getDependencies, getExecutable, getHostLanguage, getLineNumber, getLocationProvider, getPublicId, getSystemId, internalMatches, iterateSubExpressions, make, matchesBeneathAnchor, promote, replaceSubExpression, resolveCurrent, selectNodes, setExecutable, setLineNumber, setOriginalText, setSystemId, setVariableBindingExpression, simplify
-
-
-
-
Constructor Detail
-
ItemTypePattern
public ItemTypePattern(ItemType test)
Create an ItemTypePattern that matches all items of a given type- Parameters:
test- the type that the items must satisfy for the pattern to match
-
-
Method Detail
-
setPriority
public void setPriority(double priority)
Set a priority to override the default priority. This is used when the pattern is written in a complex form such as a[true()] justifying a priority of 0.5, but then simplifies down to an ItemTypePattern
-
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- Specified by:
matchesin classPattern- Parameters:
item- The NodeInfo representing the Element or other node to be tested against the Patterncontext- The context in which the match is to take place. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key(). Not used (and can be set to null) in the case of patterns that are NodeTests- Returns:
- true if the node matches the Pattern, false otherwise
-
getItemType
public ItemType getItemType()
Get a NodeTest that all the nodes matching this pattern must satisfy- Specified by:
getItemTypein classPattern- Returns:
- an ItemType, as specific as possible, which all the matching items satisfy
-
getDefaultPriority
public final double getDefaultPriority()
Determine the default priority of this item type test when used on its own as a Pattern- Overrides:
getDefaultPriorityin classPattern- Returns:
- the default priority for the pattern
-
getNodeKind
public int getNodeKind()
Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Type.NODE. For patterns that do not match nodes, return -1.- Overrides:
getNodeKindin classPattern- Returns:
- the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
-
getFingerprint
public int getFingerprint()
Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.- Overrides:
getFingerprintin classPattern- Returns:
- A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints
-
toString
public java.lang.String toString()
Display the pattern for diagnostics
-
equals
public boolean equals(java.lang.Object other)
Determine whether this pattern is the same as another pattern- Overrides:
equalsin classjava.lang.Object- Parameters:
other- the other object
-
hashCode
public int hashCode()
Hashcode supporting equals()- Overrides:
hashCodein classjava.lang.Object
-
-