Debian Codegraph @

net/sf/saxon/functions/Fold.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.functions;
9
10 import net.sf.saxon.om.Item;
11 import net.sf.saxon.om.Sequence;
12 import net.sf.saxon.trans.XPathException;
13
14 /* Interface implemented by operations that compute the value of an expression using
15 * a "fold" operation: that is, by applying a function to each item in the input sequence
16 * in turn, maintaining working data as the the items are processed, and finally computing
17 * the final result of the expression from the value of the working data.
18 */
19 public interface Fold {
20
21 /**
22 * Process one item in the input sequence, returning a new copy of the working data
23 * @param item the item to be processed from the input sequence
24 * @throws XPathException if a dynamic error occurs
25 */
26
27 void processItem(Item<?> item) throws XPathException;
28
29 /**
30 * Ask whether the computation has completed. A function that can deliver its final
31 * result without reading the whole input should return true; this will be followed
32 * by a call on result() to deliver the final result.
33 * @return true if the result of the function is now available even though not all
34 * items in the sequence have been processed
35 */
36
37 boolean isFinished();
38
39 /**
40 * Compute the final result of the function, when all the input has been processed
41 * @return the result of the function
42 * @throws XPathException if a dynamic error occurs
43 */
44
45 Sequence<?> result() throws XPathException;
46
47 }
48