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