@Test public void testParseBoolean() { System.out.println("parseBoolean"); boolean expResult; boolean result; Properties props = new Properties(); props.put("value1", "true"); props.put("value2", "false"); props.put("empty", ""); props.put("str", "abc"); props.put("boolean", "true"); props.put("float", "24.98"); props.put("int", "12"); props.put("char", "a"); PropertyParser instance = new PropertyParser(props); expResult = true; result = instance.parseBoolean("value1"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("value2"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("empty"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("str"); assertEquals(expResult, result); expResult = true; result = instance.parseBoolean("boolean"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("float"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("int"); assertEquals(expResult, result); expResult = false; result = instance.parseBoolean("char"); assertEquals(expResult, result); try { expResult = false; result = instance.parseBoolean("nonexistent"); fail("no exception"); assertEquals(expResult, result); } catch (IllegalArgumentException e) { } }
public boolean parseBoolean(String name) { String property = getProperties().getProperty(name); if (property == null) { throw new IllegalArgumentException(); } return Boolean.parseBoolean(property); }
PropertyParser { public boolean parseBoolean(String name) { String property = getProperties().getProperty(name); if (property == null) { throw new IllegalArgumentException(); } return Boolean.parseBoolean(property); } }
PropertyParser { public boolean parseBoolean(String name) { String property = getProperties().getProperty(name); if (property == null) { throw new IllegalArgumentException(); } return Boolean.parseBoolean(property); } PropertyParser(Properties properties); }
PropertyParser { public boolean parseBoolean(String name) { String property = getProperties().getProperty(name); if (property == null) { throw new IllegalArgumentException(); } return Boolean.parseBoolean(property); } PropertyParser(Properties properties); Properties getProperties(); void setProperties(Properties properties); String parseString(String name); int parseInt(String name); boolean parseBoolean(String name); float parseFloat(String name); double parseDouble(String name); long parseLong(String name); char parseChar(String name); String toString(String name); int toInt(String name); boolean toBoolean(String name); float toFloat(String name); double toDouble(String name); long toLong(String name); char toChar(String name); String toString(String name, String defaultValue); int toInt(String name, int defaultValue); boolean toBoolean(String name, boolean defaultValue); float toFloat(String name, float defaultValue); double toDouble(String name, double defaultValue); long toLong(String name, long defaultValue); char toChar(String name, char defaultValue); }
PropertyParser { public boolean parseBoolean(String name) { String property = getProperties().getProperty(name); if (property == null) { throw new IllegalArgumentException(); } return Boolean.parseBoolean(property); } PropertyParser(Properties properties); Properties getProperties(); void setProperties(Properties properties); String parseString(String name); int parseInt(String name); boolean parseBoolean(String name); float parseFloat(String name); double parseDouble(String name); long parseLong(String name); char parseChar(String name); String toString(String name); int toInt(String name); boolean toBoolean(String name); float toFloat(String name); double toDouble(String name); long toLong(String name); char toChar(String name); String toString(String name, String defaultValue); int toInt(String name, int defaultValue); boolean toBoolean(String name, boolean defaultValue); float toFloat(String name, float defaultValue); double toDouble(String name, double defaultValue); long toLong(String name, long defaultValue); char toChar(String name, char defaultValue);  }