Skip to content

Package: ObjectModel

ObjectModel

nameinstructionbranchcomplexitylinemethod
ObjectModel(JCodeModel)
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%
getCodeModel()
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%
static {...}
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%
writeModel(String)
M: 8 C: 19
70%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 3 C: 6
67%
M: 0 C: 1
100%

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.jopa.owl2java;
16:
17: import com.sun.codemodel.JCodeModel;
18: import org.slf4j.Logger;
19: import org.slf4j.LoggerFactory;
20:
21: import java.io.File;
22: import java.io.IOException;
23:
24: /**
25: * Wraps the generated object model, allowing to access it in memory or write it out to the file system.
26: */
27: class ObjectModel {
28:
29: private static final Logger LOG = LoggerFactory.getLogger(ObjectModel.class);
30:
31: private final JCodeModel codeModel;
32:
33: ObjectModel(JCodeModel codeModel) {
34: this.codeModel = codeModel;
35: }
36:
37: JCodeModel getCodeModel() {
38: return codeModel;
39: }
40:
41: /**
42: * Writes out the object model.
43: *
44: * @param targetDir Target directory for the object model
45: */
46: void writeModel(String targetDir) {
47: try {
48: final File file = new File(targetDir);
49: final boolean result = file.mkdirs();
50:• if (!result && !file.exists()) {
51: LOG.error("Unable to create target directory structure.");
52: }
53: codeModel.build(file);
54: } catch (IOException e) {
55: LOG.error("Unable to write out the generated object model.", e);
56: }
57: }
58: }