Skip to content

Package: ConnectorFactory

ConnectorFactory

nameinstructionbranchcomplexitylinemethod
ConnectorFactory()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
close()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
createInferredConnector(StorageConnector)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
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%
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%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 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.jena.connector;
19:
20: import cz.cvut.kbss.ontodriver.Closeable;
21: import cz.cvut.kbss.ontodriver.jena.exception.JenaDriverException;
22: import org.apache.jena.query.Dataset;
23:
24: public abstract class ConnectorFactory implements Closeable {
25:
26: private volatile boolean open = true;
27:
28: @Override
29: public synchronized void close() throws JenaDriverException {
30: this.open = false;
31: }
32:
33: @Override
34: public boolean isOpen() {
35: return open;
36: }
37:
38: void ensureOpen() {
39:• if (!open) {
40: throw new IllegalStateException("Factory is closed.");
41: }
42: }
43:
44: /**
45: * Creates a storage connector.
46: *
47: * @return storage connector
48: */
49: public abstract StorageConnector createConnector();
50:
51: /**
52: * Creates an inference-supporting storage connector.
53: * <p>
54: * The {@code connector} parameter is required because both connector need to be kept in sync so that non-inferred
55: * data are consistent across both connectors.
56: *
57: * @param connector Existing storage connector
58: * @return New inference-supporting storage connector
59: */
60: public InferredStorageConnector createInferredConnector(StorageConnector connector) {
61: return new DummyInferredStorageConnector(connector);
62: }
63:
64: /**
65: * Reloads data from storage if it is a file-based one.
66: * <p>
67: * Does nothing for other types of storage.
68: */
69: public abstract void reloadStorage();
70:
71: /**
72: * Sets dataset on the underlying connector.
73: * <p>
74: * Not that this operation is supported only for in-memory storage.
75: *
76: * @param dataset Dataset to set
77: */
78: public abstract void setDataset(Dataset dataset);
79: }