Skip to content

Package: AbstractResultSet

AbstractResultSet

nameinstructionbranchcomplexitylinemethod
AbstractResultSet()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
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%
ensureOpen()
M: 5 C: 4
44%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
ensureState()
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
first()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getRowIndex()
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%
getStatement()
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
hasNext()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
isFirst()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 2
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%
last()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
next()
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
previous()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
registerObserver(Observer)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
relative(int)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setRowIndex(int)
M: 0 C: 19
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
setStatement(JenaStatement)
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%
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) 2022 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.jena.query;
16:
17: import cz.cvut.kbss.ontodriver.ResultSet;
18: import cz.cvut.kbss.ontodriver.Statement;
19: import cz.cvut.kbss.ontodriver.jena.exception.JenaDriverException;
20:
21: import java.util.NoSuchElementException;
22: import java.util.Observer;
23:
24: public abstract class AbstractResultSet implements ResultSet {
25:
26: private boolean open = true;
27: private int rowIndex = -1;
28:
29: private JenaStatement statement;
30:
31: void setStatement(JenaStatement statement) {
32: this.statement = statement;
33: }
34:
35: void ensureOpen() {
36:• if (!open) {
37: throw new IllegalStateException("This result set is closed.");
38: }
39: }
40:
41: @Override
42: public Statement getStatement() {
43: ensureOpen();
44:• assert statement != null;
45: return statement;
46: }
47:
48: @Override
49: public boolean isFirst() {
50: ensureOpen();
51:• return rowIndex == 0;
52: }
53:
54: @Override
55: public void last() {
56: ensureOpen();
57:• while (hasNext()) {
58: next();
59: }
60: }
61:
62: @Override
63: public void first() {
64: throw new UnsupportedOperationException("This result set does not support returning to the first rowIndex.");
65: }
66:
67: void ensureState() {
68: ensureOpen();
69:• if (getRowIndex() < 0) {
70: throw new IllegalStateException("Must call next before getting any values.");
71: }
72: }
73:
74: @Override
75: public boolean hasNext() {
76: // Intended for overriding
77: ensureOpen();
78: return false;
79: }
80:
81: @Override
82: public void next() {
83: ensureOpen();
84:• if (!hasNext()) {
85: throw new NoSuchElementException("No more rows found in this result set.");
86: }
87: this.rowIndex++;
88: }
89:
90: @Override
91: public void previous() {
92: throw new UnsupportedOperationException("Moving back is not supported by this result set.");
93: }
94:
95: @Override
96: public void registerObserver(Observer observer) {
97: throw new UnsupportedOperationException("Not supported by the current version.");
98: }
99:
100: @Override
101: public void relative(int rows) {
102: ensureOpen();
103: setRowIndex(rowIndex + rows);
104: }
105:
106: @Override
107: public int getRowIndex() {
108: return rowIndex;
109: }
110:
111: @Override
112: public void setRowIndex(int newIndex) {
113: ensureOpen();
114:• if (newIndex < rowIndex) {
115: throw new UnsupportedOperationException("Moving back is not supported by this result set.");
116: }
117:• while (rowIndex < newIndex) {
118: next();
119: }
120: }
121:
122: @Override
123: public void close() throws JenaDriverException {
124: this.open = false;
125: }
126:
127: @Override
128: public boolean isOpen() {
129: return open;
130: }
131: }