StringUtils in ATG Dynamo

A hidden gem in ATG Dynamo is the simple, but VERY useful, and totally undocumented StringUtils class. It lives in the atg.core.util package in DAS/lib/classes.jar. It has several methods, but the most commonly used are isEmpty(String) and isBlank(String). Both return a boolean, and are very useful for validating form input and the like.

One thing to note is the important difference between the two methods. isEmpty() will return true for a null or a String with a length of zero. isBlank() will return true for null, or a String with a length of zero, OR a String of just whitespace. It basically adds a trim() call to it’s checks.

So when you’re validating user input, use isBlank() not isEmpty() otherwise you can easily end up with a database full of single space, ” “, names, passwords, e-mails, etc….

Remember, using undocumented classes or APIs is at your own risk, however this class, and these methods have been around for ages and are pretty stable.

One thought on “StringUtils in ATG Dynamo

  1. Thanks, nice explanation of this undocumented util class. I was looking for the differences between those two methods.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>