Update ooo320-m1
[ooovba.git] / dbaccess / source / core / api / datacolumn.cxx
blob250bd04b78745544e7e9ce45cebdaece016f7609
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datacolumn.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef _DBACORE_DATACOLUMN_HXX_
34 #include "datacolumn.hxx"
35 #endif
36 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
37 #include <com/sun/star/lang/DisposedException.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
40 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
43 #include <com/sun/star/sdbc/DataType.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
46 #include <com/sun/star/sdbc/ColumnValue.hpp>
47 #endif
48 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
49 #include <cppuhelper/typeprovider.hxx>
50 #endif
51 #ifndef _TOOLS_DEBUG_HXX
52 #include <tools/debug.hxx>
53 #endif
54 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
55 #include "dbastrings.hrc"
56 #endif
57 #ifndef _DBASHARED_APITOOLS_HXX_
58 #include "apitools.hxx"
59 #endif
61 using namespace dbaccess;
62 using namespace ::com::sun::star::sdbc;
63 using namespace ::com::sun::star::sdb;
64 using namespace ::com::sun::star::beans;
65 using namespace ::com::sun::star::uno;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::container;
68 using namespace ::osl;
69 using namespace ::comphelper;
70 using namespace ::cppu;
72 DBG_NAME(ODataColumn)
73 //--------------------------------------------------------------------------
74 ODataColumn::ODataColumn(
75 const Reference < XResultSetMetaData >& _xMetaData,
76 const Reference < XRow >& _xRow,
77 const Reference < XRowUpdate >& _xRowUpdate,
78 sal_Int32 _nPos,
79 const Reference< XDatabaseMetaData >& _rxDBMeta)
80 :OResultColumn(_xMetaData, _nPos, _rxDBMeta)
81 ,m_xRow(_xRow)
82 ,m_xRowUpdate(_xRowUpdate)
84 DBG_CTOR(ODataColumn,NULL);
86 // -----------------------------------------------------------------------------
87 ODataColumn::~ODataColumn()
89 DBG_DTOR(ODataColumn,NULL);
92 // com::sun::star::lang::XTypeProvider
93 //--------------------------------------------------------------------------
94 Sequence< Type > ODataColumn::getTypes() throw (RuntimeException)
96 OTypeCollection aTypes(::getCppuType( (const Reference< XColumn > *)0 ),
97 ::getCppuType( (const Reference< XColumnUpdate > *)0 ),
98 OColumn::getTypes());
99 return aTypes.getTypes();
102 //--------------------------------------------------------------------------
103 Sequence< sal_Int8 > ODataColumn::getImplementationId() throw (RuntimeException)
105 static OImplementationId * pId = 0;
106 if (! pId)
108 MutexGuard aGuard( Mutex::getGlobalMutex() );
109 if (! pId)
111 static OImplementationId aId;
112 pId = &aId;
115 return pId->getImplementationId();
118 //------------------------------------------------------------------------------
119 Any SAL_CALL ODataColumn::queryInterface( const Type & _rType ) throw (RuntimeException)
121 Any aReturn = OResultColumn::queryInterface(_rType);
122 if (!aReturn.hasValue())
123 aReturn = ::cppu::queryInterface(_rType,
124 static_cast< XColumn* >(this),
125 static_cast< XColumnUpdate* >(this)
127 return aReturn;
130 // XServiceInfo
131 //------------------------------------------------------------------------------
132 rtl::OUString ODataColumn::getImplementationName( ) throw(RuntimeException)
134 return rtl::OUString::createFromAscii("com.sun.star.sdb.ODataColumn");
137 //------------------------------------------------------------------------------
138 Sequence< ::rtl::OUString > ODataColumn::getSupportedServiceNames( ) throw (RuntimeException)
140 Sequence< ::rtl::OUString > aSNS( 3 );
141 aSNS[0] = SERVICE_SDBCX_COLUMN;
142 aSNS[1] = SERVICE_SDB_RESULTCOLUMN;
143 aSNS[2] = SERVICE_SDB_DATACOLUMN;
144 return aSNS;
147 // OComponentHelper
148 //------------------------------------------------------------------------------
149 void ODataColumn::disposing()
151 OResultColumn::disposing();
153 m_xRow = NULL;
154 m_xRowUpdate = NULL;
157 // ::com::sun::star::sdb::XColumn
158 //------------------------------------------------------------------------------
159 sal_Bool ODataColumn::wasNull(void) throw( SQLException, RuntimeException )
161 MutexGuard aGuard(m_aMutex);
162 ::connectivity::checkDisposed(!m_xRow.is());
164 return m_xRow->wasNull();
167 //------------------------------------------------------------------------------
168 rtl::OUString ODataColumn::getString(void) throw( SQLException, RuntimeException )
170 MutexGuard aGuard(m_aMutex);
171 ::connectivity::checkDisposed(!m_xRow.is());
173 return m_xRow->getString(m_nPos);
176 //------------------------------------------------------------------------------
177 sal_Bool ODataColumn::getBoolean(void) throw( SQLException, RuntimeException )
179 MutexGuard aGuard(m_aMutex);
180 ::connectivity::checkDisposed(!m_xRow.is());
182 return m_xRow->getBoolean(m_nPos);
185 //------------------------------------------------------------------------------
186 sal_Int8 ODataColumn::getByte(void) throw( SQLException, RuntimeException )
188 MutexGuard aGuard(m_aMutex);
189 ::connectivity::checkDisposed(!m_xRow.is());
191 return m_xRow->getByte(m_nPos);
194 //------------------------------------------------------------------------------
195 sal_Int16 ODataColumn::getShort(void) throw( SQLException, RuntimeException )
197 MutexGuard aGuard(m_aMutex);
198 ::connectivity::checkDisposed(!m_xRow.is());
200 return m_xRow->getShort(m_nPos);
203 //------------------------------------------------------------------------------
204 sal_Int32 ODataColumn::getInt(void) throw( SQLException, RuntimeException )
206 MutexGuard aGuard(m_aMutex);
207 ::connectivity::checkDisposed(!m_xRow.is());
209 return m_xRow->getInt(m_nPos);
212 //------------------------------------------------------------------------------
213 sal_Int64 ODataColumn::getLong(void) throw( SQLException, RuntimeException )
215 MutexGuard aGuard(m_aMutex);
216 ::connectivity::checkDisposed(!m_xRow.is());
218 return m_xRow->getLong(m_nPos);
221 //------------------------------------------------------------------------------
222 float ODataColumn::getFloat(void) throw( SQLException, RuntimeException )
224 MutexGuard aGuard(m_aMutex);
225 ::connectivity::checkDisposed(!m_xRow.is());
227 return m_xRow->getFloat(m_nPos);
229 //------------------------------------------------------------------------------
230 double ODataColumn::getDouble(void) throw( SQLException, RuntimeException )
232 MutexGuard aGuard(m_aMutex);
233 ::connectivity::checkDisposed(!m_xRow.is());
235 return m_xRow->getDouble(m_nPos);
238 //------------------------------------------------------------------------------
239 Sequence< sal_Int8 > ODataColumn::getBytes(void) throw( SQLException, RuntimeException )
241 MutexGuard aGuard(m_aMutex);
242 ::connectivity::checkDisposed(!m_xRow.is());
244 return m_xRow->getBytes(m_nPos);
246 //------------------------------------------------------------------------------
247 com::sun::star::util::Date ODataColumn::getDate(void) throw( SQLException, RuntimeException )
249 MutexGuard aGuard(m_aMutex);
250 ::connectivity::checkDisposed(!m_xRow.is());
252 return m_xRow->getDate(m_nPos);
255 //------------------------------------------------------------------------------
256 com::sun::star::util::Time ODataColumn::getTime(void) throw( SQLException, RuntimeException )
258 MutexGuard aGuard(m_aMutex);
259 ::connectivity::checkDisposed(!m_xRow.is());
261 return m_xRow->getTime(m_nPos);
263 //------------------------------------------------------------------------------
264 com::sun::star::util::DateTime ODataColumn::getTimestamp(void) throw( SQLException, RuntimeException )
266 MutexGuard aGuard(m_aMutex);
267 ::connectivity::checkDisposed(!m_xRow.is());
269 return m_xRow->getTimestamp(m_nPos);
272 //------------------------------------------------------------------------------
273 Reference< ::com::sun::star::io::XInputStream > ODataColumn::getBinaryStream(void) throw( SQLException, RuntimeException )
275 MutexGuard aGuard(m_aMutex);
276 ::connectivity::checkDisposed(!m_xRow.is());
278 return m_xRow->getBinaryStream(m_nPos);
281 //------------------------------------------------------------------------------
282 Reference< ::com::sun::star::io::XInputStream > ODataColumn::getCharacterStream(void) throw( SQLException, RuntimeException )
284 MutexGuard aGuard(m_aMutex);
285 ::connectivity::checkDisposed(!m_xRow.is());
287 return m_xRow->getCharacterStream(m_nPos);
290 //------------------------------------------------------------------------------
291 Any ODataColumn::getObject(const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException )
293 MutexGuard aGuard(m_aMutex);
294 ::connectivity::checkDisposed(!m_xRow.is());
296 return m_xRow->getObject(m_nPos, typeMap);
299 //------------------------------------------------------------------------------
300 Reference< XRef > ODataColumn::getRef(void) throw( SQLException, RuntimeException )
302 MutexGuard aGuard(m_aMutex);
303 ::connectivity::checkDisposed(!m_xRow.is());
305 return m_xRow->getRef(m_nPos);
308 //------------------------------------------------------------------------------
309 Reference< XBlob > ODataColumn::getBlob(void) throw( SQLException, RuntimeException )
311 MutexGuard aGuard(m_aMutex);
312 ::connectivity::checkDisposed(!m_xRow.is());
314 return m_xRow->getBlob(m_nPos);
317 //------------------------------------------------------------------------------
318 Reference< XClob > ODataColumn::getClob(void) throw( SQLException, RuntimeException )
320 MutexGuard aGuard(m_aMutex);
321 ::connectivity::checkDisposed(!m_xRow.is());
323 return m_xRow->getClob(m_nPos);
326 //------------------------------------------------------------------------------
327 Reference< XArray > ODataColumn::getArray(void) throw( SQLException, RuntimeException )
329 MutexGuard aGuard(m_aMutex);
330 ::connectivity::checkDisposed(!m_xRow.is());
332 return m_xRow->getArray(m_nPos);
335 // ::com::sun::star::sdb::XColumnUpdate
336 //------------------------------------------------------------------------------
337 void ODataColumn::updateNull(void) throw( SQLException, RuntimeException )
339 MutexGuard aGuard( m_aMutex );
340 ::connectivity::checkDisposed(!m_xRowUpdate.is());
342 m_xRowUpdate->updateNull(m_nPos);
345 //------------------------------------------------------------------------------
346 void ODataColumn::updateBoolean(sal_Bool x) throw( SQLException, RuntimeException )
348 MutexGuard aGuard( m_aMutex );
349 ::connectivity::checkDisposed(!m_xRowUpdate.is());
351 m_xRowUpdate->updateBoolean(m_nPos, x);
354 //------------------------------------------------------------------------------
355 void ODataColumn::updateByte(sal_Int8 x) throw( SQLException, RuntimeException )
357 MutexGuard aGuard( m_aMutex );
358 ::connectivity::checkDisposed(!m_xRowUpdate.is());
360 m_xRowUpdate->updateByte(m_nPos, x);
363 //------------------------------------------------------------------------------
364 void ODataColumn::updateShort(sal_Int16 x) throw( SQLException, RuntimeException )
366 MutexGuard aGuard( m_aMutex );
367 ::connectivity::checkDisposed(!m_xRowUpdate.is());
369 m_xRowUpdate->updateShort(m_nPos, x);
372 //------------------------------------------------------------------------------
373 void ODataColumn::updateInt(sal_Int32 x) throw( SQLException, RuntimeException )
375 MutexGuard aGuard( m_aMutex );
376 ::connectivity::checkDisposed(!m_xRowUpdate.is());
378 m_xRowUpdate->updateInt(m_nPos, x);
381 //------------------------------------------------------------------------------
382 void ODataColumn::updateLong(sal_Int64 x) throw( SQLException, RuntimeException )
384 MutexGuard aGuard( m_aMutex );
385 ::connectivity::checkDisposed(!m_xRowUpdate.is());
387 m_xRowUpdate->updateLong(m_nPos, x);
390 //------------------------------------------------------------------------------
391 void ODataColumn::updateFloat(float x) throw( SQLException, RuntimeException )
393 MutexGuard aGuard( m_aMutex );
394 ::connectivity::checkDisposed(!m_xRowUpdate.is());
396 m_xRowUpdate->updateFloat(m_nPos, x);
399 //------------------------------------------------------------------------------
400 void ODataColumn::updateDouble(double x) throw( SQLException, RuntimeException )
402 MutexGuard aGuard( m_aMutex );
403 ::connectivity::checkDisposed(!m_xRowUpdate.is());
405 m_xRowUpdate->updateDouble(m_nPos, x);
408 //------------------------------------------------------------------------------
409 void ODataColumn::updateString(const rtl::OUString& x) throw( SQLException, RuntimeException )
411 MutexGuard aGuard( m_aMutex );
412 ::connectivity::checkDisposed(!m_xRowUpdate.is());
414 m_xRowUpdate->updateString(m_nPos, x);
417 //------------------------------------------------------------------------------
418 void ODataColumn::updateBytes(const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
420 MutexGuard aGuard( m_aMutex );
421 ::connectivity::checkDisposed(!m_xRowUpdate.is());
423 m_xRowUpdate->updateBytes(m_nPos, x);
426 //------------------------------------------------------------------------------
427 void ODataColumn::updateDate(const com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
429 MutexGuard aGuard( m_aMutex );
430 ::connectivity::checkDisposed(!m_xRowUpdate.is());
432 m_xRowUpdate->updateDate(m_nPos, x);
435 //------------------------------------------------------------------------------
436 void ODataColumn::updateTime(const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
438 MutexGuard aGuard( m_aMutex );
439 ::connectivity::checkDisposed(!m_xRowUpdate.is());
441 m_xRowUpdate->updateTime(m_nPos, x);
444 //------------------------------------------------------------------------------
445 void ODataColumn::updateTimestamp(const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
447 MutexGuard aGuard( m_aMutex );
448 ::connectivity::checkDisposed(!m_xRowUpdate.is());
450 m_xRowUpdate->updateTimestamp(m_nPos, x);
453 //------------------------------------------------------------------------------
454 void ODataColumn::updateCharacterStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
456 MutexGuard aGuard( m_aMutex );
457 ::connectivity::checkDisposed(!m_xRowUpdate.is());
459 m_xRowUpdate->updateCharacterStream(m_nPos, x, length);
462 //------------------------------------------------------------------------------
463 void ODataColumn::updateBinaryStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
465 MutexGuard aGuard( m_aMutex );
466 ::connectivity::checkDisposed(!m_xRowUpdate.is());
468 m_xRowUpdate->updateBinaryStream(m_nPos, x, length);
471 //------------------------------------------------------------------------------
472 void ODataColumn::updateNumericObject(const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
474 MutexGuard aGuard( m_aMutex );
475 ::connectivity::checkDisposed(!m_xRowUpdate.is());
477 m_xRowUpdate->updateNumericObject(m_nPos, x, scale);
480 //------------------------------------------------------------------------------
481 void ODataColumn::updateObject(const Any& x) throw( SQLException, RuntimeException )
483 MutexGuard aGuard( m_aMutex );
484 ::connectivity::checkDisposed(!m_xRowUpdate.is());
486 m_xRowUpdate->updateObject(m_nPos, x);