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%
registerObserver(Observer)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

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