1
2
3
4
5
6
7
8
9
10
11 package psiprobe.jsp;
12
13 import jakarta.servlet.jsp.JspException;
14 import jakarta.servlet.jsp.tagext.TagSupport;
15
16 import java.io.IOException;
17
18 import psiprobe.tools.SizeExpression;
19
20
21
22
23
24 public class VolumeTag extends TagSupport {
25
26
27 private static final long serialVersionUID = 1L;
28
29
30 private long value;
31
32
33 private int fractions;
34
35
36
37
38
39
40 public void setValue(long value) {
41 this.value = value;
42 }
43
44
45
46
47
48
49 public int getFractions() {
50 return fractions;
51 }
52
53
54
55
56
57
58 public void setFractions(int fractions) {
59 this.fractions = fractions;
60 }
61
62 @Override
63 public int doStartTag() throws JspException {
64 String title = Long.toString(value);
65 String newValue = SizeExpression.format(value, fractions, true);
66 try {
67 pageContext.getOut().write("<span title=\"" + title + "\">" + newValue + "</span>");
68 } catch (IOException e) {
69 throw new JspException("Exception writing value to JspWriter", e);
70 }
71
72 return EVAL_BODY_INCLUDE;
73 }
74
75 }