Skip to content

Package: OwlapiPreparedStatement

OwlapiPreparedStatement

nameinstructionbranchcomplexitylinemethod
OwlapiPreparedStatement(StatementExecutorFactory, OwlapiConnection, String)
M: 24 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
clearParameters()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
executeQuery()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
executeUpdate()
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
setObject(String, Object)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 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.owlapi.query;
16:
17: import cz.cvut.kbss.ontodriver.PreparedStatement;
18: import cz.cvut.kbss.ontodriver.ResultSet;
19: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
20: import cz.cvut.kbss.ontodriver.owlapi.OwlapiConnection;
21: import cz.cvut.kbss.ontodriver.util.StatementHolder;
22:
23: import java.util.Objects;
24:
25: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.npxMessage;
26:
27: public class OwlapiPreparedStatement extends OwlapiStatement implements PreparedStatement {
28:
29: private final StatementHolder statementHolder;
30:
31: public OwlapiPreparedStatement(StatementExecutorFactory executorFactory, OwlapiConnection connection,
32: String statement) {
33: super(executorFactory, connection);
34: this.statementHolder = new StatementHolder(statement);
35:• if (statementHolder.getStatement().isEmpty()) {
36: throw new IllegalArgumentException("Statement cannot be empty.");
37: }
38: statementHolder.analyzeStatement();
39: }
40:
41: @Override
42: public ResultSet executeQuery() throws OntoDriverException {
43: ensureOpen();
44: return getExecutor().executeQuery(statementHolder.assembleStatement(), this);
45: }
46:
47: @Override
48: public void executeUpdate() throws OntoDriverException {
49: ensureOpen();
50: getExecutor().executeUpdate(statementHolder.assembleStatement());
51: connection.commitIfAuto();
52: }
53:
54: @Override
55: public void setObject(String binding, Object value) throws OntoDriverException {
56: ensureOpen();
57: Objects.requireNonNull(binding, npxMessage("binding"));
58: Objects.requireNonNull(value, npxMessage("value"));
59: statementHolder.setParameter(binding, value.toString());
60: }
61:
62: @Override
63: public void clearParameters() throws OntoDriverException {
64: ensureOpen();
65: statementHolder.clearParameters();
66: }
67: }