Skip to content

Package: Rdf4jPreparedStatement

Rdf4jPreparedStatement

nameinstructionbranchcomplexitylinemethod
Rdf4jPreparedStatement(StatementExecutor, String)
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
clearParameters()
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%
executeQuery()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
executeUpdate()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setObject(String, Object)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2022 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.rdf4j.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.rdf4j.connector.StatementExecutor;
21: import cz.cvut.kbss.ontodriver.util.StatementHolder;
22:
23: import java.util.Objects;
24:
25: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
26:
27: public class Rdf4jPreparedStatement extends Rdf4jStatement implements PreparedStatement {
28:
29: private final StatementHolder statementHolder;
30:
31: public Rdf4jPreparedStatement(StatementExecutor executor, String statement) {
32: super(executor);
33: this.statementHolder = new StatementHolder(statement);
34:• if (statementHolder.getStatement().isEmpty()) {
35: throw new IllegalArgumentException("The statement string cannot be empty.");
36: }
37: statementHolder.analyzeStatement();
38: }
39:
40: @Override
41: public void setObject(String binding, Object value) {
42: ensureOpen();
43: Objects.requireNonNull(value, getNPXMessageSupplier("value"));
44: statementHolder.setParameter(binding, value.toString());
45: }
46:
47: @Override
48: public ResultSet executeQuery() throws OntoDriverException {
49: ensureOpen();
50: return executeQuery(statementHolder.assembleStatement());
51: }
52:
53: @Override
54: public void executeUpdate() throws OntoDriverException {
55: ensureOpen();
56: executeUpdate(statementHolder.assembleStatement());
57: }
58:
59: @Override
60: public void clearParameters() {
61: statementHolder.clearParameters();
62: }
63: }