![JAR search and dependency download from the Maven repository](/logo.png)
net.sf.saxon.tree.iter.ReportingSingletonIterator Maven / Gradle / Ivy
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2023 Saxonica Limited
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package net.sf.saxon.tree.iter;
import net.sf.saxon.expr.elab.LearningEvaluator;
import net.sf.saxon.om.Item;
/**
* This is a subclass of SingletonIterator
that reports to
* a LearningEvaluator
when the single target item is actually
* read. The LearningEvaluator
uses this information to decide
* whether to perform lazy or eager evaluation.
*/
public class ReportingSingletonIterator extends SingletonIterator {
private final LearningEvaluator learningEvaluator;
private final int serialNumber;
/**
* Create a ReportingSingletonIterator
* @param item the single item to be delivered by the iterator
* @param learningEvaluator the class to be notified when the item is read
* @param serialNumber a serial number identifying this evaluation
*/
public ReportingSingletonIterator(Item item, LearningEvaluator learningEvaluator, int serialNumber) {
super(item);
this.learningEvaluator = learningEvaluator;
this.serialNumber = serialNumber;
}
@Override
public Item next() {
Item result = super.next();
if (result != null) {
learningEvaluator.reportCompletion(serialNumber);
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy