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(Configuration)
M: 5 C: 12
71%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 4
80%
M: 0 C: 1
100%
initConnector(Configuration)
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: 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: *
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.Configuration;
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(Configuration configuration) throws OwlapiDriverException {
33:• if (!open) {
34: throw new IllegalStateException("The factory is closed.");
35: }
36:• if (connector == null) {
37: initConnector(configuration);
38: }
39: return connector;
40: }
41:
42: private void initConnector(Configuration configuration) throws OwlapiDriverException {
43: this.connector = new BasicStorageConnector(configuration);
44: }
45:
46: @Override
47: public boolean isOpen() {
48: return open;
49: }
50:
51: @Override
52: public synchronized void close() throws OntoDriverException {
53:• if (connector != null) {
54: connector.close();
55: }
56: this.open = false;
57: }
58: }