net.sf.saxon.pattern
Class KeyPattern

java.lang.Object
  extended by net.sf.saxon.pattern.Pattern
      extended by net.sf.saxon.pattern.NodeSetPattern
          extended by net.sf.saxon.pattern.KeyPattern
All Implemented Interfaces:
Serializable, SourceLocator, Container, PatternFinder

public final class KeyPattern
extends NodeSetPattern

A KeyPattern is a pattern of the form key(keyname, keyvalue)

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.pattern.NodeSetPattern
expression, itemType
 
Constructor Summary
KeyPattern(StructuredQName keyName, Expression key, Configuration config)
          Constructor
 
Method Summary
 Pattern analyze(ExpressionVisitor visitor, ItemType contextItemType)
          Type-check the pattern.
 NodeTest getNodeTest()
          Get a NodeTest that all the nodes matching this pattern must satisfy
 boolean matches(NodeInfo e, XPathContext context)
          Determine whether this Pattern matches the given Node.
 
Methods inherited from class net.sf.saxon.pattern.NodeSetPattern
allocateSlots, equals, getDependencies, getNodeKind, hashCode, iterateSubExpressions, promote, replaceSubExpression
 
Methods inherited from class net.sf.saxon.pattern.Pattern
getColumnNumber, getContainerGranularity, getDefaultPriority, getExecutable, getFingerprint, getHostLanguage, getLineNumber, getLocationProvider, getPublicId, getSystemId, internalMatches, make, makeSearchExpression, matchesBeneathAnchor, resolveCurrent, selectNodes, setExecutable, setLineNumber, setOriginalText, setSystemId, simplify, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyPattern

public KeyPattern(StructuredQName keyName,
                  Expression key,
                  Configuration config)
Constructor

Parameters:
keyName - the name of the key
key - the value of the key: either a StringValue or a VariableReference
Method Detail

analyze

public Pattern analyze(ExpressionVisitor visitor,
                       ItemType contextItemType)
                throws XPathException
Type-check the pattern. This is needed for patterns that contain variable references or function calls.

Overrides:
analyze in class NodeSetPattern
Parameters:
visitor - the expression visitor
contextItemType - the type of the context item at the point where the pattern is defined. Set to null if it is known that the context item is undefined.
Returns:
the optimised Pattern
Throws:
XPathException

matches

public boolean matches(NodeInfo e,
                       XPathContext context)
                throws XPathException
Determine whether this Pattern matches the given Node.

Overrides:
matches in class NodeSetPattern
Parameters:
e - The NodeInfo representing the Element or other node to be tested against the Pattern
context - 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
Throws:
XPathException

getNodeTest

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

Overrides:
getNodeTest in class NodeSetPattern
Returns:
a NodeTest, as specific as possible, which all the matching nodes satisfy


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.