Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
31   123   17   3.44
10   76   0.55   9
9     1.89  
1    
 
 
  FormatResolutionTag       Line # 39 31 17 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.util.Locale;
22    import java.util.MissingResourceException;
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.services.util.IssueUtilities;
30    import org.itracker.services.util.ProjectUtilities;
31    import org.itracker.web.util.Constants;
32   
33   
34    /**
35    * Formats a resolution for a display. If the project uses fixed resolutions,
36    * it prints the appropriate string for the current locale. Currently the tag
37    * only supports non-editable resolution fields.
38    */
 
39    public class FormatResolutionTag extends BodyTagSupport {
40    /**
41    *
42    */
43    private static final long serialVersionUID = 1L;
44    public static final String DISPLAY_TYPE_EDIT = "edit";
45    public static final String DISPLAY_TYPE_VIEW = "view";
46   
47    private String text = null;
48    private String displayType;
49    private int projectOptions;
50   
 
51  0 toggle public int getProjectOptions() {
52  0 return projectOptions;
53    }
54   
 
55  0 toggle public void setProjectOptions(int value) {
56  0 projectOptions = value;
57    }
58   
 
59  0 toggle public String getDisplayType() {
60  0 return displayType;
61    }
62   
 
63  0 toggle public void setDisplayType(String value) {
64  0 displayType = value;
65    }
66   
 
67  0 toggle public int doStartTag() throws JspException {
68  0 text = null;
69  0 return EVAL_BODY_BUFFERED;
70    }
71   
 
72  0 toggle public int doAfterBody() throws JspException {
73  0 if(bodyContent != null) {
74  0 String value = bodyContent.getString().trim();
75  0 if(value.length() > 0) {
76  0 text = value;
77    }
78    }
79  0 return SKIP_BODY;
80    }
81   
 
82  0 toggle public int doEndTag() throws JspException {
83  0 StringBuffer results = new StringBuffer();
84  0 if(text != null && ! text.trim().equals("")) {
85  0 Locale locale = null;
86   
87  0 HttpSession session = pageContext.getSession();
88  0 if(session != null) {
89  0 locale = (Locale) session.getAttribute(Constants.LOCALE_KEY);
90    }
91   
92  0 try {
93   
94  0 projectOptions = ProjectUtilities.OPTION_PREDEFINED_RESOLUTIONS;
95    } catch(NumberFormatException nfe) {
96    }
97   
98  0 if(ProjectUtilities.hasOption(ProjectUtilities.OPTION_PREDEFINED_RESOLUTIONS, projectOptions)) {
99  0 try {
100  0 text = IssueUtilities.checkResolutionName(text, locale);
101    } catch(MissingResourceException mre) {
102    // Key didn't exist so just stick the key in as a real number.
103    }
104    }
105  0 results.append(text);
106    }
107    // ResponseUtils.write(pageContext, results.toString());
108  0 TagUtils.getInstance().write(pageContext, results.toString());
109  0 clearState();
110  0 return (EVAL_PAGE);
111    }
112   
 
113  0 toggle public void release() {
114  0 super.release();
115  0 clearState();
116    }
117   
 
118  0 toggle private void clearState() {
119  0 text = null;
120  0 displayType = DISPLAY_TYPE_VIEW;
121  0 projectOptions = 0;
122    }
123    }