01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: ResultSetGetter.java,v 1.3 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.AbstractFieldManager;
14: import com.triactive.jdo.PersistenceManager;
15: import java.sql.ResultSet;
16:
17: class ResultSetGetter extends AbstractFieldManager {
18: private final PersistenceManager pm;
19: private final ResultSet rs;
20: private final ColumnMapping[] mappings;
21: private final int[] columnNumbersByField;
22:
23: public ResultSetGetter(PersistenceManager pm, ResultSet rs,
24: ColumnMapping[] mappings, int[] columnNumbersByField) {
25: this .pm = pm;
26: this .rs = rs;
27: this .mappings = mappings;
28: this .columnNumbersByField = columnNumbersByField;
29: }
30:
31: public boolean fetchBooleanField(int fieldNumber) {
32: return mappings[fieldNumber].getBoolean(pm, rs,
33: columnNumbersByField[fieldNumber]);
34: }
35:
36: public char fetchCharField(int fieldNumber) {
37: return mappings[fieldNumber].getChar(pm, rs,
38: columnNumbersByField[fieldNumber]);
39: }
40:
41: public byte fetchByteField(int fieldNumber) {
42: return mappings[fieldNumber].getByte(pm, rs,
43: columnNumbersByField[fieldNumber]);
44: }
45:
46: public short fetchShortField(int fieldNumber) {
47: return mappings[fieldNumber].getShort(pm, rs,
48: columnNumbersByField[fieldNumber]);
49: }
50:
51: public int fetchIntField(int fieldNumber) {
52: return mappings[fieldNumber].getInt(pm, rs,
53: columnNumbersByField[fieldNumber]);
54: }
55:
56: public long fetchLongField(int fieldNumber) {
57: return mappings[fieldNumber].getLong(pm, rs,
58: columnNumbersByField[fieldNumber]);
59: }
60:
61: public float fetchFloatField(int fieldNumber) {
62: return mappings[fieldNumber].getFloat(pm, rs,
63: columnNumbersByField[fieldNumber]);
64: }
65:
66: public double fetchDoubleField(int fieldNumber) {
67: return mappings[fieldNumber].getDouble(pm, rs,
68: columnNumbersByField[fieldNumber]);
69: }
70:
71: public String fetchStringField(int fieldNumber) {
72: return mappings[fieldNumber].getString(pm, rs,
73: columnNumbersByField[fieldNumber]);
74: }
75:
76: public Object fetchObjectField(int fieldNumber) {
77: return mappings[fieldNumber].getObject(pm, rs,
78: columnNumbersByField[fieldNumber]);
79: }
80: }
|