net.sf.saxon.pattern
Class NodeTest

java.lang.Object
  extended bynet.sf.saxon.pattern.Pattern
      extended bynet.sf.saxon.pattern.NodeTest
All Implemented Interfaces:
ItemType, java.io.Serializable
Direct Known Subclasses:
AnyChildNodePattern, AnyNodeTest, CombinedNodeTest, ContentTypeTest, DocumentNodeTest, LocalNameTest, NamespaceTest, NameTest, NodeKindTest, NoNodeTest, SubstitutionGroupTest

public abstract class NodeTest
extends Pattern
implements ItemType

A NodeTest is a simple kind of pattern that enables a context-free test of whether a node has a particular name. There are several kinds of node test: a full name test, a prefix test, and an "any node of a given type" test, an "any node of any type" test, a "no nodes" test (used, e.g. for "@comment()")

Author:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.pattern.Pattern
originalText
 
Constructor Summary
NodeTest()
           
 
Method Summary
abstract  boolean allowsTextNodes()
          Indicate whether this NodeTest is capable of matching text nodes
 NodeTest getNodeTest()
          Get a NodeTest that all the nodes matching this pattern must satisfy
 int getPrimitiveType()
          Get the primitive type corresponding to this item type.
 ItemType getSuperType()
          Get the type from which this item type is derived by restriction.
 boolean isSameType(ItemType other)
          Test whether this NodeTest represents the same type as another NodeTest
abstract  boolean matches(int nodeKind, int fingerprint, int annotation)
          Test whether this node test is satisfied by a given node.
 boolean matches(NodeInfo node, Controller controller)
          Determine whether this Pattern matches the given Node.
 boolean matchesItem(Item item)
          Test whether a given item conforms to this type
 
Methods inherited from class net.sf.saxon.pattern.Pattern
getDefaultPriority, getFingerprint, getLineNumber, getNodeKind, getSystemId, internalMatches, make, setLineNumber, setOriginalText, setSystemId, simplify, toString, typeCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.type.ItemType
toString
 

Constructor Detail

NodeTest

public NodeTest()
Method Detail

matchesItem

public boolean matchesItem(Item item)
Test whether a given item conforms to this type

Specified by:
matchesItem in interface ItemType
Parameters:
item - The item to be tested
Returns:
true if the item is an instance of this type; false otherwise

getSuperType

public ItemType getSuperType()
Description copied from interface: ItemType
Get the type from which this item type is derived by restriction. This is the supertype in the XPath type heirarchy, as distinct from the Schema base type: this means that the supertype of xs:boolean is xdt:anyAtomicType, whose supertype is item() (rather than xs:anySimpleType).

Specified by:
getSuperType in interface ItemType
Returns:
the supertype, or null if this type is item()

getPrimitiveType

public int getPrimitiveType()
Description copied from interface: ItemType
Get the primitive type corresponding to this item type. For item(), this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, it is the value representing the node kind, for example Type.ELEMENT. For anyAtomicValue it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. For other atomic types it is the primitive type as defined in XML Schema: note that INTEGER is not a primitive type.

Specified by:
getPrimitiveType in interface ItemType

matches

public abstract boolean matches(int nodeKind,
                                int fingerprint,
                                int annotation)
Test whether this node test is satisfied by a given node.

Parameters:
nodeKind - The kind of node to be matched
fingerprint - identifies the expanded name of the node to be matched. The value should be -1 for a node with no name.
annotation - The actual content type of the node

matches

public boolean matches(NodeInfo node,
                       Controller controller)
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:
matches in class Pattern
Parameters:
node - The NodeInfo representing the Element or other node to be tested against the Pattern
controller - 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().
Returns:
true if the node matches the Pattern, false otherwise

getNodeTest

public NodeTest getNodeTest()
Get a NodeTest that all the nodes matching this pattern must satisfy

Specified by:
getNodeTest in class Pattern

allowsTextNodes

public abstract boolean allowsTextNodes()
Indicate whether this NodeTest is capable of matching text nodes


isSameType

public boolean isSameType(ItemType other)
Test whether this NodeTest represents the same type as another NodeTest

Specified by:
isSameType in interface ItemType
Parameters:
other -
Returns:
true if the two NodeTests represent the same item type