1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "java/sql/DriverPropertyInfo.hxx"
27 #include "java/lang/Boolean.hxx"
28 #include "java/tools.hxx"
29 #include "java/lang/String.hxx"
30 using namespace connectivity;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::beans;
33 //	using namespace ::com::sun::star::sdbcx;
34 using namespace ::com::sun::star::sdbc;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::lang;
37 
38 
39 //**************************************************************
40 //************ Class: java.sql.Driver
41 //**************************************************************
42 
43 jclass java_sql_DriverPropertyInfo::theClass = 0;
44 // --------------------------------------------------------------------------------
~java_sql_DriverPropertyInfo()45 java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
46 {}
47 // --------------------------------------------------------------------------------
getMyClass() const48 jclass java_sql_DriverPropertyInfo::getMyClass() const
49 {
50 	// die Klasse muss nur einmal geholt werden, daher statisch
51 	if( !theClass )
52         theClass = findMyClass("java/sql/DriverPropertyInfo");
53 	return theClass;
54 }
55 
56 // --------------------------------------------------------------------------------
operator starsdbc::DriverPropertyInfo()57 java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
58 {
59 	starsdbc::DriverPropertyInfo aInfo;
60 	aInfo.Name = name();
61 	aInfo.Description = description();
62 	aInfo.IsRequired = required();
63 	aInfo.Value = value();
64 	aInfo.Choices = choices();
65 
66 	return aInfo;
67 }
68 // --------------------------------------------------------------------------------
name()69 ::rtl::OUString java_sql_DriverPropertyInfo::name()
70 {
71 	::rtl::OUString aStr;
72     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
73 
74 	{
75 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
76 		if(id)
77 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
78 	} //t.pEnv
79 	return aStr;
80 }
81 // --------------------------------------------------------------------------------
description()82 ::rtl::OUString java_sql_DriverPropertyInfo::description()
83 {
84 	::rtl::OUString aStr;
85     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
86 
87 	{
88 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
89 		if(id)
90 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
91 	} //t.pEnv
92 	return aStr;
93 }
94 // --------------------------------------------------------------------------------
value()95 ::rtl::OUString java_sql_DriverPropertyInfo::value()
96 {
97 	::rtl::OUString aStr;
98     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
99 
100 	{
101 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
102 		if(id)
103 			aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
104 	} //t.pEnv
105 	return aStr;
106 }
107 // --------------------------------------------------------------------------------
required()108 sal_Bool java_sql_DriverPropertyInfo::required()
109 {
110 	jboolean out(0);
111     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
112 
113 	{
114 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
115 		if(id)
116 			out = t.pEnv->GetBooleanField( object, id);
117 	} //t.pEnv
118 	return out;
119 }
120 // --------------------------------------------------------------------------------
choices()121 Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
122 {
123     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
124 
125 	{
126 		jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
127 		if(id)
128         {
129             const java_lang_String * pEmpty = NULL;
130             const ::rtl::OUString * pEmpty2 = NULL;
131             return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty);
132         }
133 	} //t.pEnv
134 	return Sequence< ::rtl::OUString>();
135 }
136 // --------------------------------------------------------------------------------
137 
138