Skip to content

Package: SesamePreparedStatement

SesamePreparedStatement

nameinstructionbranchcomplexitylinemethod
SesamePreparedStatement(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: 10
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: 10
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) 2016 Czech Technical University in Prague
3: * <p>
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: * <p>
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.sesame.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.sesame.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 SesamePreparedStatement extends SesameStatement implements PreparedStatement {
28:
29: private StatementHolder statementHolder;
30:
31: public SesamePreparedStatement(StatementExecutor executor, String statement)
32: throws OntoDriverException {
33: super(executor);
34: this.statementHolder = new StatementHolder(statement);
35:• if (statementHolder.getStatement().isEmpty()) {
36: throw new IllegalArgumentException("The statement string cannot be empty.");
37: }
38: statementHolder.analyzeStatement();
39: }
40:
41: @Override
42: public void setObject(String binding, Object value) throws OntoDriverException {
43: ensureOpen();
44: Objects.requireNonNull(value, getNPXMessageSupplier("value"));
45: statementHolder.setParameter(binding, value.toString());
46: }
47:
48: @Override
49: public ResultSet executeQuery() throws OntoDriverException {
50: ensureOpen();
51: return executeQuery(statementHolder.assembleStatement());
52: }
53:
54: @Override
55: public void executeUpdate() throws OntoDriverException {
56: ensureOpen();
57: executeUpdate(statementHolder.assembleStatement());
58: }
59:
60: @Override
61: public void clearParameters() throws OntoDriverException {
62: statementHolder.clearParameters();
63: }
64: }