@Test public void testAddProperty() { checkAddProperty("name=value", "name", "value"); checkAddProperty("name=", "name", ""); checkAddProperty("name", "name", ""); checkAddProperty(" name=value ", "name", "value"); checkAddProperty(" name = value ", "name", "value"); checkAddProperty("name = value", "name", "value"); checkAddProperty(" name= ", "name", ""); checkAddProperty(" name = ", "name", ""); checkAddProperty("name =", "name", ""); checkAddProperty("name", "name", ""); checkAddProperty(" name", "name", ""); checkAddProperty(" name ", "name", ""); failAddProperty("=", IllegalArgumentException.class); failAddProperty("=value", IllegalArgumentException.class); failAddProperty(null, IllegalArgumentException.class); failAddProperty("", IllegalArgumentException.class); }
public static void addProperty(final Hashtable env, String property) { if (property == null || property.length() == 0) { throw new IllegalArgumentException("No property specified."); } if (property.charAt(0) == '=') { throw new IllegalArgumentException("Invalid property has no name: " + property); } final String name; final String value; property = property.trim(); final int esp = property.indexOf('='); if (esp < 0) { name = property; value = ""; } else { name = property.substring(0, esp).trim(); if (property.length() > esp) { value = property.substring(esp + 1).trim(); } else { value = ""; } } env.put(name, value); }
Util { public static void addProperty(final Hashtable env, String property) { if (property == null || property.length() == 0) { throw new IllegalArgumentException("No property specified."); } if (property.charAt(0) == '=') { throw new IllegalArgumentException("Invalid property has no name: " + property); } final String name; final String value; property = property.trim(); final int esp = property.indexOf('='); if (esp < 0) { name = property; value = ""; } else { name = property.substring(0, esp).trim(); if (property.length() > esp) { value = property.substring(esp + 1).trim(); } else { value = ""; } } env.put(name, value); } }
Util { public static void addProperty(final Hashtable env, String property) { if (property == null || property.length() == 0) { throw new IllegalArgumentException("No property specified."); } if (property.charAt(0) == '=') { throw new IllegalArgumentException("Invalid property has no name: " + property); } final String name; final String value; property = property.trim(); final int esp = property.indexOf('='); if (esp < 0) { name = property; value = ""; } else { name = property.substring(0, esp).trim(); if (property.length() > esp) { value = property.substring(esp + 1).trim(); } else { value = ""; } } env.put(name, value); } private  Util(); }
Util { public static void addProperty(final Hashtable env, String property) { if (property == null || property.length() == 0) { throw new IllegalArgumentException("No property specified."); } if (property.charAt(0) == '=') { throw new IllegalArgumentException("Invalid property has no name: " + property); } final String name; final String value; property = property.trim(); final int esp = property.indexOf('='); if (esp < 0) { name = property; value = ""; } else { name = property.substring(0, esp).trim(); if (property.length() > esp) { value = property.substring(esp + 1).trim(); } else { value = ""; } } env.put(name, value); } private  Util(); static boolean isInstance(final Class type, final Object instance); static void addProperty(final Hashtable env, String property); static Method findSetter(final Class<?> testClazz, final Field field, final Object propertyValue); static Method getMostSpecificMethod(final Method method1, final Method method2); }
Util { public static void addProperty(final Hashtable env, String property) { if (property == null || property.length() == 0) { throw new IllegalArgumentException("No property specified."); } if (property.charAt(0) == '=') { throw new IllegalArgumentException("Invalid property has no name: " + property); } final String name; final String value; property = property.trim(); final int esp = property.indexOf('='); if (esp < 0) { name = property; value = ""; } else { name = property.substring(0, esp).trim(); if (property.length() > esp) { value = property.substring(esp + 1).trim(); } else { value = ""; } } env.put(name, value); } private  Util(); static boolean isInstance(final Class type, final Object instance); static void addProperty(final Hashtable env, String property); static Method findSetter(final Class<?> testClazz, final Field field, final Object propertyValue); static Method getMostSpecificMethod(final Method method1, final Method method2);  }