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%
getConnector(OntologyStorageProperties, Configuration)
M: 5 C: 13
72%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 4
80%
M: 0 C: 1
100%
initConnector(OntologyStorageProperties, Configuration)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
isOpen()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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