Skip to content

Package: QueryResult

QueryResult

nameinstructionbranchcomplexitylinemethod
QueryResult(TupleQueryResult, RepositoryConnection)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
close()
M: 6 C: 8
57%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 4
67%
M: 0 C: 1
100%
getBindingNames()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasNext()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
next()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
remove()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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 java.util.List;
18:
19: import org.openrdf.query.BindingSet;
20: import org.openrdf.query.QueryEvaluationException;
21: import org.openrdf.query.TupleQueryResult;
22: import org.openrdf.repository.RepositoryConnection;
23: import org.openrdf.repository.RepositoryException;
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: * @author ledvima1
30: *
31: */
32: class QueryResult implements TupleQueryResult {
33:
34:         private final TupleQueryResult result;
35:         private final RepositoryConnection connection;
36:
37:         QueryResult(TupleQueryResult result, RepositoryConnection connection) {
38:                 this.result = result;
39:                 this.connection = connection;
40:         }
41:
42:         @Override
43:         public void close() throws QueryEvaluationException {
44:                 result.close();
45:                 try {
46:                         connection.close();
47:                 } catch (RepositoryException e) {
48:                         throw new QueryEvaluationException(e);
49:                 }
50:         }
51:
52:         @Override
53:         public boolean hasNext() throws QueryEvaluationException {
54:                 return result.hasNext();
55:         }
56:
57:         @Override
58:         public BindingSet next() throws QueryEvaluationException {
59:                 return result.next();
60:         }
61:
62:         @Override
63:         public void remove() throws QueryEvaluationException {
64:                 result.remove();
65:         }
66:
67:         @Override
68:         public List<String> getBindingNames() throws QueryEvaluationException {
69:                 return result.getBindingNames();
70:         }
71: }