Package: ValueObserver

ValueObserver

nameinstructionbranchcomplexitylinemethod
ValueObserver(String[], Value, ValueValidationExpression)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
changedValue(ILexLocation, Value, Context)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getValue()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /***************************************************************************
2: *
3: *        Copyright (c) 2009 IHA
4: *
5: *        Author: Kenneth Lausdahl and Augusto Ribeiro
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: **************************************************************************/
23:
24: package org.overture.interpreter.runtime.validation;
25:
26: import org.overture.ast.intf.lex.ILexLocation;
27: import org.overture.interpreter.runtime.Context;
28: import org.overture.interpreter.runtime.ValueException;
29: import org.overture.interpreter.values.Value;
30: import org.overture.interpreter.values.ValueListener;
31:
32: public class ValueObserver implements ValueListener
33: {
34:
35:         public String[] name;
36:         public Value v;
37:         private ValueValidationExpression expr;
38:
39:         public ValueObserver(String[] name, Value v, ValueValidationExpression expr)
40:         {
41:                 this.name = name;
42:                 this.v = v;
43:                 this.expr = expr;
44:         }
45:
46:         public void changedValue(ILexLocation location, Value value, Context ctxt)
47:         {
48:                 // System.out.println("Value " + printValueName() + " has changed to " + value.toString());
49:                 this.expr.valueChanged(this);
50:         }
51:
52:         // private String printValueName()
53:         // {
54:         // if(name.length == 2)
55:         // {
56:         // return name[0] + "`" + name[1];
57:         // }
58:         // else
59:         // {
60:         // return name[0] + "`" + name[1] + "." + name[2];
61:         // }
62:         // }
63:
64:         public double getValue()
65:         {
66:                 try
67:                 {
68:                         return v.realValue(null);
69:                 } catch (ValueException e)
70:                 {
71:                         // TODO Auto-generated catch block
72:                         e.printStackTrace();
73:                 }
74:                 return 0;
75:         }
76:
77: }