01: /*
02: * Created on Jan 18, 2005
03: * Author dhristodorescu
04: * Borderfree
05: */
06: package simpleorm.core;
07:
08: import java.sql.ResultSet;
09:
10: import simpleorm.properties.SPropertyValue;
11:
12: /**
13: * @author dhristodorescu
14: * Borderfree
15: */
16: public class SFieldBooleanBit extends SFieldBoolean {
17:
18: public SFieldBooleanBit(SRecordMeta meta, String columnName,
19: SPropertyValue[] pvals) {
20: super (meta, columnName, pvals);
21: }
22:
23: public SFieldBooleanBit(SRecordMeta meta, String columnName) {
24: this (meta, columnName, new SPropertyValue[0]);
25: }
26:
27: public SFieldBooleanBit(SRecordMeta meta, String columnName,
28: SPropertyValue pval) {
29: this (meta, columnName, new SPropertyValue[] { pval });
30: }
31:
32: public SFieldBooleanBit(SRecordMeta meta, String columnName,
33: SPropertyValue pval1, SPropertyValue pval2) {
34: this (meta, columnName, new SPropertyValue[] { pval1, pval2 });
35: }
36:
37: /** Abstract specializer. Clone this key field to be a foreign key
38: to <code>rmeta</code> of the same type.*/
39: SFieldMeta makeForeignKey(SRecordMeta rmeta, String prefix,
40: SPropertyValue[] pvals) {
41: return new SFieldBooleanBit(rmeta, (prefix == null ? ""
42: : prefix)
43: + getString(SCon.SCOLUMN_NAME), pvals);
44: }
45:
46: /**
47: * Converts from database representation to internal representation
48: */
49: Object queryFieldValue(ResultSet rs, int sqlIndex) throws Exception {
50: return rs.getBoolean(sqlIndex) ? Boolean.TRUE : Boolean.FALSE;
51: }
52:
53: /** Specializes SFieldMeta. */
54: String defaultDataType() {
55: return "BIT"; // For MS SQL.
56: }
57: }
|