Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart8.png 62% of files have more coverage
16   111   10   2
4   42   0.62   8
8     1.25  
1    
 
  SubjectVariableAllocation       Line # 26 16 10 78.6% 0.78571427
 
  (5)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.logic.model;
17   
18    import org.qedeq.base.utility.Enumerator;
19    import org.qedeq.kernel.bo.logic.common.SubjectVariable;
20   
21    /**
22    * One subject variable allocation for our model.
23    *
24    * @author Michael Meyling
25    */
 
26    public class SubjectVariableAllocation {
27   
28    /** This subject variable. */
29    private final SubjectVariable variable;
30   
31    /** Reference to current interpretation entity. */
32    private final Enumerator value;
33   
34    /** Is this a fixed interpretatin? */
35    private boolean fixed;
36   
37    /**
38    * Constructor.
39    *
40    * @param variable Subject variable.
41    */
 
42  177337 toggle public SubjectVariableAllocation(final SubjectVariable variable) {
43  177337 this.variable = variable;
44  177337 this.value = new Enumerator();
45  177337 this.fixed = false;
46    }
47   
48    /**
49    * Constructor.
50    *
51    * @param variable Subject variable.
52    * @param value Value for subject variable.
53    */
 
54  29757 toggle public SubjectVariableAllocation(final SubjectVariable variable, final int value) {
55  29757 this.variable = variable;
56  29757 this.value = new Enumerator(value);
57  29757 this.fixed = true;
58    }
59   
60    /**
61    * Get subject variable.
62    *
63    * @return Subject variable.
64    */
 
65  1288559 toggle public SubjectVariable getVariable() {
66  1288559 return variable;
67    }
68   
69    /**
70    * Is this a fixed interpretation?
71    *
72    * @return Is this a fixed interpretation?
73    */
 
74  206672 toggle public boolean isFixed() {
75  206672 return fixed;
76    }
77   
78    /**
79    * Get reference to current model entity.
80    *
81    * @return Entity number.
82    */
 
83  619724 toggle public int getValue() {
84  619724 return value.getNumber();
85    }
86   
87    /**
88    * Increase model entity number.
89    */
 
90  288461 toggle public void increaseNumber() {
91  288461 if (fixed) {
92  0 throw new IllegalStateException("variable could not iterate: " + toString());
93    }
94  288461 value.increaseNumber();
95    }
96   
97    /**
98    * Reset model entity number.
99    */
 
100  1052 toggle public void resetNumber() {
101  1052 if (fixed) {
102  0 throw new IllegalStateException("variable could not iterate: " + toString());
103    }
104  1052 value.reset();
105    }
106   
 
107  0 toggle public String toString() {
108  0 return variable.toString() + "=" + value.getNumber();
109    }
110   
111    }