Class PatternWatch

  • All Implemented Interfaces:
    Watch
    Direct Known Subclasses:
    AccumulatorWatch, FieldWatch, MultiAccumulatorWatch, SelectorWatch, Trigger

    public abstract class PatternWatch
    extends AbstractWatch
    A Watch represents a class that is interested in looking at nodes for the purpose of evaluating uniqueness and key constraints, or for XSLT streaming; specifically, an implementation of Watch that retains a Pattern which is evaluated to see whether a particular node matches the Watch.
    • Constructor Detail

      • PatternWatch

        public PatternWatch()
    • Method Detail

      • matchesNode

        public 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

        public 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
      • 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
        Parameters:
        selection - the streamable XPath expression
      • getSelection

        public Pattern getSelection()
        Get the selection (that is, the restricted XPath expression) that defines the nodes that this Watch is looking for
        Returns:
        the selection
      • setAnchorNode

        public 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

        public final 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

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