Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
77   226   39   2.85
32   168   0.51   27
27     1.44  
1    
 
 
  FormatLinkTag       Line # 34 77 39 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.web.taglib;
20   
21    import java.net.MalformedURLException;
22    import java.util.Locale;
23   
24    import javax.servlet.http.HttpSession;
25    import javax.servlet.jsp.JspException;
26    import javax.servlet.jsp.tagext.BodyTagSupport;
27   
28    import org.apache.struts.taglib.TagUtils;
29    import org.itracker.core.resources.ITrackerResources;
30    import org.itracker.services.util.HTMLUtilities;
31    import org.itracker.web.util.Constants;
32   
33   
 
34    public final class FormatLinkTag extends BodyTagSupport {
35    /**
36    *
37    */
38    private static final long serialVersionUID = 1L;
39   
40    private String text = null;
41   
42    private String action = null;
43    private String forward = null;
44    private String paramName = null;
45    private String paramValue = null;
46    private String titleKey = null;
47    private String arg0 = null;
48    private String caller = null;
49    private String targetAction = null;
50    private String target = null;
51    private String styleClass = null;
52    private String queryString = null;
53   
 
54  0 toggle public String getAction() {
55  0 return action;
56    }
57   
 
58  0 toggle public void setAction(String value) {
59  0 action = value;
60    }
61   
 
62  0 toggle public String getForward() {
63  0 return forward;
64    }
65   
 
66  0 toggle public void setForward(String value) {
67  0 forward = value;
68    }
69   
 
70  0 toggle public String getParamName() {
71  0 return paramName;
72    }
73   
 
74  0 toggle public void setParamName(String value) {
75  0 paramName = value;
76    }
77   
 
78  0 toggle public Object getParamValue() {
79  0 return paramValue;
80    }
81   
 
82  0 toggle public void setParamValue(Object value) {
83  0 paramValue = (value != null ? value.toString() : null);
84    }
85   
 
86  0 toggle public String getQueryString() {
87  0 return queryString;
88    }
89   
 
90  0 toggle public void setQueryString(String value) {
91  0 queryString = value;
92    }
93   
 
94  0 toggle public String getTitleKey() {
95  0 return titleKey;
96    }
97   
 
98  0 toggle public void setTitleKey(String value) {
99  0 titleKey = value;
100    }
101   
 
102  0 toggle public Object getArg0() {
103  0 return arg0;
104    }
105   
 
106  0 toggle public void setArg0(Object value) {
107  0 arg0 = (value != null ? value.toString() : null);
108    }
109   
 
110  0 toggle public String getCaller() {
111  0 return caller;
112    }
113   
 
114  0 toggle public void setCaller(String value) {
115  0 caller = value;
116    }
117   
 
118  0 toggle public String getTargetAction() {
119  0 return targetAction;
120    }
121   
 
122  0 toggle public void setTargetAction(String value) {
123  0 targetAction = value;
124    }
125   
 
126  0 toggle public String getTarget() {
127  0 return target;
128    }
129   
 
130  0 toggle public void setTarget(String value) {
131  0 target = value;
132    }
133   
 
134  0 toggle public String getStyleClass() {
135  0 return styleClass;
136    }
137   
 
138  0 toggle public void setStyleClass(String value) {
139  0 styleClass = value;
140    }
141   
 
142  0 toggle public int doStartTag() throws JspException {
143  0 text = null;
144  0 return EVAL_BODY_BUFFERED;
145    }
146   
 
147  0 toggle public int doAfterBody() throws JspException {
148  0 if(bodyContent != null) {
149  0 String value = bodyContent.getString().trim();
150  0 if(value.length() > 0) {
151  0 text = value;
152    }
153    }
154  0 return SKIP_BODY;
155    }
156   
 
157  0 toggle public int doEndTag() throws JspException {
158  0 boolean hasParams = false;
159  0 Locale locale = null;
160   
161  0 HttpSession session = pageContext.getSession();
162  0 if(session != null) {
163  0 locale = (Locale) session.getAttribute(Constants.LOCALE_KEY);
164    }
165   
166  0 StringBuffer buf = new StringBuffer("<a href=\"");
167  0 try {
168  0 buf.append(TagUtils.getInstance().computeURL(pageContext, forward, null, null, action, null, null, null, false));
169    } catch(MalformedURLException murle) {
170  0 buf.append(HTMLUtilities.escapeTags(forward));
171    }
172  0 if(queryString != null) {
173  0 buf.append("?" + HTMLUtilities.escapeTags(queryString));
174  0 hasParams = true;
175    }
176  0 if(paramName != null && paramValue != null) {
177  0 buf.append((hasParams ? "&amp;" : "?") + paramName + "=" + paramValue);
178  0 hasParams = true;
179    }
180  0 if(caller != null) {
181  0 buf.append((hasParams ? "&amp;" : "?") + "caller=" + HTMLUtilities.escapeTags(caller));
182  0 hasParams = true;
183    }
184  0 if(targetAction != null) {
185  0 buf.append((hasParams ? "&amp;" : "?") + "action=" + HTMLUtilities.escapeTags(targetAction));
186  0 hasParams = true;
187    }
188  0 buf.append("\"");
189  0 if(target != null) {
190  0 buf.append(" target=\"" + HTMLUtilities.escapeTags(target) + "\"");
191    }
192  0 if(titleKey != null) {
193  0 buf.append(" title=\"" + HTMLUtilities.escapeTags(ITrackerResources.getString(titleKey, locale, (arg0 == null ? "" : arg0))) + "\"");
194    }
195  0 if(styleClass != null) {
196  0 buf.append(" class=\"" + HTMLUtilities.escapeTags(styleClass) + "\"");
197    }
198  0 buf.append(">");
199  0 buf.append(HTMLUtilities.escapeTags(text));
200  0 buf.append("</a>");
201    // ResponseUtils.write(pageContext, buf.toString());
202  0 TagUtils.getInstance().write(pageContext, buf.toString());
203  0 clearState();
204  0 return (EVAL_PAGE);
205    }
206   
 
207  0 toggle public void release() {
208  0 super.release();
209  0 clearState();
210    }
211   
 
212  0 toggle private void clearState() {
213  0 text = null;
214  0 action = null;
215  0 forward = null;
216  0 paramName = null;
217  0 paramValue = null;
218  0 titleKey = null;
219  0 arg0 = null;
220  0 caller = null;
221  0 target = null;
222  0 targetAction = null;
223  0 styleClass = null;
224  0 queryString = null;
225    }
226    }