Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / jdbc / DriverPropertyInfo.cxx
blob5134ffd775d36b10992ec21be0d68995a46678eb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DriverPropertyInfo.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "java/sql/DriverPropertyInfo.hxx"
34 #include "java/lang/Boolean.hxx"
35 #include "java/tools.hxx"
36 #include "java/lang/String.hxx"
37 using namespace connectivity;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::beans;
40 // using namespace ::com::sun::star::sdbcx;
41 using namespace ::com::sun::star::sdbc;
42 using namespace ::com::sun::star::container;
43 using namespace ::com::sun::star::lang;
46 //**************************************************************
47 //************ Class: java.sql.Driver
48 //**************************************************************
50 jclass java_sql_DriverPropertyInfo::theClass = 0;
51 // --------------------------------------------------------------------------------
52 java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
54 // --------------------------------------------------------------------------------
55 jclass java_sql_DriverPropertyInfo::getMyClass() const
57 // die Klasse muss nur einmal geholt werden, daher statisch
58 if( !theClass )
59 theClass = findMyClass("java/sql/DriverPropertyInfo");
60 return theClass;
63 // --------------------------------------------------------------------------------
64 java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
66 starsdbc::DriverPropertyInfo aInfo;
67 aInfo.Name = name();
68 aInfo.Description = description();
69 aInfo.IsRequired = required();
70 aInfo.Value = value();
71 aInfo.Choices = choices();
73 return aInfo;
75 // --------------------------------------------------------------------------------
76 ::rtl::OUString java_sql_DriverPropertyInfo::name()
78 ::rtl::OUString aStr;
79 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
82 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
83 if(id)
84 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
85 } //t.pEnv
86 return aStr;
88 // --------------------------------------------------------------------------------
89 ::rtl::OUString java_sql_DriverPropertyInfo::description()
91 ::rtl::OUString aStr;
92 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
95 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
96 if(id)
97 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
98 } //t.pEnv
99 return aStr;
101 // --------------------------------------------------------------------------------
102 ::rtl::OUString java_sql_DriverPropertyInfo::value()
104 ::rtl::OUString aStr;
105 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
108 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
109 if(id)
110 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
111 } //t.pEnv
112 return aStr;
114 // --------------------------------------------------------------------------------
115 sal_Bool java_sql_DriverPropertyInfo::required()
117 jboolean out(0);
118 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
121 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
122 if(id)
123 out = t.pEnv->GetBooleanField( object, id);
124 } //t.pEnv
125 return out;
127 // --------------------------------------------------------------------------------
128 Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
130 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
133 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
134 if(id)
136 const java_lang_String * pEmpty = NULL;
137 const ::rtl::OUString * pEmpty2 = NULL;
138 return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty);
140 } //t.pEnv
141 return Sequence< ::rtl::OUString>();
143 // --------------------------------------------------------------------------------