Ejemplo n.º 1
0
 private static void addMapping(
     Map<Integer, String> nameMap, Map<String, Integer> idMap, long id, String name) {
   if ((id >>> 32) != 0) {
     throw new AssertionError("Id has high bits set: " + id + ", " + name);
   }
   Integer intId = Integer.valueOf((int) id);
   if (nameMap.put(intId, name) != null) {
     throw new AssertionError("Duplicate id: " + id + ", " + name);
   }
   if (idMap.put(name, intId) != null) {
     throw new AssertionError("Duplicate name: " + id + ", " + name);
   }
 }
Ejemplo n.º 2
0
 static Config getConfig(final String name, final InputStream stream) {
   Config config = configMap.get(name);
   if (config != null) {
     return config;
   }
   try {
     config = new Config(name, stream);
     configMap.put(name, config);
     return config;
   } catch (Exception e) {
     throw new ProviderException("Error parsing configuration", e);
   }
 }
Ejemplo n.º 3
0
 public static long getId(Map<String, Integer> idMap, String name) {
   Integer mech = idMap.get(name);
   if (mech == null) {
     throw new IllegalArgumentException("Unknown name " + name);
   }
   return mech.intValue() & 0xffffffffL;
 }
Ejemplo n.º 4
0
 private static String getName(Map<Integer, String> nameMap, long id) {
   String name = null;
   if ((id >>> 32) == 0) {
     name = nameMap.get(Integer.valueOf((int) id));
   }
   if (name == null) {
     name = "Unknown 0x" + toFullHexString(id);
   }
   return name;
 }
Ejemplo n.º 5
0
 static Config removeConfig(String name) {
   return configMap.remove(name);
 }