01: package simpleorm.core;
02:
03: import java.sql.ResultSet;
04:
05: import simpleorm.properties.SPropertyValue;
06:
07: /** Boolieans which are represented by a string.
08: * Subclasses determine whether "T", "Y", "Yes" etc.
09: * */
10:
11: public abstract class SFieldBooleanChar extends SFieldBoolean {
12:
13: /** Represents Boolean field meta data as "T" and "F" chars.
14: * @author Martin Snyder. */
15:
16: String TRUE_VALUE;
17: String FALSE_VALUE;
18:
19: public SFieldBooleanChar(SRecordMeta meta, String columnName,
20: SPropertyValue[] pvals) {
21: super (meta, columnName, pvals);
22: putProperty(SCon.SBYTE_SIZE, new Integer(1)); // for Create Table only.
23: }
24:
25: /*
26: public SFieldBooleanChar(SRecordMeta meta, String columnName)
27: {
28: this(meta, columnName, new SPropertyValue[0]);
29: }
30: public SFieldBooleanChar(SRecordMeta meta, String columnName, SPropertyValue pval)
31: {
32: this(meta, columnName, new SPropertyValue[]{pval});
33: }
34: public SFieldBooleanChar(SRecordMeta meta, String columnName, SPropertyValue pval1, SPropertyValue pval2)
35: {
36: this(meta, columnName, new SPropertyValue[]{pval1, pval2});
37: }
38: */
39:
40: /**
41: * Converts from database representation to internal representation
42: */
43: Object queryFieldValue(ResultSet rs, int sqlIndex) throws Exception {
44: return convertDatabaseToBoolean(rs, sqlIndex);
45: }
46:
47: //Object convertToField(Object raw) // In SFieldBoolean
48:
49: Object writeFieldValue(Object value) {
50: if (((Boolean) value).booleanValue())
51: return TRUE_VALUE;
52: else
53: return FALSE_VALUE;
54: }
55:
56: /** Specializes SFieldMeta. */
57: String defaultDataType() {
58: return "CHAR";
59: }
60: }
|