@Test public void testGetConfigAsInt() throws Exception { final Hashtable<String, String> h = new Hashtable<>(); h.put("a", ""); h.put("b", "2"); h.put("c", "d"); try { OsgiUtil.getCfgAsInt(h, "a"); Assert.fail(); } catch (org.osgi.service.cm.ConfigurationException e) { Assert.assertNotNull(e); } assertEquals(2, OsgiUtil.getCfgAsInt(h, "b")); try { OsgiUtil.getCfgAsInt(h, "c"); Assert.fail(); } catch (org.osgi.service.cm.ConfigurationException e) { Assert.assertNotNull(e); } }
public static int getCfgAsInt(Dictionary d, String key) throws ConfigurationException { try { return Integer.parseInt(getCfg(d, key)); } catch (NumberFormatException e) { throw new ConfigurationException(key, "not an integer"); } }
OsgiUtil { public static int getCfgAsInt(Dictionary d, String key) throws ConfigurationException { try { return Integer.parseInt(getCfg(d, key)); } catch (NumberFormatException e) { throw new ConfigurationException(key, "not an integer"); } } }
OsgiUtil { public static int getCfgAsInt(Dictionary d, String key) throws ConfigurationException { try { return Integer.parseInt(getCfg(d, key)); } catch (NumberFormatException e) { throw new ConfigurationException(key, "not an integer"); } } private  OsgiUtil(); }
OsgiUtil { public static int getCfgAsInt(Dictionary d, String key) throws ConfigurationException { try { return Integer.parseInt(getCfg(d, key)); } catch (NumberFormatException e) { throw new ConfigurationException(key, "not an integer"); } } private  OsgiUtil(); static String getContextProperty(ComponentContext cc, String key); static Option<String> getOptContextProperty(ComponentContext cc, String key); static String getComponentContextProperty(ComponentContext cc, String key); static String getComponentContextProperty(ComponentContext cc, String key, String defaultValue); static String getCfg(Dictionary d, String key); static Option<String> getOptCfg(Dictionary d, String key); static Option<Integer> getOptCfgAsInt(Dictionary d, String key); static Map<String, String> filterByPrefix(Dictionary d, String prefix); static Option<Boolean> getOptCfgAsBoolean(Dictionary d, String key); static int getCfgAsInt(Dictionary d, String key); static ServiceRegistration<?> registerServlet(BundleContext bundleContext, Object service, String alias); }
OsgiUtil { public static int getCfgAsInt(Dictionary d, String key) throws ConfigurationException { try { return Integer.parseInt(getCfg(d, key)); } catch (NumberFormatException e) { throw new ConfigurationException(key, "not an integer"); } } private  OsgiUtil(); static String getContextProperty(ComponentContext cc, String key); static Option<String> getOptContextProperty(ComponentContext cc, String key); static String getComponentContextProperty(ComponentContext cc, String key); static String getComponentContextProperty(ComponentContext cc, String key, String defaultValue); static String getCfg(Dictionary d, String key); static Option<String> getOptCfg(Dictionary d, String key); static Option<Integer> getOptCfgAsInt(Dictionary d, String key); static Map<String, String> filterByPrefix(Dictionary d, String prefix); static Option<Boolean> getOptCfgAsBoolean(Dictionary d, String key); static int getCfgAsInt(Dictionary d, String key); static ServiceRegistration<?> registerServlet(BundleContext bundleContext, Object service, String alias);  }