01: package simpleorm.core;
02:
03: import simpleorm.properties.*;
04: import java.sql.ResultSet;
05:
06: /** Represents Bytes field meta data. Ie. Just a byte array.
07: * Note that thisis just for relatively short strings, see Blob. */
08:
09: public class SFieldBytes extends SFieldScalar {
10: public SFieldBytes(SRecordMeta meta, String columnName,
11: int maxSize, SPropertyValue[] pvals) {
12: super (meta, columnName, pvals);
13: putProperty(SCon.SBYTE_SIZE, SJSharp.newInteger(maxSize)); // for Create Table only.
14: }
15:
16: public SFieldBytes(SRecordMeta meta, String columnName, int maxSize) {
17: this (meta, columnName, maxSize, new SPropertyValue[0]);
18: }
19:
20: public SFieldBytes(SRecordMeta meta, String columnName,
21: int maxSize, SPropertyValue pval) {
22: this (meta, columnName, maxSize, new SPropertyValue[] { pval });
23: }
24:
25: public SFieldBytes(SRecordMeta meta, String columnName,
26: int maxSize, SPropertyValue pval1, SPropertyValue pval2) {
27: this (meta, columnName, maxSize, new SPropertyValue[] { pval1,
28: pval2 });
29: }
30:
31: /** Abstract specializer. Clone this key field to be a foreign key
32: to <code>rmeta</code> of the same type.*/
33: SFieldMeta makeForeignKey(SRecordMeta rmeta, String prefix,
34: SPropertyValue[] pvals) {
35: return new SFieldBytes(rmeta, (prefix == null ? "" : prefix)
36: + getString(SCon.SCOLUMN_NAME), SJSharp
37: .object2Int(getProperty(SCon.SBYTE_SIZE)), pvals);
38: }
39:
40: Object queryFieldValue(ResultSet rs, int sqlIndex) throws Exception {
41: Object res = rs.getBytes(sqlIndex);
42: return res;
43: }
44:
45: Object convertToField(Object raw) {
46: return raw;
47: }
48:
49: /** Specializes SFieldMeta. */
50: String defaultDataType() {
51: return "BYTES";
52: }
53:
54: }
|