Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_sequenceresultsetmetadata.cxx
bloba538e9e22c900e783118d00b26b6dcab2f8d4376
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
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.
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.
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
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 200? by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
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/
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.
43 * Major Contributor(s):
44 * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
46 * All Rights Reserved.
48 * For minor contributions see the git repository.
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.
56 ************************************************************************/
58 #include "pq_sequenceresultsetmetadata.hxx"
60 #include <rtl/ustrbuf.hxx>
62 using rtl::OUStringBuffer;
63 using rtl::OUString;
64 using com::sun::star::uno::Any;
66 using com::sun::star::uno::RuntimeException;
68 using com::sun::star::sdbc::SQLException;
70 namespace pq_sdbc_driver
73 SequenceResultSetMetaData::SequenceResultSetMetaData(
74 const ::rtl::Reference< RefCountedMutex > & refMutex,
75 const ColumnMetaDataVector &metaDataVector,
76 int colCount ) :
77 m_refMutex( refMutex ),
78 m_columnData( metaDataVector ),
79 m_colCount( colCount )
84 // Methods
85 sal_Int32 SequenceResultSetMetaData::getColumnCount( )
86 throw (SQLException, RuntimeException)
88 return m_colCount;
91 sal_Bool SequenceResultSetMetaData::isAutoIncrement( sal_Int32 column )
92 throw (SQLException, RuntimeException)
94 checkColumnIndex( column );
95 return m_columnData[column-1].isAutoIncrement;
98 sal_Bool SequenceResultSetMetaData::isCaseSensitive( sal_Int32 /* column */ )
99 throw (SQLException, RuntimeException)
102 return sal_True; // ??? hmm, numeric types or
105 sal_Bool SequenceResultSetMetaData::isSearchable( sal_Int32 /* column */ ) throw (SQLException, RuntimeException)
107 return sal_True; // mmm, what types are not searchable ?
110 sal_Bool SequenceResultSetMetaData::isCurrency( sal_Int32 column ) throw (SQLException, RuntimeException)
112 checkColumnIndex( column );
113 return m_columnData[column-1].isCurrency;
116 sal_Int32 SequenceResultSetMetaData::isNullable( sal_Int32 column )
117 throw (SQLException, RuntimeException)
119 checkColumnIndex( column );
120 return m_columnData[column-1].isNullable;
123 sal_Bool SequenceResultSetMetaData::isSigned( sal_Int32 /* column */ )
124 throw (SQLException, RuntimeException)
126 return sal_True;
129 sal_Int32 SequenceResultSetMetaData::getColumnDisplaySize( sal_Int32 /* column */ )
130 throw (SQLException, RuntimeException)
132 return 50;
135 ::rtl::OUString SequenceResultSetMetaData::getColumnLabel( sal_Int32 column )
136 throw (SQLException, RuntimeException)
138 checkColumnIndex( column );
139 return m_columnData[column-1].columnName;
142 ::rtl::OUString SequenceResultSetMetaData::getColumnName( sal_Int32 column ) throw (SQLException, RuntimeException)
144 checkColumnIndex( column );
145 return m_columnData[column-1].columnName;
148 ::rtl::OUString SequenceResultSetMetaData::getSchemaName( sal_Int32 column ) throw (SQLException, RuntimeException)
150 checkColumnIndex( column );
151 return m_columnData[column-1].schemaTableName;
156 sal_Int32 SequenceResultSetMetaData::getPrecision( sal_Int32 column )
157 throw (SQLException, RuntimeException)
159 checkColumnIndex( column );
160 return m_columnData[column-1].precision;
163 sal_Int32 SequenceResultSetMetaData::getScale( sal_Int32 column )
164 throw (SQLException, RuntimeException)
166 checkColumnIndex( column );
167 return m_columnData[column-1].scale;
170 ::rtl::OUString SequenceResultSetMetaData::getTableName( sal_Int32 column )
171 throw (SQLException, RuntimeException)
173 checkColumnIndex( column );
174 return m_columnData[column-1].tableName;
177 ::rtl::OUString SequenceResultSetMetaData::getCatalogName( sal_Int32 /* column */ )
178 throw (SQLException, RuntimeException)
180 // can do this through XConnection.getCatalog() !
181 return OUString();
183 sal_Int32 SequenceResultSetMetaData::getColumnType( sal_Int32 column )
184 throw (SQLException, RuntimeException)
186 checkColumnIndex( column );
187 return m_columnData[column-1].type;
190 ::rtl::OUString SequenceResultSetMetaData::getColumnTypeName( sal_Int32 column )
191 throw (SQLException, RuntimeException)
193 checkColumnIndex( column );
194 return m_columnData[column-1].typeName;
198 sal_Bool SequenceResultSetMetaData::isReadOnly( sal_Int32 /* column */ )
199 throw (SQLException, RuntimeException)
201 return sal_False;
204 sal_Bool SequenceResultSetMetaData::isWritable( sal_Int32 column )
205 throw (SQLException, RuntimeException)
207 return ! isReadOnly( column ); // what's the sense if this method ?
210 sal_Bool SequenceResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
211 throw (SQLException, RuntimeException)
213 return isWritable(column); // uhh, now it becomes really esoteric ....
215 ::rtl::OUString SequenceResultSetMetaData::getColumnServiceName( sal_Int32 /* column */ )
216 throw (SQLException, RuntimeException)
218 return OUString();
221 void SequenceResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
222 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
224 if( columnIndex < 1 || columnIndex > m_colCount )
226 OUStringBuffer buf(128);
228 buf.appendAscii( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
229 buf.append( m_colCount );
230 buf.appendAscii( ", got " );
231 buf.append( columnIndex );
232 throw SQLException(
233 buf.makeStringAndClear(), *this, OUString(), 1, Any() );