Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.saxonica.validate
Class SelectorWatch

    java.lang.Object
      com.saxonica.validate.SelectorWatch

All Implemented Interfaces:
  Watch

Direct Known Subclasses:
  KeySelectorWatch, RefSelectorWatch

public abstract class SelectorWatch
extends java.lang.Object
implements Watch

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

Constructor Summary
`SelectorWatch(ConstraintChecker checker, IdentityConstraint uniqueConstraint)`

Method Summary
`Receiver` | `activate()` Signal that an element has been found that matches the selection that this Watch is looking for.
`void` | `addFieldValue(Value[] currentRow, int column, Value value, boolean nillableElement)` The addFieldValue method is a callback from the FieldWatch created when this SelectorWatch is activated.
`protected void` | `checkRow(Value[] currentRow, boolean isTarget)` Method to check that a row (that is, the collection of fields corresponding to one selected node) is valid.
`void` | `close()` 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.
`void` | `deactivate()` Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.
`protected java.lang.String` | `displayRow(Value[] row)` Internal method to display the contents of a row, for diagnostics
`IdentityConstraint` | `getIdentityConstraint()` Get the identityConstraint implemented by this SelectorWatch
`int` | `getOriginDepth()` Get the depth within the XML hierarchy of the element whose element declaration contains the unique/key/keyref constraint that this Watch implements
`Selection` | `getSelection()` Get the selection (that is, the restricted XPath expression) that defines the nodes that this Watch is looking for
`void` | `setNamespaceResolver(NamespaceResolver resolver)` Set a NamespaceResolver for use by the Watch
`void` | `setOriginDepth(int depth)` Set the depth within the XML hierarchy of the element whose element declaration contains the unique/key/keyref constraint that this Watch implements
`void` | `setPipelineConfiguration(PipelineConfiguration pipe)` Set the PipelineConfiguration in use

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SelectorWatch

    public SelectorWatch(ConstraintChecker checker,
                         IdentityConstraint uniqueConstraint)

Method Detail

### getIdentityConstraint

    public IdentityConstraint getIdentityConstraint()

  Get the identityConstraint implemented by this SelectorWatch

### getSelection

    public Selection getSelection()

  Get the selection (that is, the restricted XPath expression) that defines the nodes that this Watch is looking for

  Specified by:
    `getSelection` in interface `Watch`
  Returns:
    the selection

### setPipelineConfiguration

    public void setPipelineConfiguration(PipelineConfiguration pipe)

  Set the PipelineConfiguration in use

  Specified by:
    `setPipelineConfiguration` in interface `Watch`
  Parameters:
    `pipe` - the PipelineConfiguration in use

### setNamespaceResolver

    public void setNamespaceResolver(NamespaceResolver resolver)

  Set a NamespaceResolver for use by the Watch

  Specified by:
    `setNamespaceResolver` in interface `Watch`

### setOriginDepth

    public void setOriginDepth(int depth)

  Set the depth within the XML hierarchy of the element whose element declaration contains the unique/key/keyref constraint that this Watch implements

  Specified by:
    `setOriginDepth` in interface `Watch`
  Parameters:
    `depth` - The depth at which the watch is scoped. This corresponds to the elementStackTop level in the controlling WatchHandler, for the startElement event that is the first level notified to the watch. For example, an xs:unique constraint declared on the outermost element of the document will have an origin depth of zero. For a FieldWatch, the origin depth is the difference between the level at which the SelectorWatch is scoped, and the level at which it was activated. This for a constraint defined at BOOKLIST level with select xpath="BOOK" and field xpath="ISBN", the constraint will be scoped at level zero, and activated at level one; the origin depth for the Field Watch will be one.

### getOriginDepth

    public int getOriginDepth()

  Get the depth within the XML hierarchy of the element whose element declaration contains the unique/key/keyref constraint that this Watch implements

  Specified by:
    `getOriginDepth` in interface `Watch`
  Returns:
    The depth at which the watch is scoped

### activate

    public Receiver activate()
                      throws ValidationException

  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

  Specified by:
    `activate` in interface `Watch`
  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.
  Throws:
    `ValidationException` - May be raised if the constraint implemented by this Watch is violated

### deactivate

    public void deactivate()
                    throws ValidationException

  Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.

  Specified by:
    `deactivate` in interface `Watch`
  Throws:
    `ValidationException` - May be raised if the constraint implemented by this Watch is violated

### close

    public void close()
               throws ValidationException

  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`
  Throws:
    `ValidationException`

### addFieldValue

    public void addFieldValue(Value[] currentRow,
                              int column,
                              Value value,
                              boolean nillableElement)
                       throws ValidationException

  The addFieldValue method is a callback from the FieldWatch created when this SelectorWatch is activated. It indicates that a value for one of the fields participating in this constraint has been encountered.

  Parameters:
    `currentRow` - identifying the node to which this field value applies
    `column` - identifies which of the fields participating in this constraint the value relates to
    `value` - The value of the field that was encountered
    `nillableElement` -
  Throws:
    `ValidationException` - May be raised if the value of the field violates the constraint

### checkRow

    protected void checkRow(Value[] currentRow,
                            boolean isTarget)
                     throws ValidationException

  Method to check that a row (that is, the collection of fields corresponding to one selected node) is valid.

  Parameters:
    `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.
  Throws:
    `ValidationException` - is raised if the value of the row (that is, the combination of fields) violates the constraint

### displayRow

    protected java.lang.String displayRow(Value[] row)

  Internal method to display the contents of a row, for diagnostics

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD