KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > ResultSetGetter


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: ResultSetGetter.java,v 1.3 2004/01/18 03:01:06 jackknifebarber Exp $
9  */

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 JavaDoc;
16
17
18 class ResultSetGetter extends AbstractFieldManager
19 {
20     private final PersistenceManager pm;
21     private final ResultSet JavaDoc rs;
22     private final ColumnMapping[] mappings;
23     private final int[] columnNumbersByField;
24
25     public ResultSetGetter(PersistenceManager pm,
26                            ResultSet JavaDoc rs,
27                            ColumnMapping[] mappings,
28                            int[] columnNumbersByField)
29     {
30         this.pm = pm;
31         this.rs = rs;
32         this.mappings = mappings;
33         this.columnNumbersByField = columnNumbersByField;
34     }
35
36     public boolean fetchBooleanField(int fieldNumber)
37     {
38         return mappings[fieldNumber].getBoolean(pm, rs, columnNumbersByField[fieldNumber]);
39     }
40
41     public char fetchCharField(int fieldNumber)
42     {
43         return mappings[fieldNumber].getChar(pm, rs, columnNumbersByField[fieldNumber]);
44     }
45
46     public byte fetchByteField(int fieldNumber)
47     {
48         return mappings[fieldNumber].getByte(pm, rs, columnNumbersByField[fieldNumber]);
49     }
50
51     public short fetchShortField(int fieldNumber)
52     {
53         return mappings[fieldNumber].getShort(pm, rs, columnNumbersByField[fieldNumber]);
54     }
55
56     public int fetchIntField(int fieldNumber)
57     {
58         return mappings[fieldNumber].getInt(pm, rs, columnNumbersByField[fieldNumber]);
59     }
60
61     public long fetchLongField(int fieldNumber)
62     {
63         return mappings[fieldNumber].getLong(pm, rs, columnNumbersByField[fieldNumber]);
64     }
65
66     public float fetchFloatField(int fieldNumber)
67     {
68         return mappings[fieldNumber].getFloat(pm, rs, columnNumbersByField[fieldNumber]);
69     }
70
71     public double fetchDoubleField(int fieldNumber)
72     {
73         return mappings[fieldNumber].getDouble(pm, rs, columnNumbersByField[fieldNumber]);
74     }
75
76     public String JavaDoc fetchStringField(int fieldNumber)
77     {
78         return mappings[fieldNumber].getString(pm, rs, columnNumbersByField[fieldNumber]);
79     }
80
81     public Object JavaDoc fetchObjectField(int fieldNumber)
82     {
83         return mappings[fieldNumber].getObject(pm, rs, columnNumbersByField[fieldNumber]);
84     }
85 }
86
Popular Tags