You got another option

Check this out (from NXCoreAPI) :

       final StringBuilder buf = new StringBuilder();

        buf.append(CoreEventImpl.class.getSimpleName());
        buf.append(" {");
        buf.append(" eventId: ");
        buf.append(getEventId());
        buf.append(", source: ");
        buf.append(getSource());
        buf.append(", info: ");
        buf.append(getInfo());
        buf.append(", date: ");
        buf.append(getDate());
        buf.append(", principal name: ");
        if (getPrincipal() != null) {
            buf.append(getPrincipal().getName());
        }
        buf.append(", comment: ");
        buf.append(getComment());
        buf.append(", category: ");
        buf.append(getCategory());
        buf.append("}");

        return buf.toString();

Supposed to be quicker especially if you are constructing string during
an iteration.

        J.


cedric MARFIL wrote:
> OK,
> Thanks.
> Python made the code easier and shorter using that syntax, but if java takes 
> performances just to do the same,
> I guess it would be better to use the + syntax:
> String firstName = "Cedric";
> String a = "Hello " + firstName;
> In case of many elements to put in the string, it will render something like 
> this:
> String a = "Hello " + firstName + ", how are you ? Did you have a good day on 
> " + day + ". I guess it will be
> better on " + date.toString() + ". See you".
> 
> Thanks
> 
> ---------- Initial Header -----------
> 
>>From      : "Florent Guillaume" [EMAIL PROTECTED]
> To          : "cedric MARFIL" [EMAIL PROTECTED]
> 
> Cc          : "ECM List" [email protected]
> Date      : Fri, 22 Dec 2006 14:49:23 +0100
> Subject : Re: [Ecm] % Notation in java
> 
>> On 22 Dec 2006, at 14:46, Julien Anguenot wrote:
>>> cedric MARFIL wrote:
>>>> Hello,
>>>> I would like to know if, during your java migration, you found a  
>>>> way to reproduce the percent notation to
>>>> build strings like it was possible in python ?
>>>> Like:
>>>> a = "Hello %s"%("Cedric")
>>> Java5 provides a way to do something similar :
> 
>>> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
>>>
>>> But we obviously didn't leverage this that much ...
>> Note that in most cases, it's faster and simpler to just do string  
>> concatenation.
>>
>> Florent
>>
>> -- 
>> Florent Guillaume, Director of R&D, Nuxeo
>> Open Source Enterprise Content Management (ECM)
>> http://www..nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87
>>
>>
>>
> 
> 
> This message contains information that may be privileged or confidential and 
> is the property of the Capgemini Group. It is intended only for the person to 
> whom it is addressed. If you are not the intended recipient,  you are not 
> authorized to read, print, retain, copy, disseminate,  distribute, or use 
> this message or any part thereof. If you receive this  message in error, 
> please notify the sender immediately and delete all  copies of this message.
> 
> _______________________________________________
> ECM mailing list
> [email protected]
> http://lists.nuxeo.com/mailman/listinfo/ecm
> 


-- 
Julien Anguenot | Nuxeo R&D (Paris, France)
Open Source ECM - http://www.nuxeo.com
Nuxeo 5 : http://www.nuxeo.org
Mobile: +33 (0) 6 72 57 57 66

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm

Reply via email to