Skip to content

Package: BasicConnectorFactory

BasicConnectorFactory

nameinstructionbranchcomplexitylinemethod
BasicConnectorFactory()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
close()
M: 0 C: 10
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
ensureOpen()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getConnector(DriverConfiguration)
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
initConnector(DriverConfiguration)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
isOpen()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
reloadData()
M: 0 C: 10
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

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.owlapi.connector;
16:
17: import cz.cvut.kbss.ontodriver.config.DriverConfiguration;
18: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
19: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
20:
21: public class BasicConnectorFactory implements ConnectorFactory {
22:
23: private boolean open;
24:
25: private AbstractConnector connector;
26:
27: BasicConnectorFactory() {
28: this.open = true;
29: }
30:
31: @Override
32: public synchronized AbstractConnector getConnector(DriverConfiguration configuration) throws OwlapiDriverException {
33: ensureOpen();
34:• if (connector == null) {
35: initConnector(configuration);
36: }
37: return connector;
38: }
39:
40: private void ensureOpen() {
41:• if (!open) {
42: throw new IllegalStateException("The factory is closed.");
43: }
44: }
45:
46: private void initConnector(DriverConfiguration configuration) throws OwlapiDriverException {
47: this.connector = new BasicStorageConnector(configuration);
48: }
49:
50: @Override
51: public boolean isOpen() {
52: return open;
53: }
54:
55: @Override
56: public synchronized void reloadData() throws OwlapiDriverException {
57: ensureOpen();
58:• if (connector == null) {
59: return;
60: }
61: connector.reloadData();
62: }
63:
64: @Override
65: public synchronized void close() throws OntoDriverException {
66:• if (connector != null) {
67: connector.close();
68: }
69: this.open = false;
70: }
71: }