Package com.saxonica.ee.stream.watch
Class AccumulatorWatch
java.lang.Object
com.saxonica.ee.stream.watch.AbstractWatch
com.saxonica.ee.stream.watch.PatternWatch
com.saxonica.ee.stream.watch.AccumulatorWatch
- All Implemented Interfaces:
Watch
This watch implements a single accumulator in streaming mode. Unlike other watches,
it is called to process every node in the stream; it then checks whether the accumulator
has any rule that matches this node, and if so applies the next-value expression associated
with that accumulator rule.
The class also provides methods to return the "before" and "after" values of the accumulator for a given node. These have to make provision (a) for handling error situations (where evaluation of the accumulator failed), and (b) for handling the case where the value is requested (by another accumulator) before it is available.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
endSelectedParentNode
(Location locationId) Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.getPreDescentValueAtDepth
(int depth) boolean
void
open
(Terminator terminator) Open the watch.void
processItem
(Item item) Signal that a node (other than an element) that matches the selection has been found.void
setNodeStack
(Stack<FleetingNode> stack) void
setWatchManager
(WatchManager watchManager) startSelectedParentNode
(FleetingParentNode node, Location locationId) Signal that an element has been found that matches the selection that this Watch is looking for.Methods inherited from class com.saxonica.ee.stream.watch.PatternWatch
getAnchorNode, getSelection, matchesNode, matchesNodesOfKind, setAnchorNode, setSelection
Methods inherited from class com.saxonica.ee.stream.watch.AbstractWatch
getNamespaceResolver, getPipelineConfiguration, setNamespaceResolver, setPipelineConfiguration
-
Constructor Details
-
AccumulatorWatch
-
-
Method Details
-
getAccumulator
-
getContext
-
open
Description copied from class:PatternWatch
Open the watch. This is done at the point where it first starts watching for nodes that match the selection.- Specified by:
open
in interfaceWatch
- Overrides:
open
in classPatternWatch
- Parameters:
terminator
- action to be taken on failure- Throws:
XPathException
- May be raised if a dynamic error occurs
-
setNodeStack
-
setWatchManager
-
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 WatchManager 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 matchedlocationId
- the location associated with the element or document node (may be the location of the instruction that created it)- Returns:
- always null
- 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 itXPathException
- May be raised if a dynamic error occurs
-
isBeingComputed
-
processItem
Signal that a node (other than an element) that matches the selection has been found.- Specified by:
processItem
in interfaceWatch
- Overrides:
processItem
in classPatternWatch
- Parameters:
item
- the node that was matched.- Throws:
XPathException
- May be raised if a dynamic error occurs
-
endSelectedParentNode
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 parsing event- 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 itXPathException
- May be raised if a constraint implemented by this Watch is violated
-
close
Description copied from class:PatternWatch
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 interfaceWatch
- Overrides:
close
in classPatternWatch
- Throws:
XPathException
- May be raised if a dynamic error occurs
-
getPreDescentValue
- Throws:
XPathException
-
getPreDescentValueAtDepth
- Throws:
XPathException
-
getPostDescentValue
- Throws:
XPathException
-