Class 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 Detail

      • AccumulatorManager

        public AccumulatorManager()
    • 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.
        tree - the document tree in question
        accumulators - 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
        tree - the tree in question
        accumulator - the accumulator in question
        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
        doc - the source document tree in question
        acc - the required accumulator
        context - the XPath dynamic evaluation context
        a data structure holding the evaluated values of the accumulator for this source document
        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
        doc - the document/tree whose accumulator data is being added
        acc - the accumulator in question
        accData - the data holding the values of the accumulator for the nodes in this tree