Class AccumulatorWatch

  • All Implemented Interfaces:
    Watch

    public class AccumulatorWatch
    extends PatternWatch
    This watch implements a single accumulator in streaming mode. Unlike other watches, it is called to process every node in the stream; it then checks whether the accumulator has any rule that matches this node, and if so applies the next-value expression associated with that accumulator rule.

    The class also provides methods to return the "before" and "after" values of the accumulator for a given node. These have to make provision (a) for handling error situations (where evaluation of the accumulator failed), and (b) for handling the case where the value is requested (by another accumulator) before it is available.

    • Constructor Detail

      • AccumulatorWatch

        public AccumulatorWatch​(Accumulator accumulator)
    • Method Detail

      • open

        public void open​(Terminator terminator)
                  throws XPathException
        Description copied from class: PatternWatch
        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 - action to be taken on failure
        Throws:
        XPathException - May be raised if a dynamic error occurs
      • setNodeStack

        public void setNodeStack​(java.util.Stack<FleetingNode> stack)
      • 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