Class SelectorWatch

All Implemented Interfaces:
Watch
Direct Known Subclasses:
KeySelectorWatch, RefSelectorWatch

public abstract class SelectorWatch extends PatternWatch
A Watch represents a class that is interested in looking at nodes for the purpose of evaluating uniqueness and key constraints. A SelectorWatch looks for the nodes that match the selector in a unique, key, or keyref constraint. There are two concrete subclasses: one for key/unique, the other for keyref
  • Method Details

    • 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 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 events for the subtree rooted at the element matched by this Watch. A SelectorWatch does not require such notification, so it returns null. @param locationId the location of the node in the source, or of the instruction that created it
      Throws:
      ValidationException - May be raised if the constraint implemented by this Watch is violated
      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 node in the source, or of the instruction that created it
      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
      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.
      Specified by:
      close in interface Watch
      Overrides:
      close in class PatternWatch
      Throws:
      XPathException - May be raised if a dynamic error occurs
    • checkRow

      protected void checkRow(AtomicSequence[] currentRow, boolean isTarget, Location locationId) throws XPathException
      Method to check that a row (that is, the collection of fields corresponding to one selected node) is valid.
      Parameters:
      currentRow - the values of the set of fields
      isTarget - set to true if this is a value of the key referred to by a key reference, rather than a value for this constraint's own selected fields.
      locationId - identifies the location of the selected node
      Throws:
      ValidationException - is raised if the value of the row (that is, the combination of fields) violates the constraint
      XPathException
    • reportValidationError

      protected void reportValidationError(ValidationFailure err, Location locator) throws XPathException
      Report a validation error
      Parameters:
      err - The validation exception
      locator - identifies the location in the source document or stylesheet/query where the validation error was detected
      Throws:
      ValidationException - if the threshold on number of errors is exceeded
      XPathException