LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/connectivity/source/inc/java/lang - Object.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2013-07-09 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
      20             : #define _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
      21             : 
      22             : #include <cstdarg>
      23             : #include <osl/thread.h>
      24             : #include <com/sun/star/sdbc/SQLException.hpp>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include <com/sun/star/uno/XComponentContext.hpp>
      27             : #include <osl/diagnose.h>
      28             : #include <jvmaccess/virtualmachine.hxx>
      29             : #include <memory>
      30             : #include <functional>
      31             : #include <boost/shared_ptr.hpp>
      32             : 
      33             : //=====================================================================
      34             : 
      35             : #ifdef HAVE_64BIT_POINTERS
      36             : #error "no 64 bit pointer"
      37             : #endif //HAVE_64BIT_POINTERS
      38             : 
      39             : namespace comphelper
      40             : {
      41             :     class ResourceBasedEventLogger;
      42             : }
      43             : 
      44             : namespace connectivity
      45             : {
      46             :     typedef ::boost::shared_ptr< jvmaccess::VirtualMachine::AttachGuard> TGuard;
      47             :     class SDBThreadAttach
      48             :     {
      49             :         jvmaccess::VirtualMachine::AttachGuard m_aGuard;
      50             :         SDBThreadAttach(SDBThreadAttach&);
      51             :         SDBThreadAttach& operator= (SDBThreadAttach&);
      52             :     public:
      53             :         SDBThreadAttach();
      54             :         ~SDBThreadAttach();
      55             : 
      56             :         JNIEnv* pEnv;
      57             :         static void addRef();
      58             :         static void releaseRef();
      59             : 
      60             :     public:
      61           0 :         JNIEnv& env() const
      62             :         {
      63             :             // according to the documentation of jvmaccess::VirtualMachine::AttachGuard, our env is never
      64             :             // NULL, so why bothering with pointer checks?
      65           0 :             return *pEnv;
      66             :         }
      67             :     };
      68             :     //=====================================================================
      69             :     //=====================================================================
      70             :     class  java_lang_Object
      71             :     {
      72             :         // operator= and the copy ctor are forbidden
      73             :         java_lang_Object& operator= (java_lang_Object&);
      74             :         java_lang_Object(java_lang_Object&);
      75             : 
      76             :     protected:
      77             :         // The Java handle to this class
      78             :         jobject object;
      79             : 
      80             :         // Class definiton
      81             :         // New in SJ2:
      82             :         static jclass theClass; // The class needs to be requested only once!
      83             : 
      84             :         virtual jclass getMyClass() const;
      85             : 
      86             :     public:
      87             :         // Ctor that should be used for the derived classes
      88             :         java_lang_Object( JNIEnv * pEnv, jobject myObj );
      89             : 
      90             :         // The actual ctor
      91             :         java_lang_Object();
      92             : 
      93             :         virtual ~java_lang_Object();
      94             : 
      95             :         void                saveRef( JNIEnv * pEnv, jobject myObj );
      96           0 :         jobject             getJavaObject() const { return object; }
      97             :         java_lang_Object *  GetWrapper() { return this; }
      98             :         void clearObject(JNIEnv& rEnv);
      99             :         void clearObject();
     100             : 
     101             :         virtual OUString toString() const;
     102             : 
     103             :         static void ThrowSQLException(JNIEnv * pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext);
     104             :         static void ThrowLoggedSQLException(
     105             :             const ::comphelper::ResourceBasedEventLogger& _rLogger,
     106             :             JNIEnv* pEnvironment,
     107             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext
     108             :         );
     109             : 
     110             :         static ::rtl::Reference< jvmaccess::VirtualMachine > getVM(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext=NULL);
     111             : 
     112             :         static jclass   findMyClass(const char* _pClassName);
     113             :         void            obtainMethodId(JNIEnv* _pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID) const;
     114             : 
     115             :         sal_Bool        callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     116             :         sal_Bool        callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
     117             :         jobject         callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     118             :         sal_Int32       callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException = false ) const;
     119             :         sal_Int32       callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
     120             :         sal_Int32       callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const;
     121             :         OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     122             :         OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
     123             :         void            callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const;
     124             :         void            callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
     125             :         void            callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
     126             :         void            callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID, const OUString& _nArgument ) const;
     127             :         jobject         callObjectMethod( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID ) const;
     128             :         jobject         callObjectMethodWithIntArg( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
     129             : 
     130             :         template< typename T >
     131           0 :                         T callMethodWithIntArg(T (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) ,const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
     132             :         {
     133           0 :             SDBThreadAttach t;
     134           0 :             obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
     135           0 :             T out = (t.pEnv->*pCallMethod)( object, _inout_MethodID,_nArgument);
     136           0 :             ThrowSQLException( t.pEnv, NULL );
     137           0 :             return out;
     138             :         }
     139             : 
     140             :         template< typename T >
     141           0 :                         void callVoidMethod(const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID,sal_Int32 _nArgument, const T& _aValue) const
     142             :         {
     143           0 :             SDBThreadAttach t;
     144           0 :             obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
     145           0 :             t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument,_aValue);
     146           0 :             ThrowSQLException( t.pEnv, NULL );
     147           0 :         }
     148             : 
     149             : 
     150             :     };
     151             : }
     152             : #endif //_CONNECTIVITY_JAVA_LANG_OBJJECT_HXX_
     153             : 
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10