Package com.saxonica.ee.stream.watch
Class MultiAccumulatorWatch
- java.lang.Object
-
- com.saxonica.ee.stream.watch.AbstractWatch
-
- com.saxonica.ee.stream.watch.PatternWatch
-
- com.saxonica.ee.stream.watch.MultiAccumulatorWatch
-
- All Implemented Interfaces:
Watch
public class MultiAccumulatorWatch extends PatternWatch
This watch managers a set of accumulators in streaming mode. Unlike other watches, it is called to process every node in the stream; it then checks whether any accumulator has any rule that matches this node, and if so invokes the corresponding AccumulatorWatch to update the value of the associated AccumulatorThe complicating factor (see bug 4430) is that accumulators may invoke each other, and we do not know this statically. We therefore start the processing of a node/event by marking all accumulators unavailable. We then evaluate the accumulators in essentially random order. If one of them invokes another and finds it unavailable, it is then evaluated by a recursive call (with a check for cycles), and removed from the list of accumulators that are unavailable.
-
-
Constructor Summary
Constructors Constructor Description MultiAccumulatorWatch(java.util.Map<Accumulator,AccumulatorWatch> accumulatorMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
endSelectedParentNode(Location locationId)
Signal that the endElement event has occurred for the element whose startElement event caused the Watch to be activated.java.util.Map<Accumulator,AccumulatorWatch>
getAccumulatorMap()
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
setWatchManager(WatchManager watchManager)
Receiver
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 Detail
-
MultiAccumulatorWatch
public MultiAccumulatorWatch(java.util.Map<Accumulator,AccumulatorWatch> accumulatorMap)
-
-
Method Detail
-
getAccumulatorMap
public java.util.Map<Accumulator,AccumulatorWatch> getAccumulatorMap()
-
open
public void open(Terminator terminator) throws XPathException
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
-
setWatchManager
public void setWatchManager(WatchManager watchManager)
-
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
-
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 interfaceWatch
- Overrides:
processItem
in classPatternWatch
- Parameters:
item
- the node that was matched.- Throws:
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 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
public void close() throws XPathException
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
-
-