Wednesday January 22, 2003
Commons Lang: StringUtils
My new favorite method is the equals method on Commons Lang's
StringUtils class. It takes the check for null out of your logic and can help you create cleaner code. Before using it you might have to write something like this:
if (request.getParameter("checkbox") != null
&& (request.getParameter("checkbox").equals("true"))) {
With StringUtils.equals(String, String), you get a little less coding:
if (StringUtils.equals(request.getParameter("checkbox"), "true")) {
If you're using Struts or some other library that already depends on commons-lang, why wouldn't you use it? Possibly performance reasons, but I doubt it causes much of a hit. Posted in Java at Jan 22 2003, 06:05:51 AM MST 4 Comments
Search This Site
Recent Entries
- Fantastic Fun in Jackson Hole
- How We Hired a Team of 10 in 2 Months
- Jack's Skiing Like A Madman!
- My Future of Web Frameworks Presentation
- My Guest Room Remodel is finished!
- Web Application Testing with Selenium by Jason Huggins
- Web Application Testing with Selenium at Agile Denver next Monday
- 17" MacBook Pro Stolen from Living Room
- Using JRebel with IntelliJ IDEA on OS X
- Reviews for Grails: A Quick-Start Guide and Kanban and Scrum
Posted by James Chochlinski on January 22, 2003 at 06:17 AM MST #
Posted by Martin van den Bemt on January 22, 2003 at 08:03 AM MST #
Posted by Chris Winters on January 22, 2003 at 08:58 AM MST #
Posted by Danman on January 22, 2003 at 09:54 AM MST #