Debian Codegraph @

bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Cloudsmith Inc. and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * Cloudsmith Inc. - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.equinox.p2.metadata.expression;
15
16 import java.util.Iterator;
17 import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
18
19 /**
20 * This is an expression that will need access to the global variable
21 * <code>everything</code>.
22 * @since 2.0
23 */
24 public interface IContextExpression<T> extends IExpression {
25
26 /**
27 * <p>Creates a new context to be passed to a subsequent evaluation. The context
28 * will have the variable 'everything' set to an expression that represents
29 * the <code>everything</code> iterator filtered for instances of <code>elementClass</code>.</p>
30 * <p>The values of the iterator will be copied if necessary (when everything is referenced
31 * more then once).</p>
32 * @param elementClass the class of the iterator elements
33 * @param indexProvider The index provider that represents all queried material.
34 * @return A new evaluation context.
35 */
36 IEvaluationContext createContext(Class<? extends T> elementClass, IIndexProvider<T> indexProvider);
37
38 /**
39 * <p>Creates a new context to be passed to a subsequent evaluation. The context
40 * will have the variable 'everything' set to an expression that represents
41 * the <code>everything</code> iterator filtered for instances of <code>elementClass</code>.</p>
42 * <p>The values of the iterator will be copied if necessary (when everything is referenced
43 * more then once).</p>
44 * @param elementClass the class of the iterator elements
45 * @param everything The iterator that represents all queried material.
46 * @return A new evaluation context.
47 */
48 IEvaluationContext createContext(Class<? extends T> elementClass, Iterator<T> everything);
49
50 /**
51 * Returns the parameters that this context expression was created with.
52 * @return An array of parameters, possibly empty but never <code>null</code>.
53 */
54 Object[] getParameters();
55
56 /**
57 * Evaluate the expression and return the expected collection result as an iterator
58 * @param context The evaluation context
59 * @return The result of the evaluation.
60 */
61 Iterator<T> iterator(IEvaluationContext context);
62 }