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/sql/DriverPropertyInfo.hxx"
31 #include "java/lang/Boolean.hxx"
32 #include "java/tools.hxx"
33 #include "java/lang/String.hxx"
34 using namespace connectivity;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 //	using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::sdbc;
39 using namespace ::com::sun::star::container;
40 using namespace ::com::sun::star::lang;
41 
42 
43 //**************************************************************
44 //************ Class: java.sql.Driver
45 //**************************************************************
46 
47 jclass java_sql_DriverPropertyInfo::theClass = 0;
48 // --------------------------------------------------------------------------------
49 java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
50 {}
51 // --------------------------------------------------------------------------------
52 jclass java_sql_DriverPropertyInfo::getMyClass() const
53 {
54 	// die Klasse muss nur einmal geholt werden, daher statisch
55 	if( !theClass )
56         theClass = findMyClass("java/sql/DriverPropertyInfo");
57 	return theClass;
58 }
59 
60 // --------------------------------------------------------------------------------
61 java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
62 {
63 	starsdbc::DriverPropertyInfo aInfo;
64 	aInfo.Name = name();
65 	aInfo.Description = description();
66 	aInfo.IsRequired = required();
67 	aInfo.Value = value();
68 	aInfo.Choices = choices();
69 
70 	return aInfo;
71 }
72 // --------------------------------------------------------------------------------
73 ::rtl::OUString java_sql_DriverPropertyInfo::name()
74 {
75 	::rtl::OUString aStr;
76     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
77 
78 	{
79 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
80 		if(id)
81 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
82 	} //t.pEnv
83 	return aStr;
84 }
85 // --------------------------------------------------------------------------------
86 ::rtl::OUString java_sql_DriverPropertyInfo::description()
87 {
88 	::rtl::OUString aStr;
89     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
90 
91 	{
92 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
93 		if(id)
94 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
95 	} //t.pEnv
96 	return aStr;
97 }
98 // --------------------------------------------------------------------------------
99 ::rtl::OUString java_sql_DriverPropertyInfo::value()
100 {
101 	::rtl::OUString aStr;
102     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
103 
104 	{
105 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
106 		if(id)
107 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
108 	} //t.pEnv
109 	return aStr;
110 }
111 // --------------------------------------------------------------------------------
112 sal_Bool java_sql_DriverPropertyInfo::required()
113 {
114 	jboolean out(0);
115     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
116 
117 	{
118 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
119 		if(id)
120 			out = t.pEnv->GetBooleanField( object, id);
121 	} //t.pEnv
122 	return out;
123 }
124 // --------------------------------------------------------------------------------
125 Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
126 {
127     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
128 
129 	{
130 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
131 		if(id)
132         {
133             const java_lang_String * pEmpty = NULL;
134             const ::rtl::OUString * pEmpty2 = NULL;
135             return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty);
136         }
137 	} //t.pEnv
138 	return Sequence< ::rtl::OUString>();
139 }
140 // --------------------------------------------------------------------------------
141 
142