Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 16185 invoked from network); 19 Sep 2006 23:06:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Sep 2006 23:06:05 -0000 Received: (qmail 67178 invoked by uid 500); 19 Sep 2006 23:06:04 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 66792 invoked by uid 500); 19 Sep 2006 23:06:02 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 66781 invoked by uid 99); 19 Sep 2006 23:06:02 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2006 16:06:02 -0700 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= Received: from ([209.237.227.198:41988] helo=brutus.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id FF/3E-28275-9D770154 for ; Tue, 19 Sep 2006 16:06:01 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 29944410069 for ; Tue, 19 Sep 2006 23:02:25 +0000 (GMT) Message-ID: <12273132.1158706945167.JavaMail.jira@brutus> Date: Tue, 19 Sep 2006 16:02:25 -0700 (PDT) From: "Stepan Koltsov (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (LANG-266) Wish for StringUtils.join(Collection, *) In-Reply-To: <31869785.1151790569857.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/LANG-266?page=comments#action_12436050 ] Stepan Koltsov commented on LANG-266: ------------------------------------- Thank you for adding method. There are typos in the last commit: Index: src/java/org/apache/commons/lang/StringUtils.java =================================================================== --- src/java/org/apache/commons/lang/StringUtils.java (revision 448007) +++ src/java/org/apache/commons/lang/StringUtils.java (working copy) @@ -2692,7 +2692,7 @@ * * @param collection the Collection of values to join together, may be null * @param separator the separator character to use - * @return the joined String, null if null iterator input + * @return the joined String, null if null collection input * @since 2.3 */ public static String join(Collection collection, char separator) { @@ -2713,7 +2713,7 @@ * * @param collection the Collection of values to join together, may be null * @param separator the separator character to use, null treated as "" - * @return the joined String, null if null iterator input + * @return the joined String, null if null collection input * @since 2.3 */ public static String join(Collection collection, String separator) { > Wish for StringUtils.join(Collection, *) > ---------------------------------------- > > Key: LANG-266 > URL: http://issues.apache.org/jira/browse/LANG-266 > Project: Commons Lang > Issue Type: Wish > Affects Versions: Nightly Builds > Reporter: Stepan Koltsov > Priority: Trivial > Fix For: 2.3 > > Attachments: commons-lang-join-collection-stepancheg.diff > > > There is a lack of StringUtils.join(Collection, String) method in commons-lang. Could you please add it? > Commons-lang has method join(Iterator, String), however join(Collection, String) is still useful. Join is used very often, and in most situations it is used with Collection, not with Iterator, because almost all methods return Collections, not Iterators and a lot of data is stored as Collections, not as Iterators. The string ".iterator()" has 11 characters while line for code is only 72 chars. I've found that in my code there are several methods that could be one line shorter if it was StringUtils.join(Collection, String). Compare: > // with StringUtils.join(Collection, String) > return "UNIQUE (" + StringUtils.join(unique.getColumnNames(), ", ") + ")"; > against: > // without > Iterator columnNames = unique.getColumnNames().iterator(); > return "UNIQUE (" + StringUtils.join(columnNames, ", ") + ")"; > Motivation is almost same as "Why we have StringUtils.join(Object[], String) while we could write StringUtils.join(Arrays.asList(array).iterator(), separator)?" -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org