| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.web.taglib; |
| 20 |
|
|
| 21 |
|
import java.text.SimpleDateFormat; |
| 22 |
|
import java.util.Date; |
| 23 |
|
import java.util.Locale; |
| 24 |
|
|
| 25 |
|
import javax.servlet.http.HttpServletRequest; |
| 26 |
|
import javax.servlet.jsp.JspException; |
| 27 |
|
import javax.servlet.jsp.tagext.TagSupport; |
| 28 |
|
|
| 29 |
|
import org.apache.struts.taglib.TagUtils; |
| 30 |
|
import org.itracker.core.resources.ITrackerResources; |
| 31 |
|
import org.itracker.web.util.LoginUtilities; |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 60 (60) |
Complexity: 18 |
Complexity Density: 0.5 |
|
| 33 |
|
public class FormatDateTag extends TagSupport { |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
private static final long serialVersionUID = 1L; |
| 38 |
|
private String emptyKey = "itracker.web.generic.unavailable"; |
| 39 |
|
private String format; |
| 40 |
|
private Date date; |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
public String getFormat() {... |
| 43 |
0
|
return format; |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
0
|
public void setFormat(String value) {... |
| 47 |
0
|
format = value; |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 50 |
0
|
public Date getDate() {... |
| 51 |
0
|
if (null == date) |
| 52 |
0
|
return null; |
| 53 |
0
|
return new Date(date.getTime()); |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 56 |
0
|
public void setDate(Date value) {... |
| 57 |
0
|
if (null == value) |
| 58 |
0
|
this.date = null; |
| 59 |
|
else |
| 60 |
0
|
date = new Date(value.getTime()); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
0
|
public String getEmptyKey() {... |
| 64 |
0
|
return emptyKey; |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
0
|
public void setEmptyKey(String value) {... |
| 68 |
0
|
emptyKey = value; |
| 69 |
|
} |
| 70 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
0
|
public int doStartTag() throws JspException {... |
| 72 |
0
|
return SKIP_BODY; |
| 73 |
|
} |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 7 |
Complexity Density: 0.35 |
|
| 75 |
0
|
public int doEndTag() throws JspException {... |
| 76 |
0
|
String value = ""; |
| 77 |
0
|
SimpleDateFormat sdf; |
| 78 |
0
|
Locale locale = null; |
| 79 |
0
|
if (pageContext.getRequest() instanceof HttpServletRequest) { |
| 80 |
0
|
locale = LoginUtilities.getCurrentLocale((HttpServletRequest)pageContext.getRequest()); |
| 81 |
|
} |
| 82 |
0
|
if (locale == null) { |
| 83 |
0
|
locale = ITrackerResources.getLocale(); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
0
|
if (date == null) { |
| 87 |
0
|
value = ITrackerResources.getString(emptyKey, locale); |
| 88 |
|
} else { |
| 89 |
0
|
try { |
| 90 |
0
|
if ("short".equalsIgnoreCase(format)) { |
| 91 |
0
|
sdf = new SimpleDateFormat(ITrackerResources.getString( |
| 92 |
|
"itracker.dateformat.short", locale), locale); |
| 93 |
0
|
} else if ("notime".equalsIgnoreCase(format)) { |
| 94 |
0
|
sdf = new SimpleDateFormat(ITrackerResources.getString( |
| 95 |
|
"itracker.dateformat.dateonly", locale), locale); |
| 96 |
|
} else { |
| 97 |
0
|
sdf = new SimpleDateFormat(ITrackerResources.getString( |
| 98 |
|
"itracker.dateformat.full", locale), locale); |
| 99 |
|
} |
| 100 |
0
|
value = sdf.format(date); |
| 101 |
|
} catch (Exception e) { |
| 102 |
0
|
value = ITrackerResources.getString(emptyKey, locale); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|
| 106 |
0
|
TagUtils.getInstance().write(pageContext, value); |
| 107 |
0
|
clearState(); |
| 108 |
0
|
return EVAL_PAGE; |
| 109 |
|
} |
| 110 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 111 |
0
|
public void release() {... |
| 112 |
0
|
super.release(); |
| 113 |
0
|
clearState(); |
| 114 |
|
} |
| 115 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 116 |
0
|
private void clearState() {... |
| 117 |
0
|
emptyKey = "itracker.web.generic.unavailable"; |
| 118 |
0
|
format = null; |
| 119 |
0
|
date = null; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
} |