Package net.sf.saxon.expr.accum
Class AccumulatorManager
java.lang.Object
net.sf.saxon.expr.accum.AccumulatorManager
Manager for accumulator functions (XSLT 3.0).
In principle there is a dataset containing accumulator values for every accumulator/document pair. In addition, if the same stylesheet is run concurrently in multiple transformations, and a document is shared between these transformations, the data values for the accumulator can differ between the two transformations, because the accumulator rules can depend on values of stylesheet parameters or on context variables such as current-dateTime.
It is important that the accumulator data for a tree does not cause the tree to be locked in memory for the duration of a transformation. We therefore keep a weak reference to the tree. For each tree, until it is garbage collected, there is a map from accumulator names to accumulator data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAccumulatorData
(TreeInfo doc, Accumulator acc, IAccumulatorData accData) Add the accumulator data for a particular accumulator, if it does not already existgetAccumulatorData
(TreeInfo doc, Accumulator acc, XPathContext context) Get the data relating to a particular accumulator for a particular unstreamed document treeSet
<? extends Accumulator> Get the set of accumulators applicable to a particular treeboolean
isApplicable
(TreeInfo tree, Accumulator accumulator) Ask whether a particular accumulator is applicable to a particular treevoid
setApplicableAccumulators
(TreeInfo tree, Set<? extends Accumulator> accumulators) By default, all accumulators are applicable to any given tree.
-
Constructor Details
-
AccumulatorManager
public AccumulatorManager()
-
-
Method Details
-
setApplicableAccumulators
By default, all accumulators are applicable to any given tree. If this method is called, a specific set of accumulators are registered as applicable. This set may be empty.- Parameters:
tree
- the document tree in questionaccumulators
- the set of accumulators that are appicable
-
getApplicableAccumulators
Get the set of accumulators applicable to a particular tree- Parameters:
tree
- the tree in question- Returns:
- the set of applicable accumulators; a value of null indicates the universal set (all accumulators are applicable
-
isApplicable
Ask whether a particular accumulator is applicable to a particular tree- Parameters:
tree
- the tree in questionaccumulator
- the accumulator in question- Returns:
- true if the accumulator is applicable to this tree, otherwise false
-
getAccumulatorData
public IAccumulatorData getAccumulatorData(TreeInfo doc, Accumulator acc, XPathContext context) throws XPathException Get the data relating to a particular accumulator for a particular unstreamed document tree- Parameters:
doc
- the source document tree in questionacc
- the required accumulatorcontext
- the XPath dynamic evaluation context- Returns:
- a data structure holding the evaluated values of the accumulator for this source document
- Throws:
XPathException
- if any dynamic error occurs
-
addAccumulatorData
Add the accumulator data for a particular accumulator, if it does not already exist- Parameters:
doc
- the document/tree whose accumulator data is being addedacc
- the accumulator in questionaccData
- the data holding the values of the accumulator for the nodes in this tree
-