diff --git a/src/fr/devinsy/util/strings/StringList.java b/src/fr/devinsy/util/strings/StringList.java index 726b538..945c2e2 100755 --- a/src/fr/devinsy/util/strings/StringList.java +++ b/src/fr/devinsy/util/strings/StringList.java @@ -757,6 +757,40 @@ public class StringList extends ArrayList implements CharSequence return (result); } + /** + * + * @param prefix + * @param separator + * @param postifx + * @return + */ + public String toString(final String prefix, final String separator, final String postfix) + { + String result; + + StringList buffer = new StringList(1 + size() * 2 + 1); + + buffer.append(prefix); + + for (String string : this) + { + buffer.append(string); + buffer.append(separator); + } + + if (separator != null) + { + buffer.removeLast(); + } + + buffer.append(postfix); + + result = buffer.toString(); + + // + return result; + } + /** * Returns an array containing all of the strings in this list in proper * sequence (from first to last element). @@ -791,8 +825,8 @@ public class StringList extends ArrayList implements CharSequence { String result; - // - StringList buffer = new StringList(this.length() * 2); + StringList buffer = new StringList(this.size() * 2); + for (String string : this) { buffer.append(string); diff --git a/src/fr/devinsy/util/strings/StringListUtils.java b/src/fr/devinsy/util/strings/StringListUtils.java index ab2402b..253af81 100644 --- a/src/fr/devinsy/util/strings/StringListUtils.java +++ b/src/fr/devinsy/util/strings/StringListUtils.java @@ -26,6 +26,30 @@ package fr.devinsy.util.strings; */ public class StringListUtils { + /** + * + * @param prefix + * @param separator + * @param postfix + * @return + */ + public String toString(final StringList source, final String prefix, final String separator, final String postfix) + { + String result; + + if (source == null) + { + result = prefix + postfix; + } + else + { + result = source.toString(prefix, separator, postfix); + } + + // + return result; + } + /** * Builds a string list concatenating several time one string. *