01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.algebra.evaluation.util;
07:
08: import java.util.ArrayList;
09: import java.util.List;
10:
11: import org.openrdf.query.BindingSet;
12: import org.openrdf.query.Dataset;
13: import org.openrdf.query.algebra.TupleExpr;
14: import org.openrdf.query.algebra.evaluation.QueryOptimizer;
15:
16: /**
17: * A query optimizer that contains a list of other query optimizers, which are
18: * called consecutively when the list's {@link #optimize(TupleExpr, Dataset, BindingSet)}
19: * method is called.
20: *
21: * @author Arjohn Kampman
22: */
23: public class QueryOptimizerList implements QueryOptimizer {
24:
25: protected List<QueryOptimizer> optimizers;
26:
27: public QueryOptimizerList() {
28: this .optimizers = new ArrayList<QueryOptimizer>(8);
29: }
30:
31: public QueryOptimizerList(List<QueryOptimizer> optimizers) {
32: this .optimizers = new ArrayList<QueryOptimizer>(optimizers);
33: }
34:
35: public QueryOptimizerList(QueryOptimizer... optimizers) {
36: this .optimizers = new ArrayList<QueryOptimizer>(
37: optimizers.length);
38: for (QueryOptimizer optimizer : optimizers) {
39: this .optimizers.add(optimizer);
40: }
41: }
42:
43: public void add(QueryOptimizer optimizer) {
44: optimizers.add(optimizer);
45: }
46:
47: public void optimize(TupleExpr tupleExpr, Dataset dataset,
48: BindingSet bindings) {
49: for (QueryOptimizer optimizer : optimizers) {
50: optimizer.optimize(tupleExpr, dataset, bindings);
51: }
52: }
53: }
|