Skip to content

Package: MappingFileParser

MappingFileParser

nameinstructionbranchcomplexitylinemethod
MappingFileParser(DriverConfiguration)
M: 4 C: 21
84%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 6
100%
M: 0 C: 1
100%
getMappings()
M: 4 C: 10
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
resolveMappingFile(String)
M: 0 C: 52
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.owlapi.util;
14:
15: import cz.cvut.kbss.jopa.owlapi.exception.MappingFileParserException;
16: import cz.cvut.kbss.ontodriver.config.DriverConfiguration;
17: import cz.cvut.kbss.ontodriver.owlapi.config.OwlapiConfigParam;
18: import cz.cvut.kbss.ontodriver.owlapi.config.OwlapiOntoDriverProperties;
19:
20: import java.io.File;
21: import java.net.URI;
22: import java.util.Map;
23:
24: public class MappingFileParser {
25:
26: private final File mappingFile;
27:
28: private final String delimiter;
29:
30: public MappingFileParser(DriverConfiguration configuration) {
31: final String mappingFilePath = configuration.getProperty(OwlapiConfigParam.MAPPING_FILE_LOCATION);
32:• assert mappingFilePath != null;
33: this.mappingFile = resolveMappingFile(mappingFilePath);
34: this.delimiter = configuration.getProperty(OwlapiConfigParam.IRI_MAPPING_DELIMITER,
35: OwlapiOntoDriverProperties.DEFAULT_IRI_MAPPING_DELIMITER);
36: }
37:
38: private File resolveMappingFile(String path) {
39: File mapping = new File(path);
40:• if (mapping.exists()) {
41: return mapping;
42: }
43: try {
44: mapping = new File(URI.create(path));
45:• if (mapping.exists()) {
46: return mapping;
47: }
48: } catch (IllegalArgumentException e) {
49: throw new MappingFileParserException(
50: "Mapping file path " + path + " is neither a valid file path nor a valid URI.", e);
51: }
52: throw new MappingFileParserException("Mapping file " + path + " does not exist.");
53: }
54:
55: public Map<URI, URI> getMappings() {
56:• assert mappingFile != null;
57:
58: return cz.cvut.kbss.jopa.util.MappingFileParser.getMappings(mappingFile, delimiter);
59: }
60: }