LibreOffice Module connectivity (master) 1
Array.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <java/sql/Array.hxx>
21#include <java/tools.hxx>
22#include <osl/diagnose.h>
23
24using namespace connectivity;
25
26//************ Class: java.sql.Array
27
28
29jclass java_sql_Array::theClass = nullptr;
30
31java_sql_Array::~java_sql_Array()
32{}
33
35{
36 // the class must be fetched once, therefore it's static
37 if( !theClass )
38 theClass = findMyClass("java/sql/Array");
39
40 return theClass;
41}
42
44{
45 static jmethodID mID(nullptr);
46 return callStringMethod("getBaseTypeName",mID);
47}
48
49sal_Int32 SAL_CALL java_sql_Array::getBaseType( )
50{
51 static jmethodID mID(nullptr);
52 return callIntMethod_ThrowSQL("getBaseType", mID);
53}
54
55css::uno::Sequence< css::uno::Any > SAL_CALL java_sql_Array::getArray( const css::uno::Reference< css::container::XNameAccess >& typeMap )
56{
57 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
58 {
59 jobject obj = convertTypeMapToJavaMap(typeMap);
60 static const char * const cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;";
61 static const char * const cMethodName = "getArray";
62 static jmethodID mID(nullptr);
63 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
64 // submit Java-Call
65 t.pEnv->CallObjectMethod( object, mID, obj);
66 ThrowSQLException(t.pEnv,*this);
67 // and clean up
68 t.pEnv->DeleteLocalRef(obj);
69 } //t.pEnv
70 return css::uno::Sequence< css::uno::Any >();
71}
72
73css::uno::Sequence< css::uno::Any > SAL_CALL java_sql_Array::getArrayAtIndex( sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess >& typeMap )
74{
75 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
76 {
77 jobject obj = convertTypeMapToJavaMap(typeMap);
78 static const char * const cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;";
79 static const char * const cMethodName = "getArray";
80 // submit Java-Call
81 static jmethodID mID(nullptr);
82 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
83 t.pEnv->CallObjectMethod( object, mID, index,count,obj);
84 ThrowSQLException(t.pEnv,*this);
85 // and clean up
86 t.pEnv->DeleteLocalRef(obj);
87 }
88 return css::uno::Sequence< css::uno::Any >();
89}
90
91css::uno::Reference< css::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSet( const css::uno::Reference< css::container::XNameAccess >& typeMap )
92{
93 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
94 {
95 // convert Parameter
96 jobject obj = convertTypeMapToJavaMap(typeMap);
97 // initialize temporary variable
98 static const char * const cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
99 static const char * const cMethodName = "getResultSet";
100 // submit Java-Call
101 static jmethodID mID(nullptr);
102 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
103 t.pEnv->CallObjectMethod( object, mID, obj);
104 ThrowSQLException(t.pEnv,*this);
105 // and cleanup
106 t.pEnv->DeleteLocalRef(obj);
107 }
108 return nullptr;
109}
110
111css::uno::Reference< css::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess >& typeMap )
112{
113 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
114 {
115 // convert parameter
116 jobject obj = convertTypeMapToJavaMap(typeMap);
117 // initialize temporary variable
118 static const char * const cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
119 static const char * const cMethodName = "getResultSetAtIndex";
120 // submit Java-Call
121 static jmethodID mID(nullptr);
122 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
123 t.pEnv->CallObjectMethod( object, mID, index,count,obj);
124 ThrowSQLException(t.pEnv,*this);
125 // and cleanup
126 t.pEnv->DeleteLocalRef(obj);
127 }
128 return nullptr;
129}
130
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
sal_Int32 callIntMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:286
OUString callStringMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:394
static void ThrowSQLException(JNIEnv *pEnv, const css::uno::Reference< css::uno::XInterface > &_rContext)
Definition: Object.cxx:208
static jclass findMyClass(const char *_pClassName)
Definition: Object.cxx:466
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
Definition: Object.cxx:229
virtual OUString SAL_CALL getBaseTypeName() override
Definition: Array.cxx:43
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSetAtIndex(sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: Array.cxx:111
virtual sal_Int32 SAL_CALL getBaseType() override
Definition: Array.cxx:49
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: Array.cxx:91
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArray(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: Array.cxx:55
static jclass theClass
Definition: Array.hxx:36
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArrayAtIndex(sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: Array.cxx:73
virtual jclass getMyClass() const override
Definition: Array.cxx:34
jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > &_rMap)
index