Clover Coverage Report - SmartWeb
Coverage timestamp: Sun Jun 8 2008 21:20:12 CEST
../../../img/srcFileCovDistChart0.png 29% of files have more coverage
10   97   6   3,33
4   31   0,6   3
3     2  
1    
10,5% of code in this file is excluded from these metrics.
 
  Validator       Line # 41 10 6 0% 0.0
 
No Tests
 
1    /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10    * This library is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this library; if not, write to the Free Software
17    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18    *
19    * For further informations on the SmartWeb Framework please visit
20    *
21    * http://smartweb.sourceforge.net
22    */
23   
24    package net.smartlab.web;
25   
26    import javax.servlet.http.HttpServletRequest;
27   
28    import org.apache.commons.validator.Field;
29    import org.apache.commons.validator.GenericValidator;
30    import org.apache.commons.validator.ValidatorAction;
31    import org.apache.commons.validator.util.ValidatorUtils;
32    import org.apache.struts.action.ActionErrors;
33    import org.apache.struts.validator.Resources;
34   
35    /**
36    * TODO documentation
37    *
38    * @author rlogiacco
39    * @stereotype static
40    */
 
41    public class Validator {
42   
43    /**
44    * TODO documentation
45    *
46    * @param bean
47    * @param action
48    * @param field
49    * @param errors
50    * @param request
51    * @return
52    */
 
53  0 toggle public static boolean confirmed(Object bean, ValidatorAction action, Field field, ActionErrors errors, HttpServletRequest request) {
54  0 String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
55  0 String confirm = ValidatorUtils.getValueAsString(bean, field.getVarValue("confirm"));
56  0 if (!GenericValidator.isBlankOrNull(value)) {
57  0 try {
58  0 if (!value.equals(confirm)) {
59  0 errors.add(field.getKey(), Resources.getActionMessage(request, action, field));
60  0 return false;
61    }
62    } catch (Exception e) {
63    errors.add(field.getKey(), Resources.getActionMessage(request, action, field));
64    return false;
65    }
66    }
67  0 return true;
68    }
69   
70    /**
71    * TODO documentation
72    *
73    * @param bean
74    * @param action
75    * @param field
76    * @param errors
77    * @param request
78    * @return
79    */
 
80  0 toggle public static boolean before(Object bean, ValidatorAction action, Field field, ActionErrors errors, HttpServletRequest request) {
81  0 return true;
82    }
83   
84    /**
85    * TODO documentation
86    *
87    * @param bean
88    * @param action
89    * @param field
90    * @param errors
91    * @param request
92    * @return
93    */
 
94  0 toggle public static boolean after(Object bean, ValidatorAction action, Field field, ActionErrors errors, HttpServletRequest request) {
95  0 return true;
96    }
97    }