LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/jdbc - Reader.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 41 0.0 %
Date: 2012-12-17 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/Reader.hxx"
      21             : #include <string.h>
      22             : using namespace connectivity;
      23             : 
      24             : //**************************************************************
      25             : //************ Class: java.io.Reader
      26             : //**************************************************************
      27             : 
      28             : jclass java_io_Reader::theClass = 0;
      29           0 : java_io_Reader::java_io_Reader( JNIEnv * pEnv, jobject myObj )
      30           0 :     : java_lang_Object( pEnv, myObj )
      31             : {
      32           0 :     SDBThreadAttach::addRef();
      33           0 : }
      34           0 : java_io_Reader::~java_io_Reader()
      35             : {
      36           0 :     SDBThreadAttach::releaseRef();
      37           0 : }
      38             : 
      39           0 : jclass java_io_Reader::getMyClass() const
      40             : {
      41             :     // the class must be fetched only once, therefore static
      42           0 :     if( !theClass )
      43           0 :         theClass = findMyClass("java/io/Reader");
      44           0 :     return theClass;
      45             : }
      46             : 
      47           0 : sal_Int32 SAL_CALL java_io_Reader::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)
      48             : {
      49           0 :     return readBytes(aData,nMaxBytesToRead);
      50             : }
      51             : 
      52           0 : void SAL_CALL java_io_Reader::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)
      53             : {
      54             :     static jmethodID mID(NULL);
      55           0 :     callIntMethodWithIntArg("skip",mID,nBytesToSkip);
      56           0 : }
      57             : 
      58           0 : sal_Int32 SAL_CALL java_io_Reader::available(  ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
      59             : {
      60           0 :     jboolean out(sal_False);
      61           0 :     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
      62             : 
      63             :     {
      64             :         static const char * cSignature = "()Z";
      65             :         static const char * cMethodName = "available";
      66             :         // Java-Call
      67             :         static jmethodID mID(NULL);
      68           0 :         obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
      69           0 :         out = t.pEnv->CallBooleanMethod( object, mID);
      70           0 :         ThrowSQLException(t.pEnv,*this);
      71             :     } //t.pEnv
      72           0 :     return out;
      73             : }
      74             : 
      75           0 : void SAL_CALL java_io_Reader::closeInput(  ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
      76             : {
      77             :     static jmethodID mID(NULL);
      78           0 :     callVoidMethod("close",mID);
      79           0 : }
      80             : // -----------------------------------------------------
      81           0 : sal_Int32 SAL_CALL java_io_Reader::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)
      82             : {
      83             :     OSL_ENSURE(aData.getLength() < nBytesToRead," Sequence is smaller than BytesToRead");
      84           0 :     jint out(0);
      85           0 :     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
      86             : 
      87             :     {
      88           0 :         jcharArray pCharArray = t.pEnv->NewCharArray(nBytesToRead);
      89             :         static const char * cSignature = "([CII)I";
      90             :         static const char * cMethodName = "read";
      91             :         // Java-Call
      92             :         static jmethodID mID(NULL);
      93           0 :         obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
      94           0 :         out = t.pEnv->CallIntMethod( object, mID, pCharArray, 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 :             if(aData.getLength() < out)
     101           0 :                 aData.realloc(out-aData.getLength());
     102             : 
     103           0 :             memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out);
     104             :         }
     105           0 :         t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
     106             :     } //t.pEnv
     107           0 :     return out;
     108             : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10