com.saxonica.stream.watch

## Class CopyOfWatch

- java.lang.Object
- - com.saxonica.validate.AbstractWatch
  - - com.saxonica.stream.watch.ComposingWatch
    - - com.saxonica.stream.watch.CopyOfWatch

- All Implemented Interfaces:
    Watch

      public class CopyOfWatch
      extends ComposingWatch

  This class is used when optimizing a SequentialCopy, that is, when evaluating a construct of the form saxon:stream(doc('a.xml')/a/b/c). When the matched element (c in this example) is encountered, this Watch detects the fact, and activates a Receiver to receive subsequent events and construct a tree being a copy of the subtree rooted at c. On completion, this tree is written to the supplied SequenceWriter. This will often be a Conduit, where hopefully an iterator is waiting for it on another thread.

  Previously known as SubtreeCopyWatch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CopyOfWatch(Feed result, Stack<XPathContext> contextStack)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `endSelectedParentNode(int locationId)` Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.
    `void` | `notifySelectedLeafNode(FleetingNode node, int locationId)` Signal that a node (other than an element) that matches the selection has been found.
    `Receiver` | `startSelectedParentNode(FleetingNode node, int locationId)` Signal that an element has been found that matches the selection that this Watch is looking for.

    - ### Methods inherited from class com.saxonica.stream.watch.ComposingWatch

      `close, getContext, getContextStack, getResult, open`

    - ### Methods inherited from class com.saxonica.validate.AbstractWatch

      `getAnchorNode, getNamespaceResolver, getPipelineConfiguration, getSelection, setAnchorNode, setNamespaceResolver, setPipelineConfiguration, setSelection`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CopyOfWatch

          public CopyOfWatch(Feed result,
                     Stack<XPathContext> contextStack)

  - ### Method Detail

    - #### startSelectedParentNode

          public Receiver startSelectedParentNode(FleetingNode node,
                                         int 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 ConstraintChecker 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:
        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:
        `ValidationException` - May be raised if the constraint implemented by this Watch is violated @param locationId
        `XPathException` - May be raised if a dynamic error occurs

    - #### notifySelectedLeafNode

          public void notifySelectedLeafNode(FleetingNode node,
                                    int locationId)
                                      throws XPathException

      Signal that a node (other than an element) that matches the selection has been found.
      Specified by:
        `notifySelectedLeafNode` in interface `Watch`
      Overrides:
        `notifySelectedLeafNode` in class `AbstractWatch`
      Parameters:
        `node` - the node that was matched.
        `locationId` -
      Throws:
        `XPathException`

    - #### endSelectedParentNode

          public void endSelectedParentNode(int 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:
        `ValidationException` - May be raised if the constraint implemented by this Watch is violated @param locationId
        `XPathException` - May be raised if a constraint implemented by this Watch is violated

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.