Class 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.
    • Method Detail

      • 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 interface Watch
        Overrides:
        open in class PatternWatch
        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 matched
        locationId - 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 interface Watch
        Overrides:
        processItem in class PatternWatch
        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 interface Watch
        Overrides:
        close in class PatternWatch
        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 class PatternWatch
        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