summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060518/java/das/rdb/src/main/java/org/apache/tuscany/das/rdb/Command.java
blob: 37d67fd10c1e8047ae00bbea307af123db20794f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/**
 *
 *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.tuscany.das.rdb;

import java.sql.Connection;

import org.apache.tuscany.das.rdb.impl.CommandFactoryImpl;

import commonj.sdo.DataObject;
import commonj.sdo.Type;

/**
 * A Command is used to execute a read or write to a database
 * 
 * 
 */
public interface Command {

	public static CommandFactory FACTORY = new CommandFactoryImpl();

	/**
	 * Performs the function defined by the command
	 */
	public void execute();

	/**
	 * Performs the function defined by the command and return the results in
	 * the root DataObject
	 * 
	 * @return the root DataObject
	 */
	public DataObject executeQuery();

	/**
	 * Returns the parameter associated with "name"
	 * 
	 * @param name
	 *            the name of the parameter
	 * @return the associated parameter
	 */
	public Parameter getParameter(String name);

	/**
	 * Returns the Parameter at index
	 * 
	 * @param index
	 *            the index of the Parameter
	 * @return the associated Parameter
	 */
	public Parameter getParameter(int index);

	/**
	 * Sets the value of the named Parameter
	 * 
	 * @param name
	 *            the name of this Parameter
	 * @param value
	 *            the value for the Parameter
	 */
	public void setParameterValue(String name, Object value);

	/**
	 * Sets the value of the associated Parameter
	 * 
	 * @param index
	 *            the index of the Parameter
	 * @param value
	 *            the value for the Parameter
	 */
	public void setParameterValue(int index, Object value);

    /**
     * Sets the "type" of the associated Parameter
     * 
     * @param name
     *            the name of this Parameter
     * @param type
     *            the SDODataTypes-defined "type" for the Parameter.
     */
    public void setParameterType(String string, Type dataType);
     
     /**
     * Sets the "type" of the associated Parameter
     * 
     * @param index
     *            the index of the Parameter
     * @param type
     *            the SDODataTypes-defined "type" for the Parameter.
     */
    public void setParameterType(int index, Type dataType);
    
    /**
	 * Returns the value of the associated Parameter
	 * 
	 * @param name
	 *            the name of the Parameter
	 * @return the value of the Parameter
	 */
	public Object getParameterValue(String name);

	/**
	 * Returns the value of the associated Parameter
	 * 
	 * @param index
	 *            the index of the Parameter
	 * @return the value of the Parameter
	 */
	public Object getParameterValue(int index);

	/**
	 * Adds a Parameter to the command
	 * 
	 * @param index
	 *            the index of the parameter
	 * @param sdoType
	 *            the commonj.sdo.Type of the Parameter
	 */
	public void addParameter(int index, Type sdoType);

	/**
	 * Adds a Parameter to the command
	 * 
	 * @param name
	 *            the index of the parameter
	 * @param sdoType
	 *            the commonj.sdo.Type of the Parameter
	 */
	public void addParameter(String name, Type sdoType);

	/**
	 * Adds a Parameter to the command
	 * 
	 * @param index
	 *            the index of the parameter
	 * @param direction
	 *            the direction of the Parameter. Either Parameter.IN,
	 *            Parameter.OUT or Parameter.INOUT
	 * @param sdoType
	 *            specifies the type as a commonj.sdo.Type from
	 *            {@link SDODataTypes}
	 */
	public void addParameter(int index, int direction, Type sdoType);

	/**
	 * Adds a Parameter to the command
	 * 
	 * @param name
	 *            the name associated with the Parameter
	 * @param direction
	 *            the direction of the Parameter. Either Parameter.IN,
	 *            Parameter.OUT or Parameter.INOUT
	 * @param sdoType
	 *            specifies the type as a commonj.sdo.Type from
	 *            {@link SDODataTypes}
	 */
	public void addParameter(String name, int direction, Type sdoType);

	/**
	 * Specifies an object model for a graph of DataObjects returned by
	 * #executeQuery()
	 * 
	 * @param schema
	 *            the model as a commonj.sdo.Type
	 */
	public void setDataObjectModel(Type schema);

	/**
	 * Defines the structure of the ResultSet returned by the JDBC Driver when
	 * this command is executed. If the shape is not specified then the shape is
	 * taken from the ResultSetMetatadta instance provided by the JDBC Driver.
	 * <p>
	 * This method is prvided primarily to support platforms (such as Oracle)
	 * that do not provide complete support for ResultSetMetadata
	 * 
	 * @param shape
	 *            the specified result set shape
	 * @see ResultSetShape
	 */
	public void setResultSetShape(ResultSetShape shape);

	/**
	 * Provides the java.sql.Connection to be used for this executing this
	 * command.
	 * 
	 * @param connection
	 *            the java.sql.Connection
	 */
	public void setConnection(Connection connection);

	/**
	 * Provides the java.sql.Connection to be used for this executing this
	 * command.
	 * 
	 * @param connection
	 *            the java.sql.Connection
	 * @param manageTransactions
	 *            <code>true</code> if the DAS should perform tx
	 *            commit/rollback
	 */
	public void setConnection(Connection connection, boolean manageTransactions);

	/**
	 * Cleans up and realeases all resources associated with this command. This
	 * should be called when the application is done with this command.
	 */
	public void close();

}