Skip to content

Package: Statement

Statement

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;
16:
17: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
18:
19: /**
20: * This interface represents a SPARQL statement.
21: */
22: public interface Statement extends AutoCloseable {
23:
24: /**
25: * Specifies which ontology is used for statement evaluation.
26: */
27: enum StatementOntology {
28: /**
29: * Transactional ontology. May contain uncommitted changes which influence the statement evaluation.
30: */
31: TRANSACTIONAL,
32: /**
33: * The main ontology in the current state. No uncommitted changes are present in it.
34: */
35: CENTRAL
36: }
37:
38: /**
39: * Execute the specified SPARQL query.
40: *
41: * @param sparql The statement to execute
42: * @return {@code ResultSet} containing results of the query
43: * @throws OntoDriverException If an error occurs during query execution
44: */
45: ResultSet executeQuery(String sparql) throws OntoDriverException;
46:
47: /**
48: * Execute the specified SPARQL update query.
49: *
50: * @param sparql The statement to execute
51: * @throws OntoDriverException If an error occurs during query execution
52: */
53: void executeUpdate(String sparql) throws OntoDriverException;
54:
55: /**
56: * Sets which ontology is used to evaluate this statement.
57: * <p>
58: * {@link Statement.StatementOntology#TRANSACTIONAL} ontology is the transactional
59: * snapshot. It may contain uncommitted changes and thus the query results may differ from evaluation against {@link
60: * Statement.StatementOntology#CENTRAL}.
61: *
62: * @param ontology Which ontology to use
63: */
64: void useOntology(StatementOntology ontology);
65:
66: /**
67: * Gets information about which ontology will be used to evaluate the statement.
68: *
69: * @return Which ontology will be used for evaluation
70: * @see #useOntology(StatementOntology)
71: */
72: StatementOntology getStatementOntology();
73:
74: /**
75: * Whether this statement is still open.
76: * <p>
77: * A {@code Statement} is closed if the method {@link #close()} has been called on it.
78: *
79: * @return Open status
80: */
81: boolean isOpen();
82:
83: /**
84: * Closes this statement, releasing any resources it has hold.
85: * <p>
86: * Calling the method close on a Statement object that is already closed has no effect.
87: * <p>
88: * Note: When a {@code Statement} object is closed, its current {@code ResultSet} object, if one exists, is also closed.
89: *
90: * @throws OntoDriverException If closing the statement fails
91: */
92: @Override
93: void close() throws OntoDriverException;
94: }