01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.impl;
07:
08: import java.util.ArrayList;
09: import java.util.List;
10:
11: import org.openrdf.query.BindingSet;
12: import org.openrdf.query.TupleQueryResult;
13: import org.openrdf.query.TupleQueryResultHandlerBase;
14: import org.openrdf.query.TupleQueryResultHandlerException;
15:
16: /**
17: * A TupleQueryResultHandler that can be used to create a TupleQueryResult object.
18: */
19: public class TupleQueryResultBuilder extends
20: TupleQueryResultHandlerBase {
21:
22: /*-----------*
23: * Variables *
24: *-----------*/
25:
26: private List<String> bindingNames;
27:
28: private List<BindingSet> bindingSetList;
29:
30: /*---------*
31: * Methods *
32: *---------*/
33:
34: @Override
35: public void startQueryResult(List<String> bindingNames)
36: throws TupleQueryResultHandlerException {
37: this .bindingNames = bindingNames;
38: bindingSetList = new ArrayList<BindingSet>();
39: }
40:
41: @Override
42: public void handleSolution(BindingSet bindingSet)
43: throws TupleQueryResultHandlerException {
44: bindingSetList.add(bindingSet);
45: }
46:
47: public TupleQueryResult getQueryResult() {
48: return new TupleQueryResultImpl(bindingNames, bindingSetList);
49: }
50: }
|