Return-Path: Delivered-To: apmail-velocity-dev-archive@www.apache.org Received: (qmail 58420 invoked from network); 13 Feb 2009 21:45:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Feb 2009 21:45:22 -0000 Received: (qmail 9699 invoked by uid 500); 13 Feb 2009 21:45:22 -0000 Delivered-To: apmail-velocity-dev-archive@velocity.apache.org Received: (qmail 9629 invoked by uid 500); 13 Feb 2009 21:45:22 -0000 Mailing-List: contact dev-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Velocity Developers List" Delivered-To: mailing list dev@velocity.apache.org Received: (qmail 9618 invoked by uid 500); 13 Feb 2009 21:45:22 -0000 Delivered-To: apmail-jakarta-velocity-dev@jakarta.apache.org Received: (qmail 9615 invoked by uid 99); 13 Feb 2009 21:45:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2009 13:45:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2009 21:45:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AF3E4234C48D for ; Fri, 13 Feb 2009 13:44:59 -0800 (PST) Message-ID: <748588232.1234561499716.JavaMail.jira@brutus> Date: Fri, 13 Feb 2009 13:44:59 -0800 (PST) From: "Sergiy Kovalchuk (JIRA)" To: velocity-dev@jakarta.apache.org Subject: [jira] Commented: (VELOCITY-692) have #if handle empty strings/arrays/collections/maps more conveniently In-Reply-To: <1761987350.1234298279725.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/VELOCITY-692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673384#action_12673384 ] Sergiy Kovalchuk commented on VELOCITY-692: ------------------------------------------- >if someone wants to be specific about what falsiness they are checking on, they should always be specific and do: >#if( $foo == $null ) >#if( $foo == false ) >#if( $foo.length() == 0 ) >#if( $foo.isEmpty() ) Yes, but if I understand it correctly if #if operator will check for emptiness, all those expressions will be equal. You can't use #if( $foo == $null ) anymore because it will be the same as #if( $foo.length() == 0 ) (if an object has length) and so on. That's why I thought about separated operator for checking for emptiness - so you still can check for null or for length/false/empty specifically if you want using regular #if, and it won't break backward compatibility. Also when a user calls operator named something like #ifEmpty it is clear what he wants, and in this case reflection for empty/length/size methods won't be unexpected. Unless I don't get the point and you still will be able to check for nulls even with this empty addition? ($null in Velocity is just a regular variable, not a special keyword, isn't it?) > have #if handle empty strings/arrays/collections/maps more conveniently > ----------------------------------------------------------------------- > > Key: VELOCITY-692 > URL: https://issues.apache.org/jira/browse/VELOCITY-692 > Project: Velocity > Issue Type: New Feature > Components: Engine > Reporter: Nathan Bubna > Priority: Trivial > > An idea from the dev list: > ------------------------------------------------------------------------------------------------- > On Sat, Feb 7, 2009 at 3:41 PM, wrote: > > Hello, > > I wanted to share with you a few ideas I have about new simple > > improvements for DisplayTools. I should be able to make patches for > > them if you are interested. > > > > 1. Add new method > > > > isEmpty(object) > > > > that will return true if the object is null or empty (for strings it's > > zero length; for collections, maps and arrays it's zero size). This > > should help with annoying null checks. (Probably a better place for > > this method would be Engine, not Tools) > yeah, not something for tools. would be interesting to have the > Uberspect pretend that every non-null reference has an isEmpty() > method, or perhaps just add 0-length strings, empty collections, empty > maps and 0-length arrays to the list of things that #if( $foo ) > considers false. > ------------------------------------------------------------------------------------------------- -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org For additional commands, e-mail: dev-help@velocity.apache.org