Package: LexNameTokenMap

LexNameTokenMap

nameinstructionbranchcomplexitylinemethod
LexNameTokenMap()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
clear()
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%
containsKey(Object)
M: 14 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
containsValue(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%
entrySet()
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
get(Object)
M: 5 C: 12
71%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
isEmpty()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
keySet()
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
put(ILexNameToken, Object)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
putAll(Map)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
remove(Object)
M: 2 C: 12
86%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
size()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
toString()
M: 27 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
values()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.typechecker.util;
23:
24: import java.io.Serializable;
25: import java.util.Collection;
26: import java.util.HashMap;
27: import java.util.HashSet;
28: import java.util.Iterator;
29: import java.util.Map;
30: import java.util.Set;
31:
32: import org.overture.ast.intf.lex.ILexNameToken;
33:
34: public class LexNameTokenMap<V> implements Map<ILexNameToken, V>, Serializable
35: {
36:
37:         /**
38:          *
39:          */
40:         private static final long serialVersionUID = -1122692848887584905L;
41:
42:         private final HashMap<LexNameTokenWrapper, V> map = new HashMap<LexNameTokenWrapper, V>();
43:
44:         public V put(ILexNameToken key, V value)
45:         {
46:                 return map.put(new LexNameTokenWrapper(key), value);
47:         };
48:
49:         public V get(Object key)
50:         {
51:•                if (key instanceof ILexNameToken)
52:                 {
53:                         return map.get(new LexNameTokenWrapper((ILexNameToken) key));
54:                 }
55:                 return map.get(key);
56:         }
57:
58:         public Set<Entry<ILexNameToken, V>> entrySet()
59:         {
60:                 Set<Entry<ILexNameToken, V>> result = new HashSet<Entry<ILexNameToken, V>>();
61:
62:•                for (Entry<LexNameTokenWrapper, V> lexNameTokenEntry : map.entrySet())
63:                 {
64:                         result.add(new LexNameTokenEntry<V>(lexNameTokenEntry));
65:                 }
66:
67:                 return result;
68:         }
69:
70:         public int size()
71:         {
72:                 return this.map.size();
73:         }
74:
75:         public boolean isEmpty()
76:         {
77:                 return this.map.isEmpty();
78:         }
79:
80:         public boolean containsKey(Object key)
81:         {
82:•                if (key instanceof ILexNameToken)
83:                 {
84:                         return this.map.containsKey(new LexNameTokenWrapper((ILexNameToken) key));
85:                 }
86:                 return false;
87:         }
88:
89:         public boolean containsValue(Object value)
90:         {
91:                 return this.map.containsValue(value);
92:         }
93:
94:         public V remove(Object key)
95:         {
96:•                if (key instanceof ILexNameToken)
97:                 {
98:                         return this.map.remove(new LexNameTokenWrapper((ILexNameToken) key));
99:                 }
100:                 return null;
101:         }
102:
103:         public void putAll(Map<? extends ILexNameToken, ? extends V> m)
104:         {
105:•                for (Entry<? extends ILexNameToken, ? extends V> item : m.entrySet())
106:                 {
107:                         put(item.getKey(), item.getValue());
108:                 }
109:
110:         }
111:
112:         public void clear()
113:         {
114:                 this.map.clear();
115:         }
116:
117:         public Set<ILexNameToken> keySet()
118:         {
119:                 Set<ILexNameToken> result = new HashSet<ILexNameToken>();
120:
121:•                for (LexNameTokenWrapper item : this.map.keySet())
122:                 {
123:                         result.add(item.token);
124:                 }
125:
126:                 return result;
127:         }
128:
129:         public Collection<V> values()
130:         {
131:                 return this.map.values();
132:         }
133:
134:         @Override
135:         public String toString()
136:         {
137:                 StringBuffer sb = new StringBuffer();
138:•                for (Iterator<Entry<ILexNameToken, V>> iterator = entrySet().iterator(); iterator.hasNext();)
139:                 {
140:                         sb.append(iterator.next());
141:•                        if (iterator.hasNext())
142:                         {
143:                                 sb.append("\n");
144:                         }
145:
146:                 }
147:                 return sb.toString();
148:         }
149: }