Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * Effective License of whole file:
5 : *
6 : * This library is free software; you can redistribute it and/or
7 : * modify it under the terms of the GNU Lesser General Public
8 : * License version 2.1, as published by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 : * MA 02111-1307 USA
19 : *
20 : * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 : *
22 : * The Contents of this file are made available subject to the terms of
23 : * the GNU Lesser General Public License Version 2.1
24 : *
25 : * Copyright: 200? by Sun Microsystems, Inc.
26 : *
27 : * Contributor(s): Joerg Budischewski
28 : *
29 : * All parts contributed on or after August 2011:
30 : *
31 : * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
32 : *
33 : * The contents of this file are subject to the Mozilla Public License Version
34 : * 1.1 (the "License"); you may not use this file except in compliance with
35 : * the License or as specified alternatively below. You may obtain a copy of
36 : * the License at http://www.mozilla.org/MPL/
37 : *
38 : * Software distributed under the License is distributed on an "AS IS" basis,
39 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
40 : * for the specific language governing rights and limitations under the
41 : * License.
42 : *
43 : * Major Contributor(s):
44 : * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
45 : *
46 : * All Rights Reserved.
47 : *
48 : * For minor contributions see the git repository.
49 : *
50 : * Alternatively, the contents of this file may be used under the terms of
51 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
52 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
53 : * in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
54 : * instead of those above.
55 : *
56 : ************************************************************************/
57 :
58 : #include "pq_sequenceresultsetmetadata.hxx"
59 :
60 : #include <rtl/ustrbuf.hxx>
61 :
62 : using rtl::OUStringBuffer;
63 : using rtl::OUString;
64 : using com::sun::star::uno::Any;
65 :
66 : using com::sun::star::uno::RuntimeException;
67 :
68 : using com::sun::star::sdbc::SQLException;
69 :
70 : namespace pq_sdbc_driver
71 : {
72 :
73 0 : SequenceResultSetMetaData::SequenceResultSetMetaData(
74 : const ::rtl::Reference< RefCountedMutex > & refMutex,
75 : const ColumnMetaDataVector &metaDataVector,
76 : int colCount ) :
77 : m_refMutex( refMutex ),
78 : m_columnData( metaDataVector ),
79 0 : m_colCount( colCount )
80 : {
81 0 : }
82 :
83 :
84 : // Methods
85 0 : sal_Int32 SequenceResultSetMetaData::getColumnCount( )
86 : throw (SQLException, RuntimeException)
87 : {
88 0 : return m_colCount;
89 : }
90 :
91 0 : sal_Bool SequenceResultSetMetaData::isAutoIncrement( sal_Int32 column )
92 : throw (SQLException, RuntimeException)
93 : {
94 0 : checkColumnIndex( column );
95 0 : return m_columnData[column-1].isAutoIncrement;
96 : }
97 :
98 0 : sal_Bool SequenceResultSetMetaData::isCaseSensitive( sal_Int32 /* column */ )
99 : throw (SQLException, RuntimeException)
100 : {
101 :
102 0 : return sal_True; // ??? hmm, numeric types or
103 : }
104 :
105 0 : sal_Bool SequenceResultSetMetaData::isSearchable( sal_Int32 /* column */ ) throw (SQLException, RuntimeException)
106 : {
107 0 : return sal_True; // mmm, what types are not searchable ?
108 : }
109 :
110 0 : sal_Bool SequenceResultSetMetaData::isCurrency( sal_Int32 column ) throw (SQLException, RuntimeException)
111 : {
112 0 : checkColumnIndex( column );
113 0 : return m_columnData[column-1].isCurrency;
114 : }
115 :
116 0 : sal_Int32 SequenceResultSetMetaData::isNullable( sal_Int32 column )
117 : throw (SQLException, RuntimeException)
118 : {
119 0 : checkColumnIndex( column );
120 0 : return m_columnData[column-1].isNullable;
121 : }
122 :
123 0 : sal_Bool SequenceResultSetMetaData::isSigned( sal_Int32 /* column */ )
124 : throw (SQLException, RuntimeException)
125 : {
126 0 : return sal_True;
127 : }
128 :
129 0 : sal_Int32 SequenceResultSetMetaData::getColumnDisplaySize( sal_Int32 /* column */ )
130 : throw (SQLException, RuntimeException)
131 : {
132 0 : return 50;
133 : }
134 :
135 0 : ::rtl::OUString SequenceResultSetMetaData::getColumnLabel( sal_Int32 column )
136 : throw (SQLException, RuntimeException)
137 : {
138 0 : checkColumnIndex( column );
139 0 : return m_columnData[column-1].columnName;
140 : }
141 :
142 0 : ::rtl::OUString SequenceResultSetMetaData::getColumnName( sal_Int32 column ) throw (SQLException, RuntimeException)
143 : {
144 0 : checkColumnIndex( column );
145 0 : return m_columnData[column-1].columnName;
146 : }
147 :
148 0 : ::rtl::OUString SequenceResultSetMetaData::getSchemaName( sal_Int32 column ) throw (SQLException, RuntimeException)
149 : {
150 0 : checkColumnIndex( column );
151 0 : return m_columnData[column-1].schemaTableName;
152 : }
153 :
154 :
155 :
156 0 : sal_Int32 SequenceResultSetMetaData::getPrecision( sal_Int32 column )
157 : throw (SQLException, RuntimeException)
158 : {
159 0 : checkColumnIndex( column );
160 0 : return m_columnData[column-1].precision;
161 : }
162 :
163 0 : sal_Int32 SequenceResultSetMetaData::getScale( sal_Int32 column )
164 : throw (SQLException, RuntimeException)
165 : {
166 0 : checkColumnIndex( column );
167 0 : return m_columnData[column-1].scale;
168 : }
169 :
170 0 : ::rtl::OUString SequenceResultSetMetaData::getTableName( sal_Int32 column )
171 : throw (SQLException, RuntimeException)
172 : {
173 0 : checkColumnIndex( column );
174 0 : return m_columnData[column-1].tableName;
175 : }
176 :
177 0 : ::rtl::OUString SequenceResultSetMetaData::getCatalogName( sal_Int32 /* column */ )
178 : throw (SQLException, RuntimeException)
179 : {
180 : // can do this through XConnection.getCatalog() !
181 0 : return OUString();
182 : }
183 0 : sal_Int32 SequenceResultSetMetaData::getColumnType( sal_Int32 column )
184 : throw (SQLException, RuntimeException)
185 : {
186 0 : checkColumnIndex( column );
187 0 : return m_columnData[column-1].type;
188 : }
189 :
190 0 : ::rtl::OUString SequenceResultSetMetaData::getColumnTypeName( sal_Int32 column )
191 : throw (SQLException, RuntimeException)
192 : {
193 0 : checkColumnIndex( column );
194 0 : return m_columnData[column-1].typeName;
195 : }
196 :
197 :
198 0 : sal_Bool SequenceResultSetMetaData::isReadOnly( sal_Int32 /* column */ )
199 : throw (SQLException, RuntimeException)
200 : {
201 0 : return sal_False;
202 : }
203 :
204 0 : sal_Bool SequenceResultSetMetaData::isWritable( sal_Int32 column )
205 : throw (SQLException, RuntimeException)
206 : {
207 0 : return ! isReadOnly( column ); // what's the sense if this method ?
208 : }
209 :
210 0 : sal_Bool SequenceResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
211 : throw (SQLException, RuntimeException)
212 : {
213 0 : return isWritable(column); // uhh, now it becomes really esoteric ....
214 : }
215 0 : ::rtl::OUString SequenceResultSetMetaData::getColumnServiceName( sal_Int32 /* column */ )
216 : throw (SQLException, RuntimeException)
217 : {
218 0 : return OUString();
219 : }
220 :
221 0 : void SequenceResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
222 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
223 : {
224 0 : if( columnIndex < 1 || columnIndex > m_colCount )
225 : {
226 0 : OUStringBuffer buf(128);
227 :
228 0 : buf.appendAscii( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
229 0 : buf.append( m_colCount );
230 0 : buf.appendAscii( ", got " );
231 0 : buf.append( columnIndex );
232 : throw SQLException(
233 0 : buf.makeStringAndClear(), *this, OUString(), 1, Any() );
234 : }
235 0 : }
236 :
237 :
238 : }
|