Package net.sf.saxon.expr.accum
Class AccumulatorManager
- java.lang.Object
-
- net.sf.saxon.expr.accum.AccumulatorManager
-
public class AccumulatorManager extends java.lang.Object
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 Constructor Description AccumulatorManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAccumulatorData(TreeInfo doc, Accumulator acc, IAccumulatorData accData)
Add the accumulator data for a particular accumulator, if it does not already existIAccumulatorData
getAccumulatorData(TreeInfo doc, Accumulator acc, XPathContext context)
Get the data relating to a particular accumulator for a particular unstreamed document treeboolean
isApplicable(TreeInfo tree, Accumulator accumulator)
Ask whether a particular accumulator is applicable to a particular treevoid
setApplicableAccumulators(TreeInfo tree, java.util.Set<? extends Accumulator> accumulators)
By default, all accumulators are applicable to any given tree.
-
-
-
Method Detail
-
setApplicableAccumulators
public void setApplicableAccumulators(TreeInfo tree, java.util.Set<? extends Accumulator> accumulators)
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
-
isApplicable
public boolean isApplicable(TreeInfo tree, Accumulator accumulator)
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
public void addAccumulatorData(TreeInfo doc, Accumulator acc, IAccumulatorData accData)
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
-
-