Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / jdbc / DriverPropertyInfo.cxx
blob2995d17d0592be367c87dd9dceed2f8f9ab83610
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "java/sql/DriverPropertyInfo.hxx"
30 #include "java/lang/Boolean.hxx"
31 #include "java/tools.hxx"
32 #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::sdbc;
38 using namespace ::com::sun::star::container;
39 using namespace ::com::sun::star::lang;
42 //**************************************************************
43 //************ Class: java.sql.Driver
44 //**************************************************************
46 jclass java_sql_DriverPropertyInfo::theClass = 0;
47 // --------------------------------------------------------------------------------
48 java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
50 // --------------------------------------------------------------------------------
51 jclass java_sql_DriverPropertyInfo::getMyClass() const
53 // the class must be fetched only once, therefore static
54 if( !theClass )
55 theClass = findMyClass("java/sql/DriverPropertyInfo");
56 return theClass;
59 // --------------------------------------------------------------------------------
60 java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
62 starsdbc::DriverPropertyInfo aInfo;
63 aInfo.Name = name();
64 aInfo.Description = description();
65 aInfo.IsRequired = required();
66 aInfo.Value = value();
67 aInfo.Choices = choices();
69 return aInfo;
71 // --------------------------------------------------------------------------------
72 ::rtl::OUString java_sql_DriverPropertyInfo::name()
74 ::rtl::OUString aStr;
75 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
78 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
79 if(id)
80 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
81 } //t.pEnv
82 return aStr;
84 // --------------------------------------------------------------------------------
85 ::rtl::OUString java_sql_DriverPropertyInfo::description()
87 ::rtl::OUString aStr;
88 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
91 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
92 if(id)
93 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
94 } //t.pEnv
95 return aStr;
97 // --------------------------------------------------------------------------------
98 ::rtl::OUString java_sql_DriverPropertyInfo::value()
100 ::rtl::OUString aStr;
101 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
104 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
105 if(id)
106 aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
107 } //t.pEnv
108 return aStr;
110 // --------------------------------------------------------------------------------
111 sal_Bool java_sql_DriverPropertyInfo::required()
113 jboolean out(0);
114 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
117 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
118 if(id)
119 out = t.pEnv->GetBooleanField( object, id);
120 } //t.pEnv
121 return out;
123 // --------------------------------------------------------------------------------
124 Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
126 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
129 jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
130 if(id)
132 const java_lang_String * pEmpty = NULL;
133 const ::rtl::OUString * pEmpty2 = NULL;
134 return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty);
136 } //t.pEnv
137 return Sequence< ::rtl::OUString>();
139 // --------------------------------------------------------------------------------
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */