Interface Watch

  • All Known Implementing Classes:
    AbstractWatch, AccumulatorWatch, FieldWatch, KeySelectorWatch, MultiAccumulatorWatch, PatternWatch, RefSelectorWatch, SelectorWatch, StreamWatch, Trigger

    public interface Watch
    A Watch represents a class that is interested in looking at nodes passing down a push pipeline. Originally this was for the purpose of evaluating uniqueness and key constraints while validating an instance document against a schema; now it is used for many expressions that need to be evaluated in streaming mode.

    The Watch is responsible for deciding which nodes it is interested in. There is a subclass PatternWatch in which this is decided by matching an XSLT-like pattern, but not all watches make the decision in this way.

    • Method Detail

      • matchesNode

        boolean matchesNode​(FleetingNode node,
                            XPathContext context)
                     throws XPathException
        Determine whether the watch matches a given node
        Parameters:
        node - the node to be tested
        context - 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
      • matchesNodesOfKind

        boolean matchesNodesOfKind​(UType kind)
        Ask whether the Watch is capable of matching nodes of a particular kind
        Parameters:
        kind - the node kind as a UType
        Returns:
        true if the watch is capabl of matching
      • setPipelineConfiguration

        void setPipelineConfiguration​(PipelineConfiguration pipe)
        Set the pipeline configuration in use
        Parameters:
        pipe - the pipeline Configuration in use
      • getPipelineConfiguration

        PipelineConfiguration getPipelineConfiguration()
        Get the pipeline configuration in use
        Returns:
        the pipeline configuration
      • setNamespaceResolver

        void setNamespaceResolver​(NamespaceResolver resolver)
        Set a NamespaceResolver for use by the Watch
        Parameters:
        resolver - the namespace resolver to be used
      • getNamespaceResolver

        NamespaceResolver getNamespaceResolver()
        Get the namespace resolver in use by the Watch
        Returns:
        the namespace resolver
      • setAnchorNode

        void setAnchorNode​(FleetingParentNode anchor)
        Set the anchor node for the watch. This is the node to which the watch is scoped, typically the context node for the streamable path expression that defines the root of the subtree within which nodes are being sought.
        Parameters:
        anchor - The anchor node within which the watch is scoped
      • getAnchorNode

        FleetingParentNode getAnchorNode()
        Get the anchor node for the watch. This is the node to which the watch is scoped, typically the context node for the streamable path expression that defines the root of the subtree within which nodes are being sought.
        Returns:
        The anchor node within which the watch is scoped
      • open

        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.
        Parameters:
        terminator -
        Throws:
        XPathException - May be raised if a dynamic error occurs
      • startSelectedParentNode

        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

        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

        void processItem​(Item item)
                  throws XPathException
        Signal that a node (other than a document or element node) that matches the selection has been found.
        Parameters:
        item - the node that was matched.
        Throws:
        XPathException - May be raised if a dynamic error occurs
      • close

        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.
        Throws:
        XPathException - May be raised if a dynamic error occurs