1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package ifc.sdbc;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import java.util.Vector;
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir import lib.MultiMethodTest;
33*cdf0e10cSrcweir import lib.Status;
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir import com.sun.star.io.XDataInputStream;
36*cdf0e10cSrcweir import com.sun.star.io.XInputStream;
37*cdf0e10cSrcweir import com.sun.star.io.XTextInputStream;
38*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
39*cdf0e10cSrcweir import com.sun.star.sdbc.DataType;
40*cdf0e10cSrcweir import com.sun.star.sdbc.SQLException;
41*cdf0e10cSrcweir import com.sun.star.sdbc.XParameters;
42*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
43*cdf0e10cSrcweir import com.sun.star.util.Date;
44*cdf0e10cSrcweir import com.sun.star.util.DateTime;
45*cdf0e10cSrcweir import com.sun.star.util.Time;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir /**
48*cdf0e10cSrcweir /**
49*cdf0e10cSrcweir * Testing <code>com.sun.star.sdbc.XParameters</code>
50*cdf0e10cSrcweir * interface methods :
51*cdf0e10cSrcweir * <ul>
52*cdf0e10cSrcweir *  <li><code> setNull()</code></li>
53*cdf0e10cSrcweir *  <li><code> setObjectNull()</code></li>
54*cdf0e10cSrcweir *  <li><code> setBoolean()</code></li>
55*cdf0e10cSrcweir *  <li><code> setByte()</code></li>
56*cdf0e10cSrcweir *  <li><code> setShort()</code></li>
57*cdf0e10cSrcweir *  <li><code> setInt()</code></li>
58*cdf0e10cSrcweir *  <li><code> setLong()</code></li>
59*cdf0e10cSrcweir *  <li><code> setFloat()</code></li>
60*cdf0e10cSrcweir *  <li><code> setDouble()</code></li>
61*cdf0e10cSrcweir *  <li><code> setString()</code></li>
62*cdf0e10cSrcweir *  <li><code> setBytes()</code></li>
63*cdf0e10cSrcweir *  <li><code> setDate()</code></li>
64*cdf0e10cSrcweir *  <li><code> setTime()</code></li>
65*cdf0e10cSrcweir *  <li><code> setTimestamp()</code></li>
66*cdf0e10cSrcweir *  <li><code> setBinaryStream()</code></li>
67*cdf0e10cSrcweir *  <li><code> setCharacterStream()</code></li>
68*cdf0e10cSrcweir *  <li><code> setObject()</code></li>
69*cdf0e10cSrcweir *  <li><code> setObjectWithInfo()</code></li>
70*cdf0e10cSrcweir *  <li><code> setRef()</code></li>
71*cdf0e10cSrcweir *  <li><code> setBlob()</code></li>
72*cdf0e10cSrcweir *  <li><code> setClob()</code></li>
73*cdf0e10cSrcweir *  <li><code> setArray()</code></li>
74*cdf0e10cSrcweir *  <li><code> clearParameters()</code></li>
75*cdf0e10cSrcweir * </ul> <p>
76*cdf0e10cSrcweir * Object relations required :
77*cdf0e10cSrcweir * <ul>
78*cdf0e10cSrcweir * <li> <code>'XParameters.ParamValues'</code> :  is a
79*cdf0e10cSrcweir * <code>java.util.Vector</code> object
80*cdf0e10cSrcweir * that contains parameter types and values of the statement. Each
81*cdf0e10cSrcweir * element of vector corresponds to appropriate parameter (element
82*cdf0e10cSrcweir * with index 0 to parameter #1, 1 -> #2, etc.). <p>
83*cdf0e10cSrcweir * The following <code>XParameters</code> methods correspond to classes
84*cdf0e10cSrcweir * in Vector :
85*cdf0e10cSrcweir * <ul>
86*cdf0e10cSrcweir *   <li> <code>setBinaryStream</code> -
87*cdf0e10cSrcweir *        <code>com.sun.star.io.XDataInputStream</code> class. </li>
88*cdf0e10cSrcweir *   <li> <code>setCharacterStream</code> -
89*cdf0e10cSrcweir *        <code>com.sun.star.io.XTextInputStream</code> class. </li>
90*cdf0e10cSrcweir *   <li> <code>setObject</code> -
91*cdf0e10cSrcweir *        <code>java.lang.Object[]</code> class, the element with
92*cdf0e10cSrcweir *         index 0 must be used. </li>
93*cdf0e10cSrcweir * </ul>
94*cdf0e10cSrcweir * Other methods uses types of their arguments (i.e.
95*cdf0e10cSrcweir * <code>java.lang.String</code>
96*cdf0e10cSrcweir * for <code>setString</code> method, <code>com.sun.star.sdbc.XRef</code>
97*cdf0e10cSrcweir * for <code>setRef</code> method).
98*cdf0e10cSrcweir * </li>
99*cdf0e10cSrcweir * </ul>
100*cdf0e10cSrcweir * @see com.sun.star.sdbc.XParameters
101*cdf0e10cSrcweir */
102*cdf0e10cSrcweir public class _XParameters extends MultiMethodTest {
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     // oObj filled by MultiMethodTest
105*cdf0e10cSrcweir     public XParameters oObj = null ;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     private Vector data = null ;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     /**
110*cdf0e10cSrcweir     * Gets object relation
111*cdf0e10cSrcweir     */
112*cdf0e10cSrcweir     public void before() {
113*cdf0e10cSrcweir         data = (Vector) tEnv.getObjRelation("XParameters.ParamValues") ;
114*cdf0e10cSrcweir         if (data == null) {
115*cdf0e10cSrcweir             log.println("!!! Relation not found !!!") ;
116*cdf0e10cSrcweir         }
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     /**
120*cdf0e10cSrcweir     * Sets String parameter (if exists) to SQL NULL value. <p>
121*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
122*cdf0e10cSrcweir     */
123*cdf0e10cSrcweir     public void _setNull() {
124*cdf0e10cSrcweir         boolean result = true ;
125*cdf0e10cSrcweir         int idx = findParamOfType(String.class) ;
126*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
127*cdf0e10cSrcweir         else {
128*cdf0e10cSrcweir             try {
129*cdf0e10cSrcweir                 oObj.setNull(idx, DataType.VARCHAR) ;
130*cdf0e10cSrcweir             } catch (SQLException e) {
131*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
132*cdf0e10cSrcweir                 log.println(e) ;
133*cdf0e10cSrcweir                 result = false ;
134*cdf0e10cSrcweir             }
135*cdf0e10cSrcweir         }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         tRes.tested("setNull()", result) ;
138*cdf0e10cSrcweir     }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     public void _setObjectNull() {
141*cdf0e10cSrcweir         /*
142*cdf0e10cSrcweir             !!! TO DO !!!
143*cdf0e10cSrcweir         */
144*cdf0e10cSrcweir         tRes.tested("setObjectNull()", Status.skipped(true)) ;
145*cdf0e10cSrcweir     }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     /**
148*cdf0e10cSrcweir     * Sets String parameter (if exists) to new value. <p>
149*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
150*cdf0e10cSrcweir     */
151*cdf0e10cSrcweir     public void _setString() {
152*cdf0e10cSrcweir         boolean result = true ;
153*cdf0e10cSrcweir         int idx = findParamOfType(String.class) ;
154*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
155*cdf0e10cSrcweir         else {
156*cdf0e10cSrcweir             try {
157*cdf0e10cSrcweir                 oObj.setString(idx, "XParameters") ;
158*cdf0e10cSrcweir             } catch (SQLException e) {
159*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
160*cdf0e10cSrcweir                 log.println(e) ;
161*cdf0e10cSrcweir                 result = false ;
162*cdf0e10cSrcweir             }
163*cdf0e10cSrcweir         }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         tRes.tested("setString()", result) ;
166*cdf0e10cSrcweir     }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     /**
169*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
170*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
171*cdf0e10cSrcweir     */
172*cdf0e10cSrcweir     public void _setBoolean() {
173*cdf0e10cSrcweir         boolean result = true ;
174*cdf0e10cSrcweir         int idx = findParamOfType(Boolean.class) ;
175*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
176*cdf0e10cSrcweir         else {
177*cdf0e10cSrcweir             try {
178*cdf0e10cSrcweir                 oObj.setBoolean(idx, true) ;
179*cdf0e10cSrcweir             } catch (SQLException e) {
180*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
181*cdf0e10cSrcweir                 log.println(e) ;
182*cdf0e10cSrcweir                 result = false ;
183*cdf0e10cSrcweir             }
184*cdf0e10cSrcweir         }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         tRes.tested("setBoolean()", result) ;
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     /**
190*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
191*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
192*cdf0e10cSrcweir     */
193*cdf0e10cSrcweir     public void _setByte() {
194*cdf0e10cSrcweir         boolean result = true ;
195*cdf0e10cSrcweir         int idx = findParamOfType(Byte.class) ;
196*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
197*cdf0e10cSrcweir         else {
198*cdf0e10cSrcweir             try {
199*cdf0e10cSrcweir                 oObj.setByte(idx, (byte)122) ;
200*cdf0e10cSrcweir             } catch (SQLException e) {
201*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
202*cdf0e10cSrcweir                 log.println(e) ;
203*cdf0e10cSrcweir                 result = false ;
204*cdf0e10cSrcweir             }
205*cdf0e10cSrcweir         }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         tRes.tested("setByte()", result) ;
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     /**
211*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
212*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
213*cdf0e10cSrcweir     */
214*cdf0e10cSrcweir     public void _setShort() {
215*cdf0e10cSrcweir         boolean result = true ;
216*cdf0e10cSrcweir         int idx = findParamOfType(Short.class) ;
217*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
218*cdf0e10cSrcweir         else {
219*cdf0e10cSrcweir             try {
220*cdf0e10cSrcweir                 oObj.setShort(idx, (short)133) ;
221*cdf0e10cSrcweir             } catch (SQLException e) {
222*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
223*cdf0e10cSrcweir                 log.println(e) ;
224*cdf0e10cSrcweir                 result = false ;
225*cdf0e10cSrcweir             }
226*cdf0e10cSrcweir         }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir         tRes.tested("setShort()", result) ;
229*cdf0e10cSrcweir     }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir     /**
232*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
233*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
234*cdf0e10cSrcweir     */
235*cdf0e10cSrcweir     public void _setInt() {
236*cdf0e10cSrcweir         boolean result = true ;
237*cdf0e10cSrcweir         int idx = findParamOfType(Integer.class) ;
238*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
239*cdf0e10cSrcweir         else {
240*cdf0e10cSrcweir             try {
241*cdf0e10cSrcweir                 oObj.setInt(idx, 13300) ;
242*cdf0e10cSrcweir             } catch (SQLException e) {
243*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
244*cdf0e10cSrcweir                 log.println(e) ;
245*cdf0e10cSrcweir                 result = false ;
246*cdf0e10cSrcweir             }
247*cdf0e10cSrcweir         }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         tRes.tested("setInt()", result) ;
250*cdf0e10cSrcweir     }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir     /**
253*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
254*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
255*cdf0e10cSrcweir     */
256*cdf0e10cSrcweir     public void _setLong() {
257*cdf0e10cSrcweir         boolean result = true ;
258*cdf0e10cSrcweir         int idx = findParamOfType(Long.class) ;
259*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
260*cdf0e10cSrcweir         else {
261*cdf0e10cSrcweir             try {
262*cdf0e10cSrcweir                 oObj.setLong(idx, 13362453) ;
263*cdf0e10cSrcweir             } catch (SQLException e) {
264*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
265*cdf0e10cSrcweir                 log.println(e) ;
266*cdf0e10cSrcweir                 result = false ;
267*cdf0e10cSrcweir             }
268*cdf0e10cSrcweir         }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir         tRes.tested("setLong()", result) ;
271*cdf0e10cSrcweir     }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir     /**
274*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
275*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
276*cdf0e10cSrcweir     */
277*cdf0e10cSrcweir     public void _setFloat() {
278*cdf0e10cSrcweir         boolean result = true ;
279*cdf0e10cSrcweir         int idx = findParamOfType(Float.class) ;
280*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
281*cdf0e10cSrcweir         else {
282*cdf0e10cSrcweir             try {
283*cdf0e10cSrcweir                 oObj.setFloat(idx, (float)133.55) ;
284*cdf0e10cSrcweir             } catch (SQLException e) {
285*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
286*cdf0e10cSrcweir                 log.println(e) ;
287*cdf0e10cSrcweir                 result = false ;
288*cdf0e10cSrcweir             }
289*cdf0e10cSrcweir         }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir         tRes.tested("setFloat()", result) ;
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir     /**
295*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
296*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
297*cdf0e10cSrcweir     */
298*cdf0e10cSrcweir     public void _setDouble() {
299*cdf0e10cSrcweir         boolean result = true ;
300*cdf0e10cSrcweir         int idx = findParamOfType(Double.class) ;
301*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
302*cdf0e10cSrcweir         else {
303*cdf0e10cSrcweir             try {
304*cdf0e10cSrcweir                 oObj.setDouble(idx, 133) ;
305*cdf0e10cSrcweir             } catch (SQLException e) {
306*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
307*cdf0e10cSrcweir                 log.println(e) ;
308*cdf0e10cSrcweir                 result = false ;
309*cdf0e10cSrcweir             }
310*cdf0e10cSrcweir         }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir         tRes.tested("setDouble()", result) ;
313*cdf0e10cSrcweir     }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     /**
316*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
317*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
318*cdf0e10cSrcweir     */
319*cdf0e10cSrcweir     public void _setBytes() {
320*cdf0e10cSrcweir         boolean result = true ;
321*cdf0e10cSrcweir         int idx = findParamOfType(byte[].class) ;
322*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
323*cdf0e10cSrcweir         else {
324*cdf0e10cSrcweir             try {
325*cdf0e10cSrcweir                 oObj.setBytes(idx, new byte[] {5}) ;
326*cdf0e10cSrcweir             } catch (SQLException e) {
327*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
328*cdf0e10cSrcweir                 log.println(e) ;
329*cdf0e10cSrcweir                 result = false ;
330*cdf0e10cSrcweir             }
331*cdf0e10cSrcweir         }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         tRes.tested("setBytes()", result) ;
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     /**
337*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
338*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
339*cdf0e10cSrcweir     */
340*cdf0e10cSrcweir     public void _setDate() {
341*cdf0e10cSrcweir         boolean result = true ;
342*cdf0e10cSrcweir         int idx = findParamOfType(Date.class) ;
343*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
344*cdf0e10cSrcweir         else {
345*cdf0e10cSrcweir             try {
346*cdf0e10cSrcweir                 oObj.setDate(
347*cdf0e10cSrcweir                     idx, new Date ((short)19, (short)01, (short)1979)) ;
348*cdf0e10cSrcweir             } catch (SQLException e) {
349*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
350*cdf0e10cSrcweir                 log.println(e) ;
351*cdf0e10cSrcweir                 result = false ;
352*cdf0e10cSrcweir             }
353*cdf0e10cSrcweir         }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         tRes.tested("setDate()", result) ;
356*cdf0e10cSrcweir     }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir     /**
359*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
360*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
361*cdf0e10cSrcweir     */
362*cdf0e10cSrcweir     public void _setTime() {
363*cdf0e10cSrcweir         boolean result = true ;
364*cdf0e10cSrcweir         int idx = findParamOfType(Time.class) ;
365*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
366*cdf0e10cSrcweir         else {
367*cdf0e10cSrcweir             try {
368*cdf0e10cSrcweir                 oObj.setTime(
369*cdf0e10cSrcweir                     idx, new Time((short)1,(short)2,(short)3,(short)44)) ;
370*cdf0e10cSrcweir             } catch (SQLException e) {
371*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
372*cdf0e10cSrcweir                 log.println(e) ;
373*cdf0e10cSrcweir                 result = false ;
374*cdf0e10cSrcweir             }
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir         tRes.tested("setTime()", result) ;
378*cdf0e10cSrcweir     }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     /**
381*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
382*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
383*cdf0e10cSrcweir     */
384*cdf0e10cSrcweir     public void _setTimestamp() {
385*cdf0e10cSrcweir         boolean result = true ;
386*cdf0e10cSrcweir         int idx = findParamOfType(DateTime.class) ;
387*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
388*cdf0e10cSrcweir         else {
389*cdf0e10cSrcweir             try {
390*cdf0e10cSrcweir                 oObj.setTimestamp(idx, new DateTime((short)1,(short)2,(short)3,
391*cdf0e10cSrcweir                     (short)4, (short)19, (short)01, (short)1979)) ;
392*cdf0e10cSrcweir             } catch (SQLException e) {
393*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
394*cdf0e10cSrcweir                 log.println(e) ;
395*cdf0e10cSrcweir                 result = false ;
396*cdf0e10cSrcweir             }
397*cdf0e10cSrcweir         }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         tRes.tested("setTimestamp()", result) ;
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     /**
403*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
404*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
405*cdf0e10cSrcweir     */
406*cdf0e10cSrcweir     public void _setBinaryStream() {
407*cdf0e10cSrcweir         boolean result = true ;
408*cdf0e10cSrcweir         int idx = findParamOfType(XDataInputStream.class) ;
409*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
410*cdf0e10cSrcweir         else {
411*cdf0e10cSrcweir             try {
412*cdf0e10cSrcweir                 Object oStream = ((XMultiServiceFactory)tParam.getMSF()).
413*cdf0e10cSrcweir                         createInstance("com.sun.star.io.DataInputStream") ;
414*cdf0e10cSrcweir                 XInputStream xStream = (XInputStream)UnoRuntime.queryInterface
415*cdf0e10cSrcweir                     (XInputStream.class, oStream);
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir                 oObj.setBinaryStream(idx, xStream, 2) ;
418*cdf0e10cSrcweir             } catch (SQLException e) {
419*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
420*cdf0e10cSrcweir                 log.println(e) ;
421*cdf0e10cSrcweir                 result = false ;
422*cdf0e10cSrcweir             } catch (com.sun.star.uno.Exception e) {
423*cdf0e10cSrcweir                 log.println("Unexpected exception:") ;
424*cdf0e10cSrcweir                 log.println(e) ;
425*cdf0e10cSrcweir                 result = false ;
426*cdf0e10cSrcweir             }
427*cdf0e10cSrcweir         }
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir         tRes.tested("setBinaryStream()", result) ;
430*cdf0e10cSrcweir     }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir     /**
433*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
434*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
435*cdf0e10cSrcweir     */
436*cdf0e10cSrcweir     public void _setCharacterStream() {
437*cdf0e10cSrcweir         boolean result = true ;
438*cdf0e10cSrcweir         int idx = findParamOfType(XTextInputStream.class) ;
439*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
440*cdf0e10cSrcweir         else {
441*cdf0e10cSrcweir             try {
442*cdf0e10cSrcweir                 Object oStream = ((XMultiServiceFactory)tParam.getMSF())
443*cdf0e10cSrcweir                         .createInstance("com.sun.star.io.TextInputStream") ;
444*cdf0e10cSrcweir                 XInputStream xStream = (XInputStream)UnoRuntime.queryInterface
445*cdf0e10cSrcweir                     (XInputStream.class, oStream);
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir                 oObj.setCharacterStream(idx, xStream, 2) ;
448*cdf0e10cSrcweir             } catch (SQLException e) {
449*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
450*cdf0e10cSrcweir                 log.println(e) ;
451*cdf0e10cSrcweir                 result = false ;
452*cdf0e10cSrcweir             } catch (com.sun.star.uno.Exception e) {
453*cdf0e10cSrcweir                 log.println("Unexpected exception:") ;
454*cdf0e10cSrcweir                 log.println(e) ;
455*cdf0e10cSrcweir                 result = false ;
456*cdf0e10cSrcweir             }
457*cdf0e10cSrcweir         }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir         tRes.tested("setCharacterStream()", result) ;
460*cdf0e10cSrcweir     }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir     /**
463*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
464*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
465*cdf0e10cSrcweir     */
466*cdf0e10cSrcweir     public void _setObject() {
467*cdf0e10cSrcweir         boolean result = true ;
468*cdf0e10cSrcweir         int idx = findParamOfType(Object[].class) ;
469*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
470*cdf0e10cSrcweir         else {
471*cdf0e10cSrcweir             try {
472*cdf0e10cSrcweir                 Object obj = ((XMultiServiceFactory)tParam.getMSF()).
473*cdf0e10cSrcweir                                 createInstance("com.sun.star.io.Pipe") ;
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir                 oObj.setObject(idx, obj) ;
476*cdf0e10cSrcweir             } catch (SQLException e) {
477*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
478*cdf0e10cSrcweir                 log.println(e) ;
479*cdf0e10cSrcweir                 result = false ;
480*cdf0e10cSrcweir             } catch (com.sun.star.uno.Exception e) {
481*cdf0e10cSrcweir                 log.println("Unexpected exception:") ;
482*cdf0e10cSrcweir                 log.println(e) ;
483*cdf0e10cSrcweir                 result = false ;
484*cdf0e10cSrcweir             }
485*cdf0e10cSrcweir         }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir         tRes.tested("setObject()", result) ;
488*cdf0e10cSrcweir     }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir     /**
491*cdf0e10cSrcweir     * Sets parameter (if exists) to new value. <p>
492*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
493*cdf0e10cSrcweir     */
494*cdf0e10cSrcweir     public void _setObjectWithInfo() {
495*cdf0e10cSrcweir         boolean result = true ;
496*cdf0e10cSrcweir         int idx = findParamOfType(Object[].class) ;
497*cdf0e10cSrcweir         if (idx < 0) log.println("Type not found in relation: not tested");
498*cdf0e10cSrcweir         else {
499*cdf0e10cSrcweir             try {
500*cdf0e10cSrcweir                 Object obj = ((XMultiServiceFactory)tParam.getMSF()).
501*cdf0e10cSrcweir                     createInstance("com.sun.star.io.Pipe") ;
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir                 oObj.setObjectWithInfo(idx, obj, DataType.OBJECT, 0) ;
504*cdf0e10cSrcweir             } catch (SQLException e) {
505*cdf0e10cSrcweir                 log.println("Unexpected SQL exception:") ;
506*cdf0e10cSrcweir                 log.println(e) ;
507*cdf0e10cSrcweir                 result = false ;
508*cdf0e10cSrcweir             } catch (com.sun.star.uno.Exception e) {
509*cdf0e10cSrcweir                 log.println("Unexpected exception:") ;
510*cdf0e10cSrcweir                 log.println(e) ;
511*cdf0e10cSrcweir                 result = false ;
512*cdf0e10cSrcweir             }
513*cdf0e10cSrcweir         }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir         tRes.tested("setObjectWithInfo()", result) ;
516*cdf0e10cSrcweir     }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir     public void _setRef() {
519*cdf0e10cSrcweir         /*
520*cdf0e10cSrcweir             !!! TO DO !!!
521*cdf0e10cSrcweir         */
522*cdf0e10cSrcweir         tRes.tested("setRef()", Status.skipped(true)) ;
523*cdf0e10cSrcweir     }
524*cdf0e10cSrcweir     public void _setBlob() {
525*cdf0e10cSrcweir         /*
526*cdf0e10cSrcweir             !!! TO DO !!!
527*cdf0e10cSrcweir         */
528*cdf0e10cSrcweir         tRes.tested("setBlob()", Status.skipped(true)) ;
529*cdf0e10cSrcweir     }
530*cdf0e10cSrcweir     public void _setClob() {
531*cdf0e10cSrcweir         /*
532*cdf0e10cSrcweir             !!! TO DO !!!
533*cdf0e10cSrcweir         */
534*cdf0e10cSrcweir         tRes.tested("setClob()", Status.skipped(true)) ;
535*cdf0e10cSrcweir     }
536*cdf0e10cSrcweir     public void _setArray() {
537*cdf0e10cSrcweir         /*
538*cdf0e10cSrcweir             !!! TO DO !!!
539*cdf0e10cSrcweir         */
540*cdf0e10cSrcweir         tRes.tested("setArray()", Status.skipped(true)) ;
541*cdf0e10cSrcweir     }
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir     /**
544*cdf0e10cSrcweir     * Calls method. <p>
545*cdf0e10cSrcweir     * Has OK status if no exceptions occured.
546*cdf0e10cSrcweir     */
547*cdf0e10cSrcweir     public void _clearParameters() {
548*cdf0e10cSrcweir         boolean result = true ;
549*cdf0e10cSrcweir         try {
550*cdf0e10cSrcweir             oObj.clearParameters() ;
551*cdf0e10cSrcweir         } catch (SQLException e) {
552*cdf0e10cSrcweir             log.println("Unexpected SQL exception:") ;
553*cdf0e10cSrcweir             log.println(e) ;
554*cdf0e10cSrcweir             result = false ;
555*cdf0e10cSrcweir         }
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir         tRes.tested("clearParameters()", result) ;
558*cdf0e10cSrcweir     }
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     /**
562*cdf0e10cSrcweir     * Finds in relation vector index of parameter of the appropriate
563*cdf0e10cSrcweir     * type.
564*cdf0e10cSrcweir     */
565*cdf0e10cSrcweir     private int findParamOfType(Class clz) {
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir         for (int i = 0; i < data.size(); i++)
568*cdf0e10cSrcweir             if (clz.isInstance(data.get(i))) return i + 1 ;
569*cdf0e10cSrcweir         return -1 ;
570*cdf0e10cSrcweir     }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir }  // finish class _XParameters
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir 
575