Class MultiAccumulatorWatch

  • All Implemented Interfaces:
    Watch

    public class MultiAccumulatorWatch
    extends PatternWatch
    This watch managers a set of accumulators in streaming mode. Unlike other watches, it is called to process every node in the stream; it then checks whether any accumulator has any rule that matches this node, and if so invokes the corresponding AccumulatorWatch to update the value of the associated Accumulator

    The complicating factor (see bug 4430) is that accumulators may invoke each other, and we do not know this statically. We therefore start the processing of a node/event by marking all accumulators unavailable. We then evaluate the accumulators in essentially random order. If one of them invokes another and finds it unavailable, it is then evaluated by a recursive call (with a check for cycles), and removed from the list of accumulators that are unavailable.

    • Method Detail

      • setWatchManager

        public void setWatchManager​(WatchManager watchManager)
      • startSelectedParentNode

        public Receiver startSelectedParentNode​(FleetingParentNode node,
                                                Location locationId)
                                         throws XPathException
        Signal that an element has been found that matches the selection that this Watch is looking for. This method is called by the WatchManager while processing the startElement event that matches the selection. For this purpose, any attributes selected by the last step in the selection are ignored
        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:
        always null
        Throws:
        ValidationException - May be raised if the constraint implemented by this Watch is violated @param locationId the location of the node in the source, or of the instruction that created it
        XPathException - May be raised if a dynamic error occurs
      • 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
      • 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 parsing event
        Throws:
        ValidationException - May be raised if the constraint implemented by this Watch is violated @param locationId the location of the node in the source, or of the instruction that created it
        XPathException - May be raised if a constraint implemented by this Watch is violated
      • close

        public void close()
                   throws XPathException
        Description copied from class: PatternWatch
        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