01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: // Copyright (C) 1999 - 2002, Salmon LLC
04: //
05: // This program is free software; you can redistribute it and/or
06: // modify it under the terms of the GNU General Public License version 2
07: // as published by the Free Software Foundation;
08: //
09: // This program is distributed in the hope that it will be useful,
10: // but WITHOUT ANY WARRANTY; without even the implied warranty of
11: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: // GNU General Public License for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // along with this program; if not, write to the Free Software
16: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: // For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20: package com.salmonllc.sql;
21:
22: /////////////////////////
23: //$Archive: /SOFIA/SourceCode/com/salmonllc/sql/StoredProcedureParms.java $
24: //$Author: Fred $
25: //$Revision: 9 $
26: //$Modtime: 6/24/04 10:52a $
27: /////////////////////////
28:
29: import java.util.*;
30:
31: import com.salmonllc.util.*;
32:
33: /**
34: * This class is used to set parameters to pass to a SQL stored procedure. It should be used in conjunction with one of the data store executeProc methods.
35: */
36: public class StoredProcedureParms {
37: Vector _parms = new Vector();
38:
39: /**
40: * Creates a new StoredProcedureParms instance.
41: */
42: public StoredProcedureParms() {
43: super ();
44: }
45:
46: /**
47: * Use this method to add a new parameter to be passed to the stored procedure. The order that parameters are set must correspond to the parameters in the stored procedure header.
48: * @param parm The parameter to set\
49: * @return StoredProcedureParms - This instance of StoredProcedureParms
50: */
51: public StoredProcedureParms addParm(Object parm) {
52: TwoObjectContainer c = new TwoObjectContainer(parm,
53: new Integer(DataStore.DATATYPE_ANY));
54: _parms.addElement(c);
55: return this ;
56: }
57:
58: /**
59: * Use this method to add a new parameter to the stored procedure. The order that parameters are set must correspond to the parameters in the stored procedure header.
60: * @param parm The parameter to set
61: * @param dataType The dataType of the parameter. Valid values are all the DATATYPE constants in the data store;
62: * @return StoredProcedureParms - This instance of StoredProcedureParms
63: */
64: public StoredProcedureParms addParm(Object parm, int dataType) {
65: TwoObjectContainer c = new TwoObjectContainer(parm,
66: new Integer(dataType));
67: _parms.addElement(c);
68: return this ;
69: }
70:
71: int getDataType(int index) {
72: TwoObjectContainer cont = (TwoObjectContainer) _parms
73: .elementAt(index);
74: return ((Integer) cont.getObject2()).intValue();
75: }
76:
77: Object getParm(int index) {
78: TwoObjectContainer cont = (TwoObjectContainer) _parms
79: .elementAt(index);
80: return cont.getObject1();
81:
82: }
83:
84: int getParmCount() {
85: return _parms.size();
86: }
87:
88: /**
89: * Use this method to clear all the parameters in the object.
90: */
91: public void reset() {
92: _parms.removeAllElements();
93: }
94: }
|