LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/jdbc - Timestamp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 68 0.0 %
Date: 2012-12-27 Functions: 0 18 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/sql/Timestamp.hxx"
      21             : #include "java/tools.hxx"
      22             : #include <comphelper/types.hxx>
      23             : #include "connectivity/dbconversion.hxx"
      24             : 
      25             : using namespace ::comphelper;
      26             : using namespace connectivity;
      27             : //**************************************************************
      28             : //************ Class: java.sql.Date
      29             : //**************************************************************
      30             : const double fMilliSecondsPerDay = 86400000.0;
      31             : jclass java_sql_Date::theClass = 0;
      32           0 : java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date( NULL, (jobject)NULL )
      33             : {
      34           0 :     SDBThreadAttach t;
      35           0 :     if( !t.pEnv )
      36           0 :         return;
      37             :     jvalue args[1];
      38             :     // Convert parameters
      39           0 :     ::rtl::OUString sDateStr;
      40           0 :     sDateStr = ::dbtools::DBTypeConversion::toDateString(_rOut);
      41           0 :     args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
      42             : 
      43             :     // Turn of Java-Call for the constructor
      44             :     // initialise temporary variables
      45             :     static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;";
      46             :     jobject tempObj;
      47             :     static jmethodID mID(NULL);
      48           0 :     if ( !mID  )
      49           0 :         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
      50           0 :     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
      51           0 :     saveRef( t.pEnv, tempObj );
      52           0 :     t.pEnv->DeleteLocalRef( tempObj );
      53             :     // and clean
      54             : }
      55             : 
      56           0 : java_sql_Date::~java_sql_Date()
      57           0 : {}
      58             : 
      59           0 : jclass java_sql_Date::getMyClass() const
      60             : {
      61           0 :     return st_getMyClass();
      62             : }
      63           0 : jclass java_sql_Date::st_getMyClass()
      64             : {
      65             :     // the class needs only be fetched once, that is why it is static
      66           0 :     if( !theClass )
      67           0 :         theClass = findMyClass("java/sql/Date");
      68           0 :     return theClass;
      69             : }
      70             : // -----------------------------------------------------------------------------
      71             : 
      72           0 : java_sql_Date::operator ::com::sun::star::util::Date()
      73             : {
      74           0 :     return ::dbtools::DBTypeConversion::toDate(toString());
      75             : }
      76             : 
      77             : //**************************************************************
      78             : //************ Class: java.sql.Time
      79             : //**************************************************************
      80             : 
      81             : jclass java_sql_Time::theClass = 0;
      82             : 
      83           0 : java_sql_Time::~java_sql_Time()
      84           0 : {}
      85             : 
      86           0 : jclass java_sql_Time::getMyClass() const
      87             : {
      88           0 :     return st_getMyClass();
      89             : }
      90           0 : jclass java_sql_Time::st_getMyClass()
      91             : {
      92             :     // the class needs only be fetched once, that is why it is static
      93           0 :     if( !theClass )
      94           0 :         theClass = findMyClass("java/sql/Time");
      95           0 :     return theClass;
      96             : }
      97           0 : java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL )
      98             : {
      99           0 :     SDBThreadAttach t;
     100           0 :     if( !t.pEnv )
     101           0 :         return;
     102             :     jvalue args[1];
     103             :     // Convert parameters
     104           0 :     ::rtl::OUString sDateStr;
     105           0 :     sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut);
     106           0 :     args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
     107             : 
     108             :     // Turn off Java-Call for the constructor
     109             :     // intialise temporary variables
     110             :     static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;";
     111             :     jobject tempObj;
     112             :     static jmethodID mID(NULL);
     113           0 :     if ( !mID  )
     114           0 :         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
     115           0 :     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
     116           0 :     t.pEnv->DeleteLocalRef((jstring)args[0].l);
     117           0 :     saveRef( t.pEnv, tempObj );
     118           0 :     t.pEnv->DeleteLocalRef( tempObj );
     119             :     // and clean
     120             : }
     121             : // -----------------------------------------------------------------------------
     122           0 : java_sql_Time::operator ::com::sun::star::util::Time()
     123             : {
     124           0 :     return ::dbtools::DBTypeConversion::toTime(toString());
     125             : }
     126             : //**************************************************************
     127             : //************ Class: java.sql.Timestamp
     128             : //**************************************************************
     129             : 
     130             : jclass java_sql_Timestamp::theClass = 0;
     131             : 
     132           0 : java_sql_Timestamp::~java_sql_Timestamp()
     133           0 : {}
     134             : 
     135           0 : jclass java_sql_Timestamp::getMyClass() const
     136             : {
     137           0 :     return st_getMyClass();
     138             : }
     139             : 
     140           0 : jclass java_sql_Timestamp::st_getMyClass()
     141             : {
     142             :     // the class needs only be fetched once, that is why it is static
     143           0 :     if( !theClass )
     144           0 :         theClass = findMyClass("java/sql/Timestamp");
     145           0 :     return theClass;
     146             : }
     147             : 
     148           0 : java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut)
     149           0 :                    :java_util_Date( NULL, (jobject)NULL )
     150             : {
     151           0 :         SDBThreadAttach t;
     152           0 :     if( !t.pEnv )
     153           0 :         return;
     154             :     jvalue args[1];
     155             :     // Convert parameters
     156           0 :     ::rtl::OUString sDateStr;
     157           0 :     sDateStr = ::dbtools::DBTypeConversion::toDateTimeString(_rOut);
     158             : 
     159           0 :     args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
     160             : 
     161             :     // Turn off Java-Call for the constructor
     162             :     // initialise temporary variables
     163             :     static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;";
     164             :     jobject tempObj;
     165             :     static jmethodID mID(NULL);
     166           0 :     if ( !mID  )
     167           0 :         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
     168           0 :     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
     169             : 
     170           0 :     saveRef( t.pEnv, tempObj );
     171           0 :     t.pEnv->DeleteLocalRef( tempObj );
     172             :     // and clean
     173             : }
     174             : 
     175             : // -----------------------------------------------------------------------------
     176           0 : java_sql_Timestamp::operator ::com::sun::star::util::DateTime()
     177             : {
     178           0 :     return ::dbtools::DBTypeConversion::toDateTime(toString());
     179             : }
     180             : // -----------------------------------------------------------------------------
     181             : 
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10