@Test public void testFromBundle_InvalidBundle() { BundleName bundle = BundleName.MODS_IDENTIFIER_TYPES; JsonValueMap result = JsonValueMap.fromBundle(bundle, Locale.ENGLISH); assertNotNull(result); assertEquals(bundle.getValueMapId(), result.getMapId()); assertTrue(result.getValues().isEmpty()); }
public static JsonValueMap fromBundle(BundleName bundle, Locale locale) { JsonValueMap jvm = new JsonValueMap(); jvm.setMapId(bundle.getValueMapId()); URL resource = findResource(bundle.toString(), CONTROL, locale); if (resource == null) { return jvm; } ObjectMapper om = JsonUtils.defaultObjectMapper(); try { TypeFactory typeFactory = om.getTypeFactory(); MapType jsonType = typeFactory.constructMapType(Map.class, String.class, Object.class); Map<String, Object> jsonMap = om.readValue(resource, jsonType); if (LOG.isLoggable(Level.FINE)) { LOG.fine(String.valueOf(jsonMap)); } Object data = jsonMap.get("data"); jvm.setValues((List<Map<String, Object>>) data); } catch (Exception ex) { LOG.log(Level.WARNING, "Cannot read resource " + resource, ex); } return jvm; }
JsonValueMap extends ValueMap<Map<String, Object>> { public static JsonValueMap fromBundle(BundleName bundle, Locale locale) { JsonValueMap jvm = new JsonValueMap(); jvm.setMapId(bundle.getValueMapId()); URL resource = findResource(bundle.toString(), CONTROL, locale); if (resource == null) { return jvm; } ObjectMapper om = JsonUtils.defaultObjectMapper(); try { TypeFactory typeFactory = om.getTypeFactory(); MapType jsonType = typeFactory.constructMapType(Map.class, String.class, Object.class); Map<String, Object> jsonMap = om.readValue(resource, jsonType); if (LOG.isLoggable(Level.FINE)) { LOG.fine(String.valueOf(jsonMap)); } Object data = jsonMap.get("data"); jvm.setValues((List<Map<String, Object>>) data); } catch (Exception ex) { LOG.log(Level.WARNING, "Cannot read resource " + resource, ex); } return jvm; } }
JsonValueMap extends ValueMap<Map<String, Object>> { public static JsonValueMap fromBundle(BundleName bundle, Locale locale) { JsonValueMap jvm = new JsonValueMap(); jvm.setMapId(bundle.getValueMapId()); URL resource = findResource(bundle.toString(), CONTROL, locale); if (resource == null) { return jvm; } ObjectMapper om = JsonUtils.defaultObjectMapper(); try { TypeFactory typeFactory = om.getTypeFactory(); MapType jsonType = typeFactory.constructMapType(Map.class, String.class, Object.class); Map<String, Object> jsonMap = om.readValue(resource, jsonType); if (LOG.isLoggable(Level.FINE)) { LOG.fine(String.valueOf(jsonMap)); } Object data = jsonMap.get("data"); jvm.setValues((List<Map<String, Object>>) data); } catch (Exception ex) { LOG.log(Level.WARNING, "Cannot read resource " + resource, ex); } return jvm; }  }
JsonValueMap extends ValueMap<Map<String, Object>> { public static JsonValueMap fromBundle(BundleName bundle, Locale locale) { JsonValueMap jvm = new JsonValueMap(); jvm.setMapId(bundle.getValueMapId()); URL resource = findResource(bundle.toString(), CONTROL, locale); if (resource == null) { return jvm; } ObjectMapper om = JsonUtils.defaultObjectMapper(); try { TypeFactory typeFactory = om.getTypeFactory(); MapType jsonType = typeFactory.constructMapType(Map.class, String.class, Object.class); Map<String, Object> jsonMap = om.readValue(resource, jsonType); if (LOG.isLoggable(Level.FINE)) { LOG.fine(String.valueOf(jsonMap)); } Object data = jsonMap.get("data"); jvm.setValues((List<Map<String, Object>>) data); } catch (Exception ex) { LOG.log(Level.WARNING, "Cannot read resource " + resource, ex); } return jvm; }  static JsonValueMap fromBundle(BundleName bundle, Locale locale); }
JsonValueMap extends ValueMap<Map<String, Object>> { public static JsonValueMap fromBundle(BundleName bundle, Locale locale) { JsonValueMap jvm = new JsonValueMap(); jvm.setMapId(bundle.getValueMapId()); URL resource = findResource(bundle.toString(), CONTROL, locale); if (resource == null) { return jvm; } ObjectMapper om = JsonUtils.defaultObjectMapper(); try { TypeFactory typeFactory = om.getTypeFactory(); MapType jsonType = typeFactory.constructMapType(Map.class, String.class, Object.class); Map<String, Object> jsonMap = om.readValue(resource, jsonType); if (LOG.isLoggable(Level.FINE)) { LOG.fine(String.valueOf(jsonMap)); } Object data = jsonMap.get("data"); jvm.setValues((List<Map<String, Object>>) data); } catch (Exception ex) { LOG.log(Level.WARNING, "Cannot read resource " + resource, ex); } return jvm; }  static JsonValueMap fromBundle(BundleName bundle, Locale locale);  }