01: package simpleorm.simplewebapp.scalarFields;
02:
03: import simpleorm.simplewebapp.core.WField;
04:
05: public class WFieldString extends WField {
06: public WFieldString(String name) {
07: super (name);
08: }
09:
10: public WFieldString(String name, String widget) {
11: super (name, widget);
12: }
13:
14: protected String format() {
15: return (String) value;
16: }
17:
18: protected void parse(String rawText) {
19: this .value = rawText;
20: }
21:
22: public Class getValueClass() {
23: return String.class;
24: }
25:
26: public String getValue() {
27: return (String) super .getValue();
28: }
29:
30: /** Interpret the string as a boolean. */
31: public boolean getBooleanValue(boolean defalt) {
32: if (value == null)
33: return false;
34: return "true".equalsIgnoreCase((String) value)
35: || "t".equalsIgnoreCase((String) value)
36: || "yes".equalsIgnoreCase((String) value)
37: || "y".equalsIgnoreCase((String) value) // I18N?
38: || "on".equalsIgnoreCase((String) value);
39: }
40:
41: }
|