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: ParameterSetter.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.PreparedStatement;
16:
17: class ParameterSetter extends AbstractFieldManager {
18: private final PersistenceManager pm;
19: private final PreparedStatement ps;
20: private final ColumnMapping[] mappings;
21: private final int[] paramNumbersByField;
22:
23: public ParameterSetter(PersistenceManager pm, PreparedStatement ps,
24: ColumnMapping[] mappings, int[] paramNumbersByField) {
25: this .pm = pm;
26: this .ps = ps;
27: this .mappings = mappings;
28: this .paramNumbersByField = paramNumbersByField;
29: }
30:
31: public void storeBooleanField(int fieldNumber, boolean value) {
32: mappings[fieldNumber].setBoolean(pm, ps,
33: paramNumbersByField[fieldNumber], value);
34: }
35:
36: public void storeCharField(int fieldNumber, char value) {
37: mappings[fieldNumber].setChar(pm, ps,
38: paramNumbersByField[fieldNumber], value);
39: }
40:
41: public void storeByteField(int fieldNumber, byte value) {
42: mappings[fieldNumber].setByte(pm, ps,
43: paramNumbersByField[fieldNumber], value);
44: }
45:
46: public void storeShortField(int fieldNumber, short value) {
47: mappings[fieldNumber].setShort(pm, ps,
48: paramNumbersByField[fieldNumber], value);
49: }
50:
51: public void storeIntField(int fieldNumber, int value) {
52: mappings[fieldNumber].setInt(pm, ps,
53: paramNumbersByField[fieldNumber], value);
54: }
55:
56: public void storeLongField(int fieldNumber, long value) {
57: mappings[fieldNumber].setLong(pm, ps,
58: paramNumbersByField[fieldNumber], value);
59: }
60:
61: public void storeFloatField(int fieldNumber, float value) {
62: mappings[fieldNumber].setFloat(pm, ps,
63: paramNumbersByField[fieldNumber], value);
64: }
65:
66: public void storeDoubleField(int fieldNumber, double value) {
67: mappings[fieldNumber].setDouble(pm, ps,
68: paramNumbersByField[fieldNumber], value);
69: }
70:
71: public void storeStringField(int fieldNumber, String value) {
72: mappings[fieldNumber].setString(pm, ps,
73: paramNumbersByField[fieldNumber], value);
74: }
75:
76: public void storeObjectField(int fieldNumber, Object value) {
77: mappings[fieldNumber].setObject(pm, ps,
78: paramNumbersByField[fieldNumber], value);
79: }
80: }
|