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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_connectivity.hxx" 26 #include "java/sql/Array.hxx" 27 #include "java/tools.hxx" 28 #include "java/sql/ResultSet.hxx" 29 30 using namespace connectivity; 31 //************************************************************** 32 //************ Class: java.sql.Array 33 //************************************************************** 34 35 jclass java_sql_Array::theClass = 0; 36 37 java_sql_Array::~java_sql_Array() 38 {} 39 40 jclass java_sql_Array::getMyClass() const 41 { 42 // die Klasse muss nur einmal geholt werden, daher statisch 43 if( !theClass ) 44 theClass = findMyClass("java/sql/Array"); 45 46 return theClass; 47 } 48 49 ::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 50 { 51 static jmethodID mID(NULL); 52 return callStringMethod("getBaseTypeName",mID); 53 } 54 55 sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 56 { 57 static jmethodID mID(NULL); 58 return callIntMethod("getBaseType",mID); 59 } 60 61 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 62 { 63 jobjectArray out(0); 64 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 65 66 { 67 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); 68 static const char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;"; 69 static const char * cMethodName = "getArray"; 70 static jmethodID mID(NULL); 71 obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 72 // Java-Call absetzen 73 out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj); 74 ThrowSQLException(t.pEnv,*this); 75 // und aufraeumen 76 t.pEnv->DeleteLocalRef(obj); 77 } //t.pEnv 78 return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out); 79 } 80 81 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArrayAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 82 { 83 jobjectArray out(0); 84 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 85 86 { 87 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); 88 static const char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;"; 89 static const char * cMethodName = "getArray"; 90 // Java-Call absetzen 91 static jmethodID mID(NULL); 92 obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 93 out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj); 94 ThrowSQLException(t.pEnv,*this); 95 // und aufraeumen 96 t.pEnv->DeleteLocalRef(obj); 97 } //t.pEnv 98 return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out); 99 } 100 101 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSet( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 102 { 103 jobject out(0); 104 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 105 { 106 // Parameter konvertieren 107 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); 108 // temporaere Variable initialisieren 109 static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; 110 static const char * cMethodName = "getResultSet"; 111 // Java-Call absetzen 112 static jmethodID mID(NULL); 113 obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 114 out = t.pEnv->CallObjectMethod( object, mID, obj); 115 ThrowSQLException(t.pEnv,*this); 116 // und aufraeumen 117 t.pEnv->DeleteLocalRef(obj); 118 } //t.pEnv 119 // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 120 // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); 121 return NULL; 122 } 123 124 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 125 { 126 jobject out(0); 127 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 128 { 129 // Parameter konvertieren 130 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); 131 // temporaere Variable initialisieren 132 static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; 133 static const char * cMethodName = "getResultSetAtIndex"; 134 // Java-Call absetzen 135 static jmethodID mID(NULL); 136 obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 137 out = t.pEnv->CallObjectMethod( object, mID, index,count,obj); 138 ThrowSQLException(t.pEnv,*this); 139 // und aufraeumen 140 t.pEnv->DeleteLocalRef(obj); 141 } //t.pEnv 142 // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 143 // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out ); 144 return NULL; 145 } 146 147 148 149