Package: SesamePreparedStatement
SesamePreparedStatement
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SesamePreparedStatement(StatementExecutor, String) |
|
|
|
|
|
||||||||||||||||||||
clearParameters() |
|
|
|
|
|
||||||||||||||||||||
executeQuery() |
|
|
|
|
|
||||||||||||||||||||
executeUpdate() |
|
|
|
|
|
||||||||||||||||||||
setObject(String, Object) |
|
|
|
|
|
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.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: 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: }