Skip to content

Method: static {...}

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.ontodriver;
19:
20: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
21:
22: /**
23: * This interface represents a SPARQL statement.
24: */
25: public interface Statement extends AutoCloseable {
26:
27: /**
28: * Specifies which ontology is used for statement evaluation.
29: */
30: enum StatementOntology {
31: /**
32: * Transactional ontology. May contain uncommitted changes which influence the statement evaluation.
33: */
34: TRANSACTIONAL,
35: /**
36: * The main ontology in the current state. No uncommitted changes are present in it.
37: */
38: SHARED
39: }
40:
41: /**
42: * Execute the specified SPARQL query.
43: *
44: * @param sparql The statement to execute
45: * @return {@code ResultSet} containing results of the query
46: * @throws OntoDriverException If an error occurs during query execution
47: */
48: ResultSet executeQuery(String sparql) throws OntoDriverException;
49:
50: /**
51: * Execute the specified SPARQL update query.
52: *
53: * @param sparql The statement to execute
54: * @throws OntoDriverException If an error occurs during query execution
55: */
56: void executeUpdate(String sparql) throws OntoDriverException;
57:
58: /**
59: * Sets which ontology is used to evaluate this statement.
60: * <p>
61: * {@link Statement.StatementOntology#TRANSACTIONAL} ontology is the transactional version. It may contain
62: * uncommitted changes and thus the query results may differ from evaluation against {@link
63: * Statement.StatementOntology#SHARED}.
64: * <p>
65: * Note that implementations may ignore this setting depending on their internal transaction management mechanisms.
66: *
67: * @param ontology Which ontology to use
68: */
69: void useOntology(StatementOntology ontology);
70:
71: /**
72: * Gets information about which ontology will be used to evaluate the statement.
73: *
74: * @return Which ontology will be used for evaluation
75: * @see #useOntology(StatementOntology)
76: */
77: StatementOntology getStatementOntology();
78:
79: /**
80: * Whether this statement is still open.
81: * <p>
82: * A {@code Statement} is closed if the method {@link #close()} has been called on it.
83: *
84: * @return Open status
85: */
86: boolean isOpen();
87:
88: /**
89: * Closes this statement, releasing any resources it has hold.
90: * <p>
91: * Calling the method close on a Statement object that is already closed has no effect.
92: * <p>
93: * Note: When a {@code Statement} object is closed, its current {@code ResultSet} object, if one exists, is also
94: * closed.
95: *
96: * @throws OntoDriverException If closing the statement fails
97: */
98: @Override
99: void close() throws OntoDriverException;
100:
101: /**
102: * Disables inference for execution of this statement.
103: * <p>
104: * Note that by default, inference is enabled for execution of all statements (depending on whether the underlying
105: * storage supports inference at all). Also note that in case the underlying repository does not support disabling
106: * inference, this configuration may be silently ignored.
107: */
108: void disableInference();
109:
110: /**
111: * Checks whether inference is disabled for execution of this statement.
112: *
113: * @return Inference disabled status
114: * @see #disableInference()
115: */
116: boolean isInferenceDisabled();
117: }