1caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5caf5cd79SAndrew Rist * distributed with this work for additional information 6caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10caf5cd79SAndrew Rist * 11caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12caf5cd79SAndrew Rist * 13caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17caf5cd79SAndrew Rist * specific language governing permissions and limitations 18caf5cd79SAndrew Rist * under the License. 19caf5cd79SAndrew Rist * 20caf5cd79SAndrew Rist *************************************************************/ 21caf5cd79SAndrew Rist 22caf5cd79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CONNECTIVITY_JAVA_TOOLS_HXX_ 25cdf0e10cSrcweir #define _CONNECTIVITY_JAVA_TOOLS_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 28cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef JNI_H 31cdf0e10cSrcweir #include <jni.h> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include "java/sql/SQLException.hxx" 34cdf0e10cSrcweir #include <comphelper/uno3.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 37cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 38cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp> 39cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 40cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace connectivity 44cdf0e10cSrcweir { 45cdf0e10cSrcweir 46cdf0e10cSrcweir jstring convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _Temp); 47cdf0e10cSrcweir ::rtl::OUString JavaString2String(JNIEnv *pEnv,jstring _Str); 48cdf0e10cSrcweir class java_util_Properties; 49cdf0e10cSrcweir 50cdf0e10cSrcweir java_util_Properties* createStringPropertyArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 51cdf0e10cSrcweir copyArrayAndDelete(JNIEnv * pEnv,jobjectArray _Array,const T *,const JT *)52cdf0e10cSrcweir template<class T,class JT> ::com::sun::star::uno::Sequence< T > copyArrayAndDelete(JNIEnv *pEnv,jobjectArray _Array, const T*, const JT* ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir ::com::sun::star::uno::Sequence< T > xOut; 55cdf0e10cSrcweir if(_Array) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir jsize nLen = pEnv->GetArrayLength(_Array); 58cdf0e10cSrcweir xOut.realloc(nLen); 59cdf0e10cSrcweir for(jsize i=0;i<nLen;++i) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir JT xInfo(pEnv,pEnv->GetObjectArrayElement(_Array,i)); 62cdf0e10cSrcweir java_lang_Object::ThrowSQLException(pEnv,NULL); 63cdf0e10cSrcweir xOut.getArray()[i] = xInfo; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir pEnv->DeleteLocalRef(_Array); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir return xOut; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > Map2XNameAccess(JNIEnv *pEnv,jobject _pMap); 71cdf0e10cSrcweir jobject convertTypeMapToJavaMap(JNIEnv *pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & _rMap); 72cdf0e10cSrcweir 73*07a3d7f1SPedro Giffuni /** return if a exception occurred 74cdf0e10cSrcweir @param pEnv 75cdf0e10cSrcweir The native java env 76cdf0e10cSrcweir @param _bClear 77cdf0e10cSrcweir <TRUE/> if the execption should be cleared 78cdf0e10cSrcweir @return 79*07a3d7f1SPedro Giffuni <TRUE/> if an exception is occurred 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear); 82cdf0e10cSrcweir 83cdf0e10cSrcweir jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); 84cdf0e10cSrcweir jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir #endif // _CONNECTIVITY_JAVA_TOOLS_HXX_ 88cdf0e10cSrcweir 89