1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CONNECTIVITY_OBOUNPARAM_HXX_ 28 #define _CONNECTIVITY_OBOUNPARAM_HXX_ 29 30 #include <com/sun/star/io/XInputStream.hpp> 31 #include "odbc/odbcbasedllapi.hxx" 32 33 namespace connectivity 34 { 35 namespace odbc 36 { 37 class OOO_DLLPUBLIC_ODBCBASE OBoundParam 38 { 39 40 public: 41 OBoundParam() 42 { 43 paramLength = NULL; 44 binaryData = NULL; 45 pA1=0; 46 pA2=0; 47 pB1=0; 48 pB2=0; 49 pC1=0; 50 pC2=0; 51 pS1=0; 52 pS2=0; 53 } 54 ~OBoundParam() 55 { 56 delete [] binaryData; 57 delete [] paramLength; 58 } 59 //-------------------------------------------------------------------- 60 // initialize 61 // Perform an necessary initialization 62 //-------------------------------------------------------------------- 63 void initialize () 64 { 65 // Allocate storage for the length. Note - the length is 66 // stored in native format, and will have to be converted 67 // to a Java sal_Int32. The jdbcodbc 'C' bridge provides an 68 // interface to do this. 69 70 paramLength = new sal_Int8[4]; 71 } 72 73 //-------------------------------------------------------------------- 74 // allocBindDataBuffer 75 // Allocates and returns a new bind data buffer of the specified 76 // length 77 //-------------------------------------------------------------------- 78 sal_Int8* allocBindDataBuffer (sal_Int32 bufLen) 79 { 80 if ( binaryData ) 81 delete [] binaryData; 82 binaryData = new sal_Int8[bufLen]; 83 84 // Reset the input stream, we are doing a new bind 85 setInputStream (NULL, 0); 86 87 return binaryData; 88 } 89 90 //-------------------------------------------------------------------- 91 // getBindDataBuffer 92 // Returns the data buffer to be used when binding to a parameter 93 //-------------------------------------------------------------------- 94 sal_Int8* getBindDataBuffer () 95 { 96 return binaryData; 97 } 98 99 //-------------------------------------------------------------------- 100 // getBindLengthBuffer 101 // Returns the length buffer to be used when binding to a parameter 102 //-------------------------------------------------------------------- 103 sal_Int8* getBindLengthBuffer () 104 { 105 return paramLength; 106 } 107 108 //-------------------------------------------------------------------- 109 // setInputStream 110 // Sets the input stream for the bound parameter 111 //-------------------------------------------------------------------- 112 void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream, 113 sal_Int32 len) 114 { 115 paramInputStream = inputStream; 116 paramInputStreamLen = len; 117 } 118 119 void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence) 120 { 121 aSequence = _aSequence; 122 } 123 124 //-------------------------------------------------------------------- 125 // getInputStream 126 // Gets the input stream for the bound parameter 127 //-------------------------------------------------------------------- 128 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream () 129 { 130 return paramInputStream; 131 } 132 133 //-------------------------------------------------------------------- 134 // getInputStreamLen 135 // Gets the input stream length for the bound parameter 136 //-------------------------------------------------------------------- 137 sal_Int32 getInputStreamLen () 138 { 139 return paramInputStreamLen; 140 } 141 142 //-------------------------------------------------------------------- 143 // setSqlType 144 // Sets the Java sql type used to register an OUT parameter 145 //-------------------------------------------------------------------- 146 147 void setSqlType(sal_Int32 type) 148 { 149 sqlType = type; 150 } 151 152 //-------------------------------------------------------------------- 153 // getSqlType 154 // Gets the Java sql type used to register an OUT parameter 155 //-------------------------------------------------------------------- 156 157 sal_Int32 getSqlType () 158 { 159 return sqlType; 160 } 161 162 //-------------------------------------------------------------------- 163 // setOutputParameter 164 // Sets the flag indicating if this is an OUTPUT parameter 165 //-------------------------------------------------------------------- 166 167 void setOutputParameter (sal_Bool output) 168 { 169 outputParameter = output; 170 } 171 172 //-------------------------------------------------------------------- 173 // isOutputParameter 174 // Gets the OUTPUT parameter flag 175 //-------------------------------------------------------------------- 176 177 sal_Bool isOutputParameter () 178 { 179 return outputParameter; 180 } 181 182 protected: 183 //==================================================================== 184 // Data attributes 185 //==================================================================== 186 187 sal_Int8* binaryData; // Storage area to be used 188 // when binding the parameter 189 190 sal_Int8* paramLength; // Storage area to be used 191 // for the bound length of the 192 // parameter. Note that this 193 // data is in native format. 194 195 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream; 196 ::com::sun::star::uno::Sequence< sal_Int8 > aSequence; 197 // When an input stream is 198 // bound to a parameter, the 199 // input stream is saved 200 // until needed. 201 202 sal_Int32 paramInputStreamLen; // Length of input stream 203 204 sal_Int32 sqlType; // Java SQL type used to 205 // register an OUT parameter 206 207 sal_Bool outputParameter; // true for OUTPUT parameters 208 209 210 sal_Int32 pA1; //pointers 211 sal_Int32 pA2; 212 sal_Int32 pB1; 213 sal_Int32 pB2; 214 sal_Int32 pC1; 215 sal_Int32 pC2; 216 sal_Int32 pS1; 217 sal_Int32 pS2;// reserved for strings(UTFChars) 218 }; 219 } 220 } 221 #endif // _CONNECTIVITY_OBOUNPARAM_HXX_ 222 223