KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > validator > rules > MandatoryString


1 package org.sapia.validator.rules;
2
3 import org.sapia.validator.BeanRule;
4
5 /**
6  * Insures that an expected value is not null.
7  *
8  * @author Yanick Duchesne
9  * <dl>
10  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
11  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
12  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
13  * </dl>
14  */

15 public class MandatoryString extends BeanRule {
16   /**
17    * Constructor for Mandatory.
18    */

19   public MandatoryString() {
20     super();
21   }
22
23   /**
24    * @see org.sapia.validator.BeanRule#doValidate(Object)
25    */

26   protected boolean doValidate(Object JavaDoc toValidate) {
27     if(toValidate == null){
28       return false;
29     }
30     else{
31       return ((String JavaDoc)toValidate).length() > 0;
32     }
33   }
34 }
35
Popular Tags