Skip to content

Package: OwlapiStatement

OwlapiStatement

nameinstructionbranchcomplexitylinemethod
OwlapiStatement(StatementExecutorFactory, OwlapiConnection)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
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%
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%
executeQuery(String, URI[])
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
executeUpdate(String, URI[])
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getExecutor()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getStatementOntology()
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%
useOntology(Statement.StatementOntology)
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%

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.owlapi.OwlapiConnection;
19: import cz.cvut.kbss.ontodriver.ResultSet;
20: import cz.cvut.kbss.ontodriver.Statement;
21:
22: import java.net.URI;
23: import java.util.Objects;
24:
25: public class OwlapiStatement implements Statement {
26:
27: private StatementOntology targetOntology;
28: private boolean open;
29:
30: private final StatementExecutorFactory executorFactory;
31: final OwlapiConnection connection;
32:
33: public OwlapiStatement(StatementExecutorFactory executorFactory, OwlapiConnection connection) {
34: this.executorFactory = executorFactory;
35: this.connection = connection;
36: this.open = true;
37: }
38:
39: void ensureOpen() {
40:• if (!open) {
41: throw new IllegalStateException("The statement is closed.");
42: }
43: }
44:
45: @Override
46: public ResultSet executeQuery(String sparql, URI... contexts) throws OntoDriverException {
47: ensureOpen();
48: Objects.requireNonNull(sparql);
49: return getExecutor().executeQuery(sparql, this);
50: }
51:
52: StatementExecutor getExecutor() {
53: return executorFactory.getStatementExecutor(targetOntology);
54: }
55:
56: @Override
57: public void executeUpdate(String sparql, URI... contexts) throws OntoDriverException {
58: ensureOpen();
59: Objects.requireNonNull(sparql);
60: getExecutor().executeUpdate(sparql);
61: connection.commitIfAuto();
62: }
63:
64: @Override
65: public void useOntology(StatementOntology ontology) {
66: this.targetOntology = ontology;
67: }
68:
69: @Override
70: public StatementOntology getStatementOntology() {
71: return targetOntology;
72: }
73:
74: @Override
75: public void close() throws Exception {
76: this.open = false;
77: }
78: }