Package com.saxonica.ee.stream.watch
Class Trigger
java.lang.Object
com.saxonica.ee.stream.watch.AbstractWatch
com.saxonica.ee.stream.watch.PatternWatch
com.saxonica.ee.stream.watch.Trigger
- All Implemented Interfaces:
Watch
A Trigger is a Watch that contains a pattern used for matching streamed nodes, and
a WatchAction which is invoked when a matching node is found.
-
Constructor Summary
Constructors -
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 Feed representing the pipeline of operations performed by this Triggerboolean
Ask whether or not the pattern should use all nodes in the current group as anchor nodes (by default only the first is matched)boolean
matchesNode
(FleetingNode node, XPathContext context) Determine whether the watch matches a given nodevoid
open
(Terminator terminator) Open the watch.void
processItem
(Item item) Signal that a node (other than an element) that matches the selection has been found.void
setMatchCurrentGroup
(boolean matchCurrentGroup) Set whether or not the pattern should use all nodes in the current group as anchor nodes (by default only the first is matched)void
setSelection
(Pattern selection) Set the selection (that is, the streamable XPath expression) that defines the nodes that this Watch is looking forstartSelectedParentNode
(FleetingParentNode node, Location locationId) Signal that an element or document node has been found that matches the selection that this Watch is looking for.Methods inherited from class com.saxonica.ee.stream.watch.PatternWatch
getAnchorNode, getSelection, matchesNodesOfKind, setAnchorNode
Methods inherited from class com.saxonica.ee.stream.watch.AbstractWatch
getNamespaceResolver, getPipelineConfiguration, setNamespaceResolver, setPipelineConfiguration
-
Constructor Details
-
Trigger
-
-
Method Details
-
matchesNode
Description copied from class:PatternWatch
Determine whether the watch matches a given node- Specified by:
matchesNode
in interfaceWatch
- Overrides:
matchesNode
in classPatternWatch
- 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
-
getAction
Get the Feed representing the pipeline of operations performed by this Trigger- Returns:
- the Feed through which matched items are processed
-
open
Open the watch. This is done at the point where it first starts watching for nodes that match the selection.- Specified by:
open
in interfaceWatch
- Overrides:
open
in classPatternWatch
- Parameters:
terminator
- the callback to be used to signal early exit- Throws:
XPathException
- May be raised if a dynamic error occurs
-
startSelectedParentNode
public 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 an element) that matches the selection has been found.- Specified by:
processItem
in interfaceWatch
- Overrides:
processItem
in classPatternWatch
- 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. The default implementation does nothing.- Specified by:
close
in interfaceWatch
- Overrides:
close
in classPatternWatch
- Throws:
XPathException
- May be raised if a dynamic error occurs
-
isMatchCurrentGroup
public boolean isMatchCurrentGroup()Ask whether or not the pattern should use all nodes in the current group as anchor nodes (by default only the first is matched)- Returns:
- true if every node in the current group is to act as an anchor node
-
setSelection
Set the selection (that is, the streamable XPath expression) that defines the nodes that this Watch is looking for- Overrides:
setSelection
in classPatternWatch
- Parameters:
selection
- the streamable XPath expression
-
setMatchCurrentGroup
public void setMatchCurrentGroup(boolean matchCurrentGroup) Set whether or not the pattern should use all nodes in the current group as anchor nodes (by default only the first is matched)- Parameters:
matchCurrentGroup
- true if every node in the current group is to act as an anchor node
-