| 1 | // Copyright © 2004-2006 University of Helsinki, Department of Computer Science | |
| 2 | // Copyright © 2012 various contributors | |
| 3 | // This software is released under GNU Lesser General Public License 2.1. | |
| 4 | // The license text is at http://www.gnu.org/licenses/lgpl-2.1.html | |
| 5 | ||
| 6 | package fi.helsinki.cs.titokone.devices; | |
| 7 | ||
| 8 | import java.util.Collections; | |
| 9 | import java.util.HashMap; | |
| 10 | import java.util.Map; | |
| 11 | ||
| 12 | public class DeviceNames { | |
| 13 | public static final Map<String, Integer> DEVICES; | |
| 14 | ||
| 15 | static { | |
| 16 | 1 | Map<String, Integer> devs = new HashMap<String, Integer>(); |
| 17 | 4 | devs.put("crt", 0); |
| 18 | 4 | devs.put("kbd", 1); |
| 19 | 4 | devs.put("stdin", 6); |
| 20 | 4 | devs.put("stdout", 7); |
| 21 | // TODO: add rest of the device names here. | |
| 22 | // or perhaps have a name for each of the device objects, and automatically assign these values | |
| 23 | 1 | DEVICES = Collections.unmodifiableMap(devs); |
| 24 | } | |
| 25 | ||
| 26 | public static Integer lookupIgnoringCase(String name) { | |
| 27 | 3 | return DEVICES.get(name.toLowerCase()); |
| 28 | } | |
| 29 | ||
| 30 | public static String lookupByValue(int value) { | |
| 31 | 5 | for(Map.Entry<String, Integer> entries : DEVICES.entrySet()) |
| 32 | 3 | if(entries.getValue() == value) |
| 33 | 2 | return entries.getKey(); |
| 34 | 1 | return null; |
| 35 | } | |
| 36 | } | |
Mutations | ||
| 16 |
removed call to java/util/HashMap::<init> : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 17 |
Substituted 0 with 1 : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/lang/Integer::valueOf : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) Substituted 0 with 1 : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/util/Map::put : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 18 |
removed call to java/util/Map::put : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) Substituted 1 with 0 : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/lang/Integer::valueOf : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) Substituted 1 with 0 : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 19 |
Replaced constant value of 6 with 7 : SURVIVED removed call to java/util/Map::put : SURVIVED Substituted 6 with 7 : SURVIVED removed call to java/lang/Integer::valueOf : SURVIVED |
|
| 20 |
Replaced constant value of 7 with 8 : SURVIVED Substituted 7 with 8 : SURVIVED removed call to java/lang/Integer::valueOf : SURVIVED removed call to java/util/Map::put : SURVIVED |
|
| 23 |
removed call to java/util/Collections::unmodifiableMap : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 27 |
removed call to java/util/Map::get : NO_COVERAGE mutated return of Object value for fi/helsinki/cs/titokone/devices/DeviceNames::lookupIgnoringCase to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE removed call to java/lang/String::toLowerCase : NO_COVERAGE |
|
| 31 |
removed call to java/util/Map::entrySet : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/util/Iterator::next : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/util/Set::iterator : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/util/Iterator::hasNext : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) negated conditional : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 32 |
removed call to java/util/Map$Entry::getValue : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) removed call to java/lang/Integer::intValue : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) negated conditional : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 33 |
removed call to java/util/Map$Entry::getKey : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) mutated return of Object value for fi/helsinki/cs/titokone/devices/DeviceNames::lookupByValue to ( if (x != null) null else throw new RuntimeException ) : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest) |
|
| 34 |
mutated return of Object value for fi/helsinki/cs/titokone/devices/DeviceNames::lookupByValue to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE |