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