Index: framework/src/test/org/apache/hivemind/util/TestStringUtils.java =================================================================== --- framework/src/test/org/apache/hivemind/util/TestStringUtils.java (revisión: 387550) +++ framework/src/test/org/apache/hivemind/util/TestStringUtils.java (copia de trabajo) @@ -89,4 +89,66 @@ { assertEquals(null, StringUtils.join(new String[0], ',')); } + + public void testEscapedSplit() + { + assertListsEqual( + new String[] { "alpha", "beta" }, + StringUtils.escapedSplit("alpha,beta", ',')); + } + + public void testEscapedSplitEscapes() + { + assertListsEqual( + new String[] { "alpha,beta", "gamma" }, + StringUtils.escapedSplit("alpha\\,beta,gamma", ',')); + } + + public void testEscapedSplitEscapesNoDelim() + { + assertListsEqual( + new String[] { "alpha\\", "beta", "gamma" }, + StringUtils.escapedSplit("alpha\\\\,beta,gamma", ',')); + } + + public void testEscapedSplitSingle() + { + assertListsEqual( + new String[] { "alpha" }, + StringUtils.escapedSplit("alpha", ',')); + } + + public void testEscapedSplitSingleEscapes() + { + // Trailing single "\" is ignored. + assertListsEqual( + new String[] { "alpha" }, + StringUtils.escapedSplit("alpha\\", ',')); + } + + public void testEscapedSplitSingleEscapesDouble() + { + // Trailing double "\" is included. + assertListsEqual( + new String[] { "alpha\\" }, + StringUtils.escapedSplit("alpha\\\\", ',')); + } + + public void testEscapedSplitNull() + { + assertListsEqual(new String[0], StringUtils.escapedSplit(null, ',')); + } + + public void testEscapedSplitEmpty() + { + assertListsEqual(new String[0], StringUtils.escapedSplit("", ',')); + } + + public void testEscapedSplitTrailingComma() + { + assertListsEqual( + new String[] { "fred", "barney", "wilma" }, + StringUtils.escapedSplit("fred,barney,wilma,", ',')); + } + } \ No newline at end of file Index: framework/src/java/org/apache/hivemind/util/ClassAdaptor.java =================================================================== --- framework/src/java/org/apache/hivemind/util/ClassAdaptor.java (revisión: 387550) +++ framework/src/java/org/apache/hivemind/util/ClassAdaptor.java (copia de trabajo) @@ -20,14 +20,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.StringTokenizer; import org.apache.hivemind.ApplicationRuntimeException; /** * Provides access to an object (of a particular class) as a set of individual property that may be * read or updated. - * + * * @author Howard Lewis Ship */ class ClassAdaptor @@ -49,7 +48,7 @@ /** * Updates the property of the target object. - * + * * @param target * the object to update * @param value @@ -65,7 +64,7 @@ /** * An improved version of {@link #write(Object, String, Object)} that can convert a string value * to an appropriate property type value. - * + * * @since 1.1 */ @@ -78,7 +77,7 @@ /** * Reads the property of the target object. - * + * * @param target * the object to read * @param propertyName @@ -93,7 +92,7 @@ /** * Returns the type of the named property. - * + * * @param target * the object to examine * @param propertyName @@ -182,17 +181,16 @@ /** * Does the grunt work for * {@link org.apache.hivemind.util.PropertyUtils#configureProperties(Object, String)}. - * + * * @since 1.1 */ public void configureProperties(Object target, String initializer) { - StringTokenizer tokenizer = new StringTokenizer(initializer, ","); - - while (tokenizer.hasMoreTokens()) - { - configurePropertyFromToken(target, tokenizer.nextToken()); + String [] tokens = StringUtils.escapedSplit(initializer, ','); + for(int i = 0; i < tokens.length; i++) { + String token = tokens[i]; + configurePropertyFromToken(target, token); } } @@ -204,7 +202,7 @@ *