ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Adding a methof to StringUtils
Date Wed, 19 Apr 2006 09:57:03 GMT
>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


For a significant performance boost we had to refactor the whole (or a
major part) of the codebase in this manner. So I think a performance
test would be good. How much is the improvement on <delete>?



>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();
>    }


This does not create a log message - it just concatenates the given
arguments.
Would be something like toString(Object[]) better?

You specify the args-param as "message fragments", so I would name the
paramter 'fragments' ;-)
    public static String toString(final Object[] fragments)

...


mmmh .... alternativly you could overload the Task.log() method...
   Task.log(Object[] messageFragments, int loglevel)



Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message