Skip to content

Package: AbstractResultSet

AbstractResultSet

nameinstructionbranchcomplexitylinemethod
AbstractResultSet(Statement)
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: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
createResultSet(QueryResult, Statement, String)
M: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
ensureOpen()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getStatement()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isAskQuery(String)
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%
isOpen()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

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.owlapi.query;
16:
17: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
18: import cz.cvut.kbss.ontodriver.ResultSet;
19: import cz.cvut.kbss.ontodriver.Statement;
20: import cz.cvut.kbss.owl2query.model.QueryResult;
21: import org.semanticweb.owlapi.model.OWLObject;
22:
23: public abstract class AbstractResultSet implements ResultSet {
24:
25: private boolean open;
26: private final Statement statement;
27:
28: protected AbstractResultSet(Statement statement) {
29: this.statement = statement;
30: this.open = true;
31: }
32:
33: void ensureOpen() {
34:• if (!open) {
35: throw new IllegalStateException("The result set is closed.");
36: }
37: }
38:
39: @Override
40: public Statement getStatement() throws OntoDriverException {
41: return statement;
42: }
43:
44: @Override
45: public void close() throws OntoDriverException {
46: this.open = false;
47: }
48:
49: @Override
50: public boolean isOpen() {
51: return open;
52: }
53:
54: public static ResultSet createResultSet(QueryResult<OWLObject> result, Statement statement, String query) {
55:• if (isAskQuery(query)) {
56: return new AskResultSet(result, statement);
57: } else {
58: return new SelectResultSet(result, statement);
59: }
60: }
61:
62: private static boolean isAskQuery(String statement) {
63: return statement.toLowerCase().startsWith("ask");
64: }
65: }