Skip to content

Package: OntologyStorageProperties

OntologyStorageProperties

nameinstructionbranchcomplexitylinemethod
OntologyStorageProperties(OntologyStorageProperties.OntologyStoragePropertiesBuilder)
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
driver(String)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getDriver()
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%
getOntologyURI()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPassword()
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%
getPhysicalURI()
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%
getUsername()
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%
ontologyUri(URI)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
password(String)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
physicalUri(URI)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 55 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
username(String)
M: 6 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) 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;
16:
17: import java.net.URI;
18: import java.util.Objects;
19: import java.util.Optional;
20:
21: /**
22: * Holds properties of an ontology storage.
23: * <p>
24: * These properties can be used to create a DataSource representing the storage.
25: */
26: public class OntologyStorageProperties {
27:
28: /**
29: * URI of the ontology.
30: * <p>
31: * Logical URI is not required, since for example for Sesame storages there is no logical
32: * URI, there is just the physical URI of the repository and multiple contexts in it.
33: * <p>
34: * However, OWLAPI based storages require logical URI.
35: */
36: private final URI ontologyUri;
37: /**
38: * URI of the physical storage, e. g. OWLDB database, OWLIM storage, file
39: */
40: private final URI physicalUri;
41: /**
42: * Fully qualified OntoDriver data source class name
43: */
44: private final String driver;
45: /**
46: * User name for the storage, if necessary
47: */
48: private final String username;
49: /**
50: * Password for the storage, if necessary
51: */
52: private final String password;
53:
54: private OntologyStorageProperties(OntologyStoragePropertiesBuilder builder) {
55: this.physicalUri = Objects.requireNonNull(builder.physicalUri, "Ontology physical URI is required!");
56: this.driver = Objects.requireNonNull(builder.driverClass, "OntDriver data source class name is required!");
57: this.ontologyUri = builder.ontologyUri;
58: this.username = builder.username;
59: this.password = builder.password;
60: }
61:
62: public Optional<URI> getOntologyURI() {
63: return Optional.ofNullable(ontologyUri);
64: }
65:
66: public URI getPhysicalURI() {
67: return physicalUri;
68: }
69:
70: public String getDriver() {
71: return driver;
72: }
73:
74: public String getUsername() {
75: return username;
76: }
77:
78: public String getPassword() {
79: return password;
80: }
81:
82: @Override
83: public String toString() {
84: final StringBuilder b = new StringBuilder();
85: b.append("StorageProperties: logical URI = ");
86: b.append(ontologyUri);
87: b.append(", physical URI = ");
88: b.append(physicalUri);
89: b.append(", data source class = ");
90: b.append(driver);
91:• if (username != null) {
92: b.append(", username = ");
93: b.append(username);
94: b.append(", password = ");
95: b.append(password);
96: }
97: return b.toString();
98: }
99:
100: public static OntologyStoragePropertiesBuilder ontologyUri(URI ontologyUri) {
101: return new OntologyStoragePropertiesBuilder().ontologyUri(ontologyUri);
102: }
103:
104: public static OntologyStoragePropertiesBuilder physicalUri(URI physicalUri) {
105: return new OntologyStoragePropertiesBuilder().physicalUri(physicalUri);
106: }
107:
108: public static OntologyStoragePropertiesBuilder username(String username) {
109: return new OntologyStoragePropertiesBuilder().username(username);
110: }
111:
112: public static OntologyStoragePropertiesBuilder password(String password) {
113: return new OntologyStoragePropertiesBuilder().password(password);
114: }
115:
116: public static OntologyStoragePropertiesBuilder driver(String driverClass) {
117: return new OntologyStoragePropertiesBuilder().driver(driverClass);
118: }
119:
120: /**
121: * Builder class for the {@code OntologyStorageProperties}.
122: */
123: public static class OntologyStoragePropertiesBuilder {
124:
125: private URI ontologyUri;
126: private URI physicalUri;
127: private String username;
128: private String password;
129: private String driverClass;
130:
131: public OntologyStoragePropertiesBuilder ontologyUri(URI ontologyUri) {
132: this.ontologyUri = ontologyUri;
133: return this;
134: }
135:
136: public OntologyStoragePropertiesBuilder ontologyUri(String ontologyUri) {
137: this.ontologyUri = ontologyUri != null ? URI.create(ontologyUri) : null;
138: return this;
139: }
140:
141: public OntologyStoragePropertiesBuilder physicalUri(URI physicalUri) {
142: this.physicalUri = physicalUri;
143: return this;
144: }
145:
146: public OntologyStoragePropertiesBuilder physicalUri(String physicalUri) {
147: this.physicalUri = physicalUri != null ? URI.create(physicalUri) : null;
148: return this;
149: }
150:
151: public OntologyStoragePropertiesBuilder username(String username) {
152: this.username = username;
153: return this;
154: }
155:
156: public OntologyStoragePropertiesBuilder password(String password) {
157: this.password = password;
158: return this;
159: }
160:
161: public OntologyStoragePropertiesBuilder driver(String driverClass) {
162: this.driverClass = driverClass;
163: return this;
164: }
165:
166: public OntologyStorageProperties build() {
167: return new OntologyStorageProperties(this);
168: }
169: }
170: }