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
public class Trigger extends PatternWatch
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 Constructor Description Trigger(Pattern selection, ItemFeed action, XPathContext selectionContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.ItemFeed
getAction()
Get the Feed representing the pipeline of operations performed by this Triggerboolean
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)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 forReceiver
startSelectedParentNode(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 Detail
-
Trigger
public Trigger(Pattern selection, ItemFeed action, XPathContext selectionContext)
-
-
Method Detail
-
matchesNode
public boolean matchesNode(FleetingNode node, XPathContext context) throws XPathException
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
public ItemFeed getAction()
Get the Feed representing the pipeline of operations performed by this Trigger- Returns:
- the Feed through which matched items are processed
-
open
public void open(Terminator terminator) throws XPathException
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
public void endSelectedParentNode(Location locationId) throws XPathException
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
public void processItem(Item item) throws XPathException
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
public void close() throws XPathException
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
public void setSelection(Pattern selection)
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
-
-