LCOV - code coverage report
Current view: top level - connectivity/source/drivers/jdbc - InputStream.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 37 0.0 %
Date: 2014-11-03 Functions: 0 9 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             : 
      20             : #include "java/io/InputStream.hxx"
      21             : #include "java/tools.hxx"
      22             : 
      23             : #include <string.h>
      24             : 
      25             : using namespace connectivity;
      26             : 
      27             : #if OSL_DEBUG_LEVEL > 0
      28             : #define THROW_WHERE SAL_WHERE
      29             : #else
      30             : #define THROW_WHERE ""
      31             : #endif
      32             : 
      33             : 
      34             : //************ Class: java.io.InputStream
      35             : 
      36             : 
      37             : jclass java_io_InputStream::theClass = 0;
      38           0 : java_io_InputStream::java_io_InputStream( JNIEnv * pEnv, jobject myObj )
      39           0 :     : java_lang_Object( pEnv, myObj )
      40             : {
      41           0 :     SDBThreadAttach::addRef();
      42           0 : }
      43           0 : java_io_InputStream::~java_io_InputStream()
      44             : {
      45           0 :     SDBThreadAttach::releaseRef();
      46           0 : }
      47             : 
      48           0 : jclass java_io_InputStream::getMyClass() const
      49             : {
      50             :     // the class must be fetched only once, therefore static
      51           0 :     if( !theClass )
      52           0 :         theClass = findMyClass("java/io/InputStream");
      53           0 :     return theClass;
      54             : }
      55             : 
      56             : 
      57           0 : sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      58             : {
      59           0 :     return readBytes(aData,nMaxBytesToRead);
      60             : }
      61             : 
      62           0 : void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      63             : {
      64             :     static jmethodID mID(NULL);
      65           0 :     callIntMethodWithIntArg_ThrowRuntime("skip",mID,nBytesToSkip);
      66           0 : }
      67             : 
      68           0 : sal_Int32 SAL_CALL java_io_InputStream::available(  ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      69             : {
      70             :     static jmethodID mID(NULL);
      71           0 :     return callIntMethod_ThrowRuntime("available", mID);
      72             : }
      73             : 
      74           0 : void SAL_CALL java_io_InputStream::closeInput(  ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      75             : {
      76             :     static jmethodID mID(NULL);
      77           0 :     callVoidMethod_ThrowRuntime("close",mID);
      78           0 : }
      79             : 
      80           0 : sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception)
      81             : {
      82           0 :     if (nBytesToRead < 0)
      83           0 :         throw ::com::sun::star::io::BufferSizeExceededException( THROW_WHERE, *this );
      84             : 
      85           0 :     jint out(0);
      86           0 :     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
      87             : 
      88             :     {
      89           0 :         jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead);
      90             :         static const char * cSignature = "([BII)I";
      91             :         static const char * cMethodName = "read";
      92             :         // execute Java-Call
      93             :         static jmethodID mID(NULL);
      94           0 :         obtainMethodId_throwRuntime(t.pEnv, cMethodName,cSignature, mID);
      95           0 :         out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
      96           0 :         if ( !out )
      97           0 :             ThrowRuntimeException(t.pEnv,*this);
      98           0 :         if(out > 0)
      99             :         {
     100           0 :             jboolean p = sal_False;
     101           0 :             aData.realloc ( out );
     102           0 :             memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
     103             :         }
     104           0 :         t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
     105             :     } //t.pEnv
     106           0 :     return out;
     107             : }
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10