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

Generated by: LCOV version 1.10