[utilities COMMIT] in /java-support/trunk/src: main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormat...

noreply at shibboleth.net noreply at shibboleth.net
Sun Jan 8 13:32:11 GMT 2012


Author: rdw
Date: Sun Jan  8 13:32:10 2012
New Revision: 196

URL: http://svn.shibboleth.net/view/utilities?rev=196&view=rev
Log:
Tests for LazilyFormattedString and StringSupport.
Clarify javadoc for LazilyFormattedString.
Fix StringSupport#stringToList for the case when it ends with the delimiter (this makes it reflexive with StringSupport#listToString)

Added:
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedStringTest.java   (with props)
    java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/primitive/StringSupportTest.java   (with props)
Modified:
    java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedString.java
    java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java

Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedString.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedString.java?rev=196&r1=195&r2=196&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedString.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/LazilyFormattedString.java Sun Jan  8 13:32:10 2012
@@ -25,7 +25,7 @@
 /**
  * An object that represents a string containing a {@link java.util.Formatter} string and a set of values. When
  * {@link #toString()} is called the format string is filled in with the given values. This allows for lazy evaluation
- * of the value objects which may be expensive.
+ * of the value objects formatting function which may be expensive.
  */
 public class LazilyFormattedString {
 

Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java?rev=196&r1=195&r2=196&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java Sun Jan  8 13:32:10 2012
@@ -60,13 +60,14 @@
     }
 
     /**
-     * Converts a delimited string into a list.
+     * Converts a delimited string into a list.  We cannot user an ungarnished tokenizer since it doesn't add a empty
+     * String if end of the input String was the delimiter.  Hence we have to explicitly check.
      * 
      * @param string the string to be split into a list
      * @param delimiter the delimiter between values. This string may contain multiple delimiter characters, as allowed
      *            by {@link StringTokenizer}
      * 
-     * @return the list of values or an empty list if the given string is null or empty
+     * @return the list of values or an empty list if the given string is empty
      */
     @Nonnull public static List<String> stringToList(@Nonnull final String string, @Nonnull final String delimiter) {
         Assert.isNull(string, "String data can not be null");
@@ -79,6 +80,9 @@
             final StringTokenizer tokens = new StringTokenizer(trimmedString, delimiter);
             while (tokens.hasMoreTokens()) {
                 values.add(tokens.nextToken());
+            }
+            if (string.endsWith(delimiter)) {
+                values.add("");
             }
         }
 



More information about the commits mailing list