Skip to content

Package: InferredReferencedListIterator

InferredReferencedListIterator

nameinstructionbranchcomplexitylinemethod
InferredReferencedListIterator(ReferencedListDescriptor, OntologySnapshot, AxiomAdapter)
M: 4 C: 20
83%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 5
83%
M: 0 C: 1
100%
doStep()
M: 0 C: 42
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
hasNext()
M: 0 C: 16
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 3
100%
M: 0 C: 1
100%
nextValue()
M: 5 C: 26
84%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 6
86%
M: 0 C: 1
100%
removeWithoutReconnect()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
replaceNode(NamedResource)
M: 4 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.list;
16:
17: import cz.cvut.kbss.ontodriver.owlapi.AxiomAdapter;
18: import cz.cvut.kbss.ontodriver.owlapi.connector.OntologySnapshot;
19: import cz.cvut.kbss.ontodriver.owlapi.exception.ReasonerNotAvailableException;
20: import cz.cvut.kbss.ontodriver.owlapi.util.OwlapiUtils;
21: import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptor;
22: import cz.cvut.kbss.ontodriver.model.NamedResource;
23: import org.semanticweb.owlapi.model.OWLIndividual;
24: import org.semanticweb.owlapi.model.OWLNamedIndividual;
25: import org.semanticweb.owlapi.model.OWLOntologyChange;
26: import org.semanticweb.owlapi.reasoner.OWLReasoner;
27:
28: import java.util.Collection;
29: import java.util.Collections;
30: import java.util.List;
31: import java.util.NoSuchElementException;
32:
33: class InferredReferencedListIterator extends ReferencedListIterator {
34:
35: private OWLNamedIndividual currentNode;
36: private OWLReasoner reasoner;
37:
38: InferredReferencedListIterator(ReferencedListDescriptor descriptor, OntologySnapshot snapshot,
39: AxiomAdapter axiomAdapter) {
40: super(descriptor, snapshot, axiomAdapter);
41: this.reasoner = snapshot.getReasoner();
42:• if (reasoner == null) {
43: throw new ReasonerNotAvailableException();
44: }
45: this.currentNode = OwlapiUtils.getIndividual(descriptor.getListOwner(), snapshot.getDataFactory());
46: }
47:
48: @Override
49: public boolean hasNext() {
50:• if (next == null) {
51: doStep();
52: }
53:• return next != null && !next.isEmpty();
54: }
55:
56: @Override
57: void doStep() {
58: final Collection<OWLNamedIndividual> nextNodes = reasoner
59: .getObjectPropertyValues(currentNode, currentNextNodeProperty).getFlattened();
60:• if (nextNodes.isEmpty()) {
61: this.next = Collections.emptyList();
62: return;
63: }
64: checkMaxSuccessors(currentNextNodeProperty, nextNodes);
65: this.currentNextNodeProperty = hasNextProperty;
66: this.currentNode = nextNodes.iterator().next();
67: this.next = reasoner.getObjectPropertyValues(currentNode, hasContentProperty).getFlattened();
68: }
69:
70: @Override
71: NamedResource nextValue() {
72:• if (!hasNext()) {
73: throw new NoSuchElementException("There are no more elements.");
74: }
75: checkMaxSuccessors(hasContentProperty, next);
76: final OWLIndividual value = next.iterator().next();
77: checkIsNamed(value);
78: doStep();
79: return NamedResource.create(value.asOWLNamedIndividual().getIRI().toURI());
80: }
81:
82: @Override
83: List<OWLOntologyChange> removeWithoutReconnect() {
84: throw new UnsupportedOperationException();
85: }
86:
87: @Override
88: List<OWLOntologyChange> replaceNode(NamedResource newValue) {
89: throw new UnsupportedOperationException();
90: }
91: }