Return-Path: Delivered-To: apmail-jakarta-velocity-user-archive@www.apache.org Received: (qmail 1806 invoked from network); 16 Sep 2005 10:41:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Sep 2005 10:41:45 -0000 Received: (qmail 88824 invoked by uid 500); 16 Sep 2005 10:41:40 -0000 Delivered-To: apmail-jakarta-velocity-user-archive@jakarta.apache.org Received: (qmail 88717 invoked by uid 500); 16 Sep 2005 10:41:39 -0000 Mailing-List: contact velocity-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Velocity Users List" Reply-To: "Velocity Users List" Delivered-To: mailing list velocity-user@jakarta.apache.org Received: (qmail 88654 invoked by uid 99); 16 Sep 2005 10:41:38 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2005 03:41:38 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [129.247.21.33] (HELO n33.go.t-systems-sfr.com) (129.247.21.33) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Sep 2005 03:41:47 -0700 Received: from n81g.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) by n33.go.t-systems-sfr.com (8.11.7-20030917/8.11.7) with ESMTP id j8GAfVL501796 for ; Fri, 16 Sep 2005 12:41:31 +0200 Received: from [129.247.240.153] (manticore.af.op.dlr.de [129.247.240.153]) by n81g.sp.op.dlr.de (AIX5.1/8.11.6p2/8.11.0) with ESMTP id j8GAfVu282602 for ; Fri, 16 Sep 2005 12:41:31 +0200 Message-ID: <432AA15B.8020404@recks.org> Date: Fri, 16 Sep 2005 12:41:31 +0200 From: Christoph Reck User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.8) Gecko/20050512 X-Accept-Language: en, de MIME-Version: 1.0 To: Velocity Users List Subject: Re: Comparing strings References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Steve, Steve O'Hara wrote: > A while back I chastised someone for not using proper String comparison > operators in their templates. I looked in the Velocity code and sure > enough "==" operators are translated into equals. So I was looking a bit > stupid. > > Somebody challenged me to come up with a situation where the equality > "==" operator doesn't work with Strings. > Well, finally, I've just found an example in my code; > > #if ($SummarySortField==$Field.getUdmFieldName()) > > This statement doesn't produce a true, neither does this; > > #if ($SummarySortField==${Field.getUdmFieldName()}) It would be helpful to know the contents and jave class behind the references: $SummarySortField ($SummarySortField.class.name) $Field.getUdmFieldName() ($Field.getUdmFieldName().class.name) > > But this version does:- > > #if ($SummarySortField.equalsIgnoreCase($Field.getUdmFieldName())) Please note that equalsIgnoreCase() is not the same as equals() ;D You can try explicetely: #if( $SummarySortField.equals( $Field.getUdmFieldName() ) ) Which probably will also retrun false according to the first two examples.. :) Christoph > > I thought perhaps I was going mad before when I raised this and plenty > of people on this list questioned me, but can anyone explain this? > > Steve --------------------------------------------------------------------- To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: velocity-user-help@jakarta.apache.org