1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.kernel.bo.logic.model; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import org.qedeq.base.utility.Enumerator; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 69.1% |
Uncovered Elements: 17 (55) |
Complexity: 12 |
Complexity Density: 0.32 |
|
29 |
|
public final class FunctionVariableInterpreter { |
30 |
|
|
31 |
|
|
32 |
|
private Model model; |
33 |
|
|
34 |
|
|
35 |
|
private List functionVariables; |
36 |
|
|
37 |
|
|
38 |
|
private List functionVariableCounters; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@param |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
45 |
494
|
public FunctionVariableInterpreter(final Model model) {... |
46 |
494
|
this.model = model; |
47 |
494
|
functionVariables = new ArrayList(); |
48 |
494
|
functionVariableCounters = new ArrayList(); |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@param |
55 |
|
@return |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
57 |
698
|
private int getFunctionVariableSelection(final FunctionVariable var) {... |
58 |
698
|
int selection; |
59 |
698
|
if (functionVariables.contains(var)) { |
60 |
678
|
final int index = functionVariables.indexOf(var); |
61 |
678
|
selection = ((Enumerator) functionVariableCounters.get(index)).getNumber(); |
62 |
|
} else { |
63 |
|
|
64 |
20
|
selection = 0; |
65 |
20
|
functionVariables.add(var); |
66 |
20
|
functionVariableCounters.add(new Enumerator()); |
67 |
|
} |
68 |
698
|
return selection; |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@return |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
698
|
public Function getFunction(final FunctionVariable var) {... |
78 |
698
|
return model.getFunction(var.getArgumentNumber(), |
79 |
|
getFunctionVariableSelection(var)); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@return |
86 |
|
|
|
|
| 94.4% |
Uncovered Elements: 1 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
87 |
381
|
public boolean next() {... |
88 |
381
|
boolean next = true; |
89 |
397
|
for (int i = functionVariables.size() - 1; i >= -1; i--) { |
90 |
397
|
if (i < 0) { |
91 |
346
|
next = false; |
92 |
346
|
break; |
93 |
|
} |
94 |
51
|
final FunctionVariable var = (FunctionVariable) functionVariables.get(i); |
95 |
51
|
final Enumerator number = (Enumerator) functionVariableCounters.get(i); |
96 |
51
|
if (number.getNumber() + 1 < model.getFunctionSize(var.getArgumentNumber())) { |
97 |
35
|
number.increaseNumber(); |
98 |
35
|
break; |
99 |
|
} |
100 |
16
|
number.reset(); |
101 |
|
} |
102 |
381
|
return next; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
105 |
0
|
public String toString() {... |
106 |
0
|
final StringBuffer buffer = new StringBuffer(); |
107 |
0
|
buffer.append("function variables {"); |
108 |
0
|
for (int i = 0; i < functionVariables.size(); i++) { |
109 |
0
|
if (i > 0) { |
110 |
0
|
buffer.append(", "); |
111 |
|
} |
112 |
0
|
FunctionVariable var = (FunctionVariable) functionVariables.get(i); |
113 |
0
|
buffer.append(functionVariables.get(i)); |
114 |
0
|
buffer.append("="); |
115 |
0
|
buffer.append(getFunction(var)); |
116 |
|
} |
117 |
0
|
buffer.append("}"); |
118 |
0
|
return buffer.toString(); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
124 |
48
|
public void clear() {... |
125 |
48
|
functionVariables.clear(); |
126 |
48
|
functionVariableCounters.clear(); |
127 |
|
} |
128 |
|
|
129 |
|
} |