xref: /trunk/main/connectivity/source/drivers/jdbc/JBigDecimal.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 #include "java/math/BigDecimal.hxx"
31 #include "java/tools.hxx"
32 #include "resource/jdbc_log.hrc"
33 using namespace connectivity;
34 //**************************************************************
35 //************ Class: java.lang.Boolean
36 //**************************************************************
37 
38 jclass java_math_BigDecimal::theClass = 0;
39 
40 java_math_BigDecimal::~java_math_BigDecimal()
41 {}
42 
43 jclass java_math_BigDecimal::getMyClass() const
44 {
45     // die Klasse muss nur einmal geholt werden, daher statisch
46     if( !theClass )
47         theClass = findMyClass("java/math/BigDecimal");
48     return theClass;
49 }
50 
51 java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL )
52 {
53     SDBThreadAttach t;
54     if( !t.pEnv )
55         return;
56     // Java-Call fuer den Konstruktor absetzen
57     // temporaere Variable initialisieren
58     static const char * cSignature = "(Ljava/lang/String;)V";
59     jobject tempObj;
60     static jmethodID mID(NULL);
61     obtainMethodId(t.pEnv, "<init>",cSignature, mID);
62 
63     jstring str = convertwchar_tToJavaString(t.pEnv,_par0.replace(',','.'));
64     tempObj = t.pEnv->NewObject( getMyClass(), mID, str );
65     t.pEnv->DeleteLocalRef(str);
66     saveRef( t.pEnv, tempObj );
67     t.pEnv->DeleteLocalRef( tempObj );
68     ThrowSQLException( t.pEnv, NULL );
69     // und aufraeumen
70 }
71 
72 java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Object( NULL, (jobject)NULL )
73 {
74     SDBThreadAttach t;
75     if( !t.pEnv )
76         return;
77     // Java-Call fuer den Konstruktor absetzen
78     // temporaere Variable initialisieren
79     static const char * cSignature = "(D)V";
80     jobject tempObj;
81     static jmethodID mID(NULL);
82     obtainMethodId(t.pEnv, "<init>",cSignature, mID);
83     tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 );
84     saveRef( t.pEnv, tempObj );
85     t.pEnv->DeleteLocalRef( tempObj );
86     ThrowSQLException( t.pEnv, NULL );
87     // und aufraeumen
88 }
89 
90