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

Generated by: LCOV version 1.11