Clover Coverage Report - SmartWeb
Coverage timestamp: Sun Jun 8 2008 21:20:12 CEST
../../../../img/srcFileCovDistChart0.png 29% of files have more coverage
25   92   13   8,33
16   44   0,52   3
3     4,33  
1    
 
  PaginateTei       Line # 38 25 13 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.page;
25   
26    import java.util.Enumeration;
27   
28    import javax.servlet.jsp.tagext.TagData;
29    import javax.servlet.jsp.tagext.TagExtraInfo;
30    import javax.servlet.jsp.tagext.ValidationMessage;
31    import javax.servlet.jsp.tagext.VariableInfo;
32   
33    /**
34    * Additional features for the <code>PaginateTag</code>.
35    *
36    * @author rlogiacco
37    */
 
38    public class PaginateTei extends TagExtraInfo {
39   
40    /**
41    * @see javax.servlet.jsp.tagext.TagExtraInfo#getVariableInfo(javax.servlet.jsp.tagext.TagData)
42    */
 
43  0 toggle public final VariableInfo[] getVariableInfo(TagData data) {
44  0 return new VariableInfo[] {new VariableInfo("paginator", "net.smartlab.web.page.Paginator", true, VariableInfo.NESTED)};
45    }
46   
47    /**
48    * @see javax.servlet.jsp.tagext.TagExtraInfo#isValid(javax.servlet.jsp.tagext.TagData)
49    */
 
50  0 toggle public boolean isValid(TagData tagData) {
51  0 boolean hasHref = false;
52  0 boolean hasForm = false;
53   
54  0 Enumeration attributes = tagData.getAttributes();
55  0 while (attributes.hasMoreElements()) {
56  0 String attribute = (String)attributes.nextElement();
57  0 if (attribute.equals("href")) {
58  0 hasHref = true;
59  0 } else if (attribute.equals("form")) {
60  0 hasForm = true;
61    }
62    }
63  0 if (hasHref && hasForm) {
64    // ERROR
65  0 return false;
66    }
67  0 return true;
68    }
69   
70    /**
71    * @see javax.servlet.jsp.tagext.TagExtraInfo#validate(javax.servlet.jsp.tagext.TagData)
72    */
 
73  0 toggle public ValidationMessage[] validate(TagData tagData) {
74  0 boolean hasHref = false;
75  0 boolean hasForm = false;
76   
77  0 Enumeration attributes = tagData.getAttributes();
78  0 while (attributes.hasMoreElements()) {
79  0 String attribute = (String)attributes.nextElement();
80  0 if (attribute.equals("href")) {
81  0 hasHref = true;
82  0 } else if (attribute.equals("form")) {
83  0 hasForm = true;
84    }
85    }
86  0 if (hasHref && hasForm) {
87  0 return new ValidationMessage[] {new ValidationMessage(tagData.getId(), "Page tag has both href and form attributes")};
88    }
89  0 return null;
90    }
91   
92    }