1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.taglib;
25
26 import org.dbforms.config.Field;
27
28 import org.dbforms.util.MessageResources;
29
30 import java.util.Locale;
31
32 import javax.servlet.http.HttpServletRequest;
33
34
35
36 /***
37 * Special class for TextFormatting
38 *
39 * @author hkk
40 */
41 public class TextFormatterUtil extends AbstractDbBaseHandlerTag {
42 private Locale locale;
43 private Object obj;
44
45 /***
46 * Creates a new TextFormatter object.
47 *
48 * @param field DOCUMENT ME!
49 * @param locale DOCUMENT ME!
50 * @param pattern DOCUMENT ME!
51 * @param obj DOCUMENT ME!
52 */
53 protected TextFormatterUtil(Field field,
54 Locale locale,
55 String pattern,
56 Object obj) {
57 this.obj = obj;
58 this.locale = locale;
59 setPattern(pattern);
60 setField(field);
61 }
62
63 /***
64 * DOCUMENT ME!
65 *
66 * @param field DOCUMENT ME!
67 * @param locale DOCUMENT ME!
68 * @param pattern DOCUMENT ME!
69 * @param obj DOCUMENT ME!
70 *
71 * @return DOCUMENT ME!
72 */
73 public static String FormatText(Field field,
74 Locale locale,
75 String pattern,
76 Object obj) {
77 TextFormatterUtil tf = new TextFormatterUtil(field, locale, pattern, obj);
78
79 return tf.getFormattedFieldValue();
80 }
81
82
83 /***
84 * DOCUMENT ME!
85 *
86 * @param field DOCUMENT ME!
87 * @param request DOCUMENT ME!
88 * @param pattern DOCUMENT ME!
89 * @param obj DOCUMENT ME!
90 *
91 * @return DOCUMENT ME!
92 */
93 public static String FormatText(Field field,
94 HttpServletRequest request,
95 String pattern,
96 Object obj) {
97 Locale locale = MessageResources.getLocale(request);
98 TextFormatterUtil tf = new TextFormatterUtil(field, locale, pattern, obj);
99
100 return tf.getFormattedFieldValue();
101 }
102
103
104 /***
105 * DOCUMENT ME!
106 *
107 * @param parentForm DOCUMENT ME!
108 *
109 * @return DOCUMENT ME!
110 */
111 public String getFormFieldName(DbFormTag parentForm) {
112 setParent(parentForm);
113
114 return super.getFormFieldName();
115 }
116
117
118 /***
119 * DOCUMENT ME!
120 *
121 * @return DOCUMENT ME!
122 */
123 public String getFormattedFieldValue() {
124 return super.getFormattedFieldValue();
125 }
126
127
128 /***
129 * DOCUMENT ME!
130 *
131 * @return DOCUMENT ME!
132 */
133 public String renderPatternHtmlInputField() {
134 return super.renderPatternHtmlInputField();
135 }
136
137
138 /***
139 * DOCUMENT ME!
140 *
141 * @return DOCUMENT ME!
142 */
143 protected Object getFieldObject() {
144 return obj;
145 }
146
147
148 /***
149 * DOCUMENT ME!
150 *
151 * @return DOCUMENT ME!
152 */
153 protected Locale getLocale() {
154 return locale;
155 }
156 }