Package: LexRealToken

LexRealToken

nameinstructionbranchcomplexitylinemethod
LexRealToken(String, ILexLocation)
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%
LexRealToken(double, ILexLocation)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
apply(IAnalysis)
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%
apply(IAnswer)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
apply(IQuestion, Object)
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%
apply(IQuestionAnswer, Object)
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%
clone()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getChildren(Boolean)
M: 21 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getValue()
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%
toString()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
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.ast.lex;
25:
26: import java.util.HashMap;
27: import java.util.Map;
28:
29: import org.overture.ast.analysis.AnalysisException;
30: import org.overture.ast.analysis.intf.IAnalysis;
31: import org.overture.ast.analysis.intf.IAnswer;
32: import org.overture.ast.analysis.intf.IQuestion;
33: import org.overture.ast.analysis.intf.IQuestionAnswer;
34: import org.overture.ast.intf.lex.ILexLocation;
35: import org.overture.ast.intf.lex.ILexRealToken;
36:
37: public class LexRealToken extends LexToken implements ILexRealToken
38: {
39:         private static final long serialVersionUID = 1L;
40:         public final double value;
41:
42:         public LexRealToken(String real, ILexLocation location)
43:         {
44:                 super(location, VDMToken.REALNUMBER);
45:                 value = Double.parseDouble(real);
46:         }
47:
48:         public LexRealToken(double value, ILexLocation location)
49:         {
50:                 super(location, VDMToken.REALNUMBER);
51:                 this.value = value;
52:         }
53:
54:         @Override
55:         public double getValue()
56:         {
57:                 return value;
58:         }
59:
60:         @Override
61:         public String toString()
62:         {
63:                 return Double.toString(value);
64:         }
65:
66:         @Override
67:         public ILexRealToken clone()
68:         {
69:                 return new LexRealToken(value, location);
70:         }
71:
72:         @Override
73:         public void apply(IAnalysis analysis) throws AnalysisException
74:         {
75:                 analysis.caseILexRealToken(this);
76:         }
77:
78:         @Override
79:         public <A> A apply(IAnswer<A> caller) throws AnalysisException
80:         {
81:                 return caller.caseILexRealToken(this);
82:         }
83:
84:         @Override
85:         public <Q> void apply(IQuestion<Q> caller, Q question)
86:                         throws AnalysisException
87:         {
88:                 caller.caseILexRealToken(this, question);
89:         }
90:
91:         @Override
92:         public <Q, A> A apply(IQuestionAnswer<Q, A> caller, Q question)
93:                         throws AnalysisException
94:         {
95:                 return caller.caseILexRealToken(this, question);
96:         }
97:
98:         /**
99:          * Creates a map of all field names and their value
100:          *
101:          * @param includeInheritedFields
102:          * if true all inherited fields are included
103:          * @return a a map of names to values of all fields
104:          */
105:         @Override
106:         public Map<String, Object> getChildren(Boolean includeInheritedFields)
107:         {
108:                 Map<String, Object> fields = new HashMap<String, Object>();
109:•                if (includeInheritedFields)
110:                 {
111:                         fields.putAll(super.getChildren(includeInheritedFields));
112:                 }
113:                 fields.put("value", this.value);
114:                 return fields;
115:         }
116: }