Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
86   258   40   2.87
32   197   0.47   30
30     1.33  
1    
 
 
  FormatImageActionTag       Line # 34 86 40 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.TagSupport;
27   
28    import org.apache.struts.taglib.TagUtils;
29    import org.itracker.core.resources.ITrackerResources;
30    import org.itracker.model.UserPreferences;
31    import org.itracker.services.util.HTMLUtilities;
32    import org.itracker.web.util.Constants;
33   
 
34    public final class FormatImageActionTag extends TagSupport {
35    /**
36    *
37    */
38    private static final long serialVersionUID = 1L;
39   
40    private String action = null;
41    private String forward = null;
42    private String module = null;
43    private String paramName = null;
44    private String paramValue = null;
45    private String src = null;
46    private String altKey = null;
47    private String arg0 = null;
48    private String textActionKey = null;
49    private String border = null;
50    private String caller = null;
51    private String targetAction = null;
52    private String target = 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 getModule() {
71  0 return module;
72    }
73   
 
74  0 toggle public void setModule(String module) {
75  0 this.module = module;
76    }
77   
 
78  0 toggle public String getParamName() {
79  0 return paramName;
80    }
81   
 
82  0 toggle public void setParamName(String value) {
83  0 paramName = value;
84    }
85   
 
86  0 toggle public Object getParamValue() {
87  0 return paramValue;
88    }
89   
 
90  0 toggle public void setParamValue(Object value) {
91  0 paramValue = (value != null ? value.toString() : null);
92    }
93   
 
94  0 toggle public String getSrc() {
95  0 return src;
96    }
97   
 
98  0 toggle public void setSrc(String value) {
99  0 src = value;
100    }
101   
 
102  0 toggle public String getAltKey() {
103  0 return altKey;
104    }
105   
 
106  0 toggle public void setAltKey(String value) {
107  0 altKey = value;
108    }
109   
 
110  0 toggle public Object getArg0() {
111  0 return arg0;
112    }
113   
 
114  0 toggle public void setArg0(Object value) {
115  0 arg0 = (value != null ? value.toString() : null);
116    }
117   
 
118  0 toggle public String getTextActionKey() {
119  0 return textActionKey;
120    }
121   
 
122  0 toggle public void setTextActionKey(String value) {
123  0 textActionKey = value;
124    }
125   
 
126  0 toggle public String getBorder() {
127  0 return border;
128    }
129   
 
130  0 toggle public void setBorder(String value) {
131  0 border = value;
132    }
133   
 
134  0 toggle public String getCaller() {
135  0 return caller;
136    }
137   
 
138  0 toggle public void setCaller(String value) {
139  0 caller = value;
140    }
141   
 
142  0 toggle public String getTargetAction() {
143  0 return targetAction;
144    }
145   
 
146  0 toggle public void setTargetAction(String value) {
147  0 targetAction = value;
148    }
149   
 
150  0 toggle public String getTarget() {
151  0 return target;
152    }
153   
 
154  0 toggle public void setTarget(String value) {
155  0 target = value;
156    }
157   
 
158  0 toggle public int doStartTag() throws JspException {
159  0 return SKIP_BODY;
160    }
161   
 
162  0 toggle public int doEndTag() throws JspException {
163  0 boolean hasParams = false;
164  0 boolean useTextActions = false;
165  0 Locale locale = null;
166   
167  0 HttpSession session = pageContext.getSession();
168  0 if (session != null) {
169  0 locale = (Locale) session.getAttribute(Constants.LOCALE_KEY);
170  0 UserPreferences currUserPrefs = (UserPreferences) session
171    .getAttribute(Constants.PREFERENCES_KEY);
172  0 useTextActions = (currUserPrefs != null ? currUserPrefs
173    .getUseTextActions() : false);
174    }
175   
176  0 StringBuffer buf = new StringBuffer("<a href=\"");
177  0 try {
178  0 buf.append(TagUtils.getInstance().computeURL(pageContext, forward,
179    null, null, action, module, null, null, false));
180    } catch (MalformedURLException murle) {
181  0 buf.append(HTMLUtilities.escapeTags(forward));
182    }
183  0 if (paramName != null && paramValue != null) {
184  0 buf.append("?" + paramName + "=" + paramValue);
185  0 hasParams = true;
186    }
187  0 if (caller != null) {
188  0 buf.append((hasParams ? "&amp;" : "?") + "caller=" + HTMLUtilities.escapeTags(caller));
189  0 hasParams = true;
190    }
191  0 if (targetAction != null) {
192  0 buf.append((hasParams ? "&amp;" : "?") + "action=" + HTMLUtilities.escapeTags(targetAction));
193  0 hasParams = true;
194    }
195  0 buf.append("\"");
196  0 if (target != null) {
197  0 buf.append(" target=\"" + target + "\"");
198    }
199  0 if (useTextActions) {
200  0 buf.append(" title=\""
201    + ITrackerResources.getString(altKey, locale,
202  0 (arg0 == null ? "" : arg0)) + "\"");
203  0 buf.append(" class=\"action\">");
204  0 buf.append(ITrackerResources.getString(textActionKey, locale));
205    } else {
206  0 buf.append(">");
207  0 buf.append("<img src=\"");
208  0 try {
209  0 buf.append(TagUtils.getInstance().computeURL(pageContext, null,
210    null, src, null, "", null, null, false));
211   
212    } catch (MalformedURLException murle) {
213  0 buf.append(HTMLUtilities.escapeTags(src));
214    }
215  0 buf.append("\"");
216  0 if (altKey != null) {
217  0 buf.append(" alt=\""
218    + ITrackerResources.getString(altKey, locale,
219  0 (arg0 == null ? "" : arg0)) + "\"");
220  0 buf.append(" title=\""
221    + ITrackerResources.getString(altKey, locale,
222  0 (arg0 == null ? "" : arg0)) + "\"");
223    } else {
224  0 buf.append(" alt=\"\"");
225    }
226  0 buf.append(" style=\"border:"
227  0 + (border == null ? "0" : border + "px") + ";\"");
228  0 buf.append(" />");
229    }
230  0 buf.append("</a>");
231    // ResponseUtils.write(pageContext, buf.toString());
232  0 TagUtils.getInstance().write(pageContext, buf.toString());
233  0 clearState();
234  0 return (EVAL_PAGE);
235    }
236   
237   
 
238  0 toggle public void release() {
239  0 super.release();
240  0 clearState();
241    }
242   
 
243  0 toggle private void clearState() {
244  0 action = null;
245  0 forward = null;
246  0 paramName = null;
247  0 paramValue = null;
248  0 src = null;
249  0 altKey = null;
250  0 arg0 = null;
251  0 textActionKey = null;
252  0 border = null;
253  0 caller = null;
254  0 target = null;
255  0 targetAction = null;
256  0 module = null;
257    }
258    }