Hi,

As I've been hacking away today, I've been swapping a load of "" + "" + "" style code over to use StringBuffers. I thought that perhaps there's a potential use of a static method in StringUtils to construct these strings from an array

StringUtils.messageAppender
 /**
    * Creates log messages using a StringBuffer
    * Example:
    * <code>
    * String[] args = {"1", "2", "3"}
    * log(StringUtils.messageAppender(args), Project.MSG_VERBOSE);
    * </code>
    * @param args the message fragments
    * @return the message
    * @since ant 1.7
    */
   public static String messageAppender(final Object[] args) {
       StringBuffer sb = new StringBuffer();
       for (int i = 0; i < args.length; i++) {
           sb.append(args[i]);
       }
       return sb.toString();
   }

In use Delete.java

if (dirCount > 0) {
String[] args = {"Deleted ", ""+dirCount, " director", (dirCount == 1 ? "y" : "ies"), " from ", d.getAbsolutePath()}; log(StringUtils.messageAppender(args), quiet ? Project.MSG_VERBOSE : verbosity);
}

Before I go ahead and commit any of this, what do people think (thumbs up/down on the idea of doing something about the string concatenation in logging, thumbs up/down to this static methof of StringUtils)?

Thanks
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to