LibreOffice Module connectivity (master) 1
Class.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/lang/Class.hxx>
21#include <rtl/ustring.hxx>
22
23using namespace connectivity;
24
25//************ Class: java.lang.Class
26
27jclass java_lang_Class::theClass = nullptr;
28
29java_lang_Class::~java_lang_Class() {}
30
32{
33 // the class must be fetched only once, therefore static
34 if (!theClass)
35 theClass = findMyClass("java/lang/Class");
36 return theClass;
37}
38
39java_lang_Class* java_lang_Class::forName(std::u16string_view _par0)
40{
41 jobject out(nullptr);
43
44 {
45 OString sClassName = OUStringToOString(_par0, RTL_TEXTENCODING_JAVA_UTF8);
46 sClassName = sClassName.replace('.', '/');
47 out = t.pEnv->FindClass(sClassName.getStr());
48 ThrowSQLException(t.pEnv, nullptr);
49 } //t.pEnv
50 // WARNING: the caller becomes the owner of the returned pointer
51 return out == nullptr ? nullptr : new java_lang_Class(t.pEnv, out);
52}
53
55{
57 auto const id = t.pEnv->GetMethodID(static_cast<jclass>(object), "<init>", "()V");
58 if (id == nullptr)
59 {
60 ThrowSQLException(t.pEnv, nullptr);
61 }
62 auto const obj = t.pEnv->NewObject(static_cast<jclass>(object), id);
63 if (obj == nullptr)
64 {
65 ThrowSQLException(t.pEnv, nullptr);
66 }
67 return obj;
68}
69
70/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
java_lang_Class(JNIEnv *pEnv, jobject myObj)
Definition: Class.hxx:40
virtual jclass getMyClass() const override
Definition: Class.cxx:31
static java_lang_Class * forName(std::u16string_view _par0)
Definition: Class.cxx:39
static jclass theClass
Definition: Class.hxx:35
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
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Definition: pq_tools.cxx:100