Package com.saxonica.ee.stream.watch
Interface Watch
- All Known Implementing Classes:
AbstractWatch
,AccumulatorWatch
,FieldWatch
,KeySelectorWatch
,MultiAccumulatorWatch
,PatternWatch
,RefSelectorWatch
,SelectorWatch
,StreamWatch
,Trigger
public interface Watch
A Watch represents a class that is interested in looking at nodes passing down a push
pipeline. Originally this was for the purpose of evaluating uniqueness and key constraints while
validating an instance document against a schema; now it is used for many expressions that need
to be evaluated in streaming mode.
The Watch is responsible for deciding which nodes it is interested in. There is a subclass
PatternWatch
in which this is decided by matching an XSLT-like pattern, but not all
watches make the decision in this way.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
The close() method is called immediately before the Watch is destroyed, that is, when the element whose declaration scopes the constraint implemented by this Watch goes out of scope.void
endSelectedParentNode
(Location locationId) Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.Get the anchor node for the watch.Get the namespace resolver in use by the WatchGet the pipeline configuration in useboolean
matchesNode
(FleetingNode node, XPathContext context) Determine whether the watch matches a given nodeboolean
matchesNodesOfKind
(UType kind) Ask whether the Watch is capable of matching nodes of a particular kindvoid
open
(Terminator terminator) Open the watch.void
processItem
(Item item) Signal that a node (other than a document or element node) that matches the selection has been found.void
setAnchorNode
(FleetingParentNode anchor) Set the anchor node for the watch.void
setNamespaceResolver
(NamespaceResolver resolver) Set a NamespaceResolver for use by the Watchvoid
Set the pipeline configuration in usestartSelectedParentNode
(FleetingParentNode node, Location locationId) Signal that an element or document node has been found that matches the selection that this Watch is looking for.
-
Method Details
-
matchesNode
Determine whether the watch matches a given node- Parameters:
node
- the node to be testedcontext
- the XPath dynamic context- Returns:
- true if the node is one of those the Watch is looking out for
- Throws:
XPathException
- if a dynamic error occurs
-
matchesNodesOfKind
Ask whether the Watch is capable of matching nodes of a particular kind- Parameters:
kind
- the node kind as a UType- Returns:
- true if the watch is capabl of matching
-
setPipelineConfiguration
Set the pipeline configuration in use- Parameters:
pipe
- the pipeline Configuration in use
-
getPipelineConfiguration
PipelineConfiguration getPipelineConfiguration()Get the pipeline configuration in use- Returns:
- the pipeline configuration
-
setNamespaceResolver
Set a NamespaceResolver for use by the Watch- Parameters:
resolver
- the namespace resolver to be used
-
getNamespaceResolver
NamespaceResolver getNamespaceResolver()Get the namespace resolver in use by the Watch- Returns:
- the namespace resolver
-
setAnchorNode
Set the anchor node for the watch. This is the node to which the watch is scoped, typically the context node for the streamable path expression that defines the root of the subtree within which nodes are being sought.- Parameters:
anchor
- The anchor node within which the watch is scoped
-
getAnchorNode
FleetingParentNode getAnchorNode()Get the anchor node for the watch. This is the node to which the watch is scoped, typically the context node for the streamable path expression that defines the root of the subtree within which nodes are being sought.- Returns:
- The anchor node within which the watch is scoped
-
open
Open the watch. This is done at the point where it first starts watching for nodes that match the selection.- Parameters:
terminator
- action to be taken on failure- Throws:
XPathException
- May be raised if a dynamic error occurs
-
startSelectedParentNode
Receiver startSelectedParentNode(FleetingParentNode node, Location locationId) throws XPathException Signal that an element or document node has been found that matches the selection that this Watch is looking for. This method is called by the WatchManager while processing the startElement or startDocument event that matches the selection.- Parameters:
node
- the element or document node whose start event has been matchedlocationId
- the location associated with the element or document node (may be the location of the instruction that created it)- Returns:
- a Receiver to be notified of all events starting with the startElement/startDocument event for the matched element, and ending with the endElement event for that element; or null if this feature is not required.
- Throws:
XPathException
- May be raised if a dynamic error occurs
-
endSelectedParentNode
Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.- Parameters:
locationId
- the location of the element- Throws:
XPathException
- May be raised if a constraint implemented by this Watch is violated
-
processItem
Signal that a node (other than a document or element node) that matches the selection has been found.- Parameters:
item
- the node that was matched.- Throws:
XPathException
- May be raised if a dynamic error occurs
-
close
The close() method is called immediately before the Watch is destroyed, that is, when the element whose declaration scopes the constraint implemented by this Watch goes out of scope.- Throws:
XPathException
- May be raised if a dynamic error occurs
-