Package: QueryResult
QueryResult
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
QueryResult(TupleQueryResult, RepositoryConnection) |
|
|
|
|
|
||||||||||||||||||||
close() |
|
|
|
|
|
||||||||||||||||||||
getBindingNames() |
|
|
|
|
|
||||||||||||||||||||
hasNext() |
|
|
|
|
|
||||||||||||||||||||
next() |
|
|
|
|
|
||||||||||||||||||||
remove() |
|
|
|
|
|
Coverage
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.ontodriver.sesame.connector;
16:
17: import org.eclipse.rdf4j.query.BindingSet;
18: import org.eclipse.rdf4j.query.QueryEvaluationException;
19: import org.eclipse.rdf4j.query.TupleQueryResult;
20: import org.eclipse.rdf4j.repository.RepositoryConnection;
21: import org.eclipse.rdf4j.repository.RepositoryException;
22:
23: import java.util.List;
24:
25: /**
26: * This class wraps the Sesame TupleQueryResult returned by QueryExecutor to be
27: * able to close the repository connection once the result is closed.
28: *
29: */
30: class QueryResult implements TupleQueryResult {
31:
32:         private final TupleQueryResult result;
33:         private final RepositoryConnection connection;
34:
35:         QueryResult(TupleQueryResult result, RepositoryConnection connection) {
36:                 this.result = result;
37:                 this.connection = connection;
38:         }
39:
40:         @Override
41:         public void close() throws QueryEvaluationException {
42:                 result.close();
43:                 try {
44:                         connection.close();
45:                 } catch (RepositoryException e) {
46:                         throw new QueryEvaluationException(e);
47:                 }
48:         }
49:
50:         @Override
51:         public boolean hasNext() throws QueryEvaluationException {
52:                 return result.hasNext();
53:         }
54:
55:         @Override
56:         public BindingSet next() throws QueryEvaluationException {
57:                 return result.next();
58:         }
59:
60:         @Override
61:         public void remove() throws QueryEvaluationException {
62:                 result.remove();
63:         }
64:
65:         @Override
66:         public List<String> getBindingNames() throws QueryEvaluationException {
67:                 return result.getBindingNames();
68:         }
69: }