LCOV - code coverage report
Current view: top level - connectivity/source/drivers/jdbc - InputStream.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 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("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("available",mID);
      72             : }
      73           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)
      74             : {
      75             :     static jmethodID mID(NULL);
      76           0 :     callVoidMethod("close",mID);
      77           0 : }
      78             : 
      79           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)
      80             : {
      81           0 :     if (nBytesToRead < 0)
      82           0 :         throw ::com::sun::star::io::BufferSizeExceededException( OUString(THROW_WHERE), *this );
      83             : 
      84           0 :     jint out(0);
      85           0 :     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
      86             : 
      87             :     {
      88           0 :         jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead);
      89             :         static const char * cSignature = "([BII)I";
      90             :         static const char * cMethodName = "read";
      91             :         // execute Java-Call
      92             :         static jmethodID mID(NULL);
      93           0 :         obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
      94           0 :         out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
      95           0 :         if ( !out )
      96           0 :             ThrowSQLException(t.pEnv,*this);
      97           0 :         if(out > 0)
      98             :         {
      99           0 :             jboolean p = sal_False;
     100           0 :             aData.realloc ( out );
     101           0 :             memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
     102             :         }
     103           0 :         t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
     104             :     } //t.pEnv
     105           0 :     return out;
     106             : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10