Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / jdbc / Array.cxx
blob10f1ebd4f7046b74336d74f1a1b6bb837b778e83
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Array.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "java/sql/Array.hxx"
34 #include "java/tools.hxx"
35 #include "java/sql/ResultSet.hxx"
37 using namespace connectivity;
38 //**************************************************************
39 //************ Class: java.sql.Array
40 //**************************************************************
42 jclass java_sql_Array::theClass = 0;
44 java_sql_Array::~java_sql_Array()
47 jclass java_sql_Array::getMyClass() const
49 // die Klasse muss nur einmal geholt werden, daher statisch
50 if( !theClass )
51 theClass = findMyClass("java/sql/Array");
53 return theClass;
56 ::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
58 static jmethodID mID(NULL);
59 return callStringMethod("getBaseTypeName",mID);
62 sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
64 static jmethodID mID(NULL);
65 return callIntMethod("getBaseType",mID);
68 ::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)
70 jobjectArray out(0);
71 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
74 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
75 static const char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;";
76 static const char * cMethodName = "getArray";
77 static jmethodID mID(NULL);
78 obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
79 // Java-Call absetzen
80 out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj);
81 ThrowSQLException(t.pEnv,*this);
82 // und aufraeumen
83 t.pEnv->DeleteLocalRef(obj);
84 } //t.pEnv
85 return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
88 ::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)
90 jobjectArray out(0);
91 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
94 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
95 static const char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;";
96 static const char * cMethodName = "getArray";
97 // Java-Call absetzen
98 static jmethodID mID(NULL);
99 obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
100 out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj);
101 ThrowSQLException(t.pEnv,*this);
102 // und aufraeumen
103 t.pEnv->DeleteLocalRef(obj);
104 } //t.pEnv
105 return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
108 ::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)
110 jobject out(0);
111 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
113 // Parameter konvertieren
114 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
115 // temporaere Variable initialisieren
116 static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
117 static const char * cMethodName = "getResultSet";
118 // Java-Call absetzen
119 static jmethodID mID(NULL);
120 obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
121 out = t.pEnv->CallObjectMethod( object, mID, obj);
122 ThrowSQLException(t.pEnv,*this);
123 // und aufraeumen
124 t.pEnv->DeleteLocalRef(obj);
125 } //t.pEnv
126 // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
127 // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
128 return NULL;
131 ::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)
133 jobject out(0);
134 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
136 // Parameter konvertieren
137 jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
138 // temporaere Variable initialisieren
139 static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
140 static const char * cMethodName = "getResultSetAtIndex";
141 // Java-Call absetzen
142 static jmethodID mID(NULL);
143 obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
144 out = t.pEnv->CallObjectMethod( object, mID, index,count,obj);
145 ThrowSQLException(t.pEnv,*this);
146 // und aufraeumen
147 t.pEnv->DeleteLocalRef(obj);
148 } //t.pEnv
149 // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
150 // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
151 return NULL;