Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / datacolumn.cxx
blob0e94e91306fc69c45ae90eb155687bb429c9659a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "datacolumn.hxx"
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
23 #include <com/sun/star/sdbc/DataType.hpp>
24 #include <com/sun/star/sdbc/ColumnValue.hpp>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <tools/debug.hxx>
27 #include "dbastrings.hrc"
28 #include "apitools.hxx"
30 using namespace dbaccess;
31 using namespace ::com::sun::star::sdbc;
32 using namespace ::com::sun::star::sdb;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::container;
37 using namespace ::osl;
38 using namespace ::comphelper;
39 using namespace ::cppu;
41 DBG_NAME(ODataColumn)
43 ODataColumn::ODataColumn(
44 const Reference < XResultSetMetaData >& _xMetaData,
45 const Reference < XRow >& _xRow,
46 const Reference < XRowUpdate >& _xRowUpdate,
47 sal_Int32 _nPos,
48 const Reference< XDatabaseMetaData >& _rxDBMeta)
49 :OResultColumn(_xMetaData, _nPos, _rxDBMeta)
50 ,m_xRow(_xRow)
51 ,m_xRowUpdate(_xRowUpdate)
53 DBG_CTOR(ODataColumn,NULL);
56 ODataColumn::~ODataColumn()
58 DBG_DTOR(ODataColumn,NULL);
61 // com::sun::star::lang::XTypeProvider
62 Sequence< Type > ODataColumn::getTypes() throw (RuntimeException)
64 OTypeCollection aTypes(::getCppuType( (const Reference< XColumn > *)0 ),
65 ::getCppuType( (const Reference< XColumnUpdate > *)0 ),
66 OColumn::getTypes());
67 return aTypes.getTypes();
70 Sequence< sal_Int8 > ODataColumn::getImplementationId() throw (RuntimeException)
72 static OImplementationId * pId = 0;
73 if (! pId)
75 MutexGuard aGuard( Mutex::getGlobalMutex() );
76 if (! pId)
78 static OImplementationId aId;
79 pId = &aId;
82 return pId->getImplementationId();
85 Any SAL_CALL ODataColumn::queryInterface( const Type & _rType ) throw (RuntimeException)
87 Any aReturn = OResultColumn::queryInterface(_rType);
88 if (!aReturn.hasValue())
89 aReturn = ::cppu::queryInterface(_rType,
90 static_cast< XColumn* >(this),
91 static_cast< XColumnUpdate* >(this)
93 return aReturn;
96 // XServiceInfo
97 rtl::OUString ODataColumn::getImplementationName( ) throw(RuntimeException)
99 return rtl::OUString("com.sun.star.sdb.ODataColumn");
102 Sequence< ::rtl::OUString > ODataColumn::getSupportedServiceNames( ) throw (RuntimeException)
104 Sequence< ::rtl::OUString > aSNS( 3 );
105 aSNS[0] = SERVICE_SDBCX_COLUMN;
106 aSNS[1] = SERVICE_SDB_RESULTCOLUMN;
107 aSNS[2] = SERVICE_SDB_DATACOLUMN;
108 return aSNS;
111 // OComponentHelper
112 void ODataColumn::disposing()
114 OResultColumn::disposing();
116 m_xRow = NULL;
117 m_xRowUpdate = NULL;
120 // ::com::sun::star::sdb::XColumn
121 sal_Bool ODataColumn::wasNull(void) throw( SQLException, RuntimeException )
123 MutexGuard aGuard(m_aMutex);
124 ::connectivity::checkDisposed(!m_xRow.is());
126 return m_xRow->wasNull();
129 rtl::OUString ODataColumn::getString(void) throw( SQLException, RuntimeException )
131 MutexGuard aGuard(m_aMutex);
132 ::connectivity::checkDisposed(!m_xRow.is());
134 return m_xRow->getString(m_nPos);
137 sal_Bool ODataColumn::getBoolean(void) throw( SQLException, RuntimeException )
139 MutexGuard aGuard(m_aMutex);
140 ::connectivity::checkDisposed(!m_xRow.is());
142 return m_xRow->getBoolean(m_nPos);
145 sal_Int8 ODataColumn::getByte(void) throw( SQLException, RuntimeException )
147 MutexGuard aGuard(m_aMutex);
148 ::connectivity::checkDisposed(!m_xRow.is());
150 return m_xRow->getByte(m_nPos);
153 sal_Int16 ODataColumn::getShort(void) throw( SQLException, RuntimeException )
155 MutexGuard aGuard(m_aMutex);
156 ::connectivity::checkDisposed(!m_xRow.is());
158 return m_xRow->getShort(m_nPos);
161 sal_Int32 ODataColumn::getInt(void) throw( SQLException, RuntimeException )
163 MutexGuard aGuard(m_aMutex);
164 ::connectivity::checkDisposed(!m_xRow.is());
166 return m_xRow->getInt(m_nPos);
169 sal_Int64 ODataColumn::getLong(void) throw( SQLException, RuntimeException )
171 MutexGuard aGuard(m_aMutex);
172 ::connectivity::checkDisposed(!m_xRow.is());
174 return m_xRow->getLong(m_nPos);
177 float ODataColumn::getFloat(void) throw( SQLException, RuntimeException )
179 MutexGuard aGuard(m_aMutex);
180 ::connectivity::checkDisposed(!m_xRow.is());
182 return m_xRow->getFloat(m_nPos);
185 double ODataColumn::getDouble(void) throw( SQLException, RuntimeException )
187 MutexGuard aGuard(m_aMutex);
188 ::connectivity::checkDisposed(!m_xRow.is());
190 return m_xRow->getDouble(m_nPos);
193 Sequence< sal_Int8 > ODataColumn::getBytes(void) throw( SQLException, RuntimeException )
195 MutexGuard aGuard(m_aMutex);
196 ::connectivity::checkDisposed(!m_xRow.is());
198 return m_xRow->getBytes(m_nPos);
201 com::sun::star::util::Date ODataColumn::getDate(void) throw( SQLException, RuntimeException )
203 MutexGuard aGuard(m_aMutex);
204 ::connectivity::checkDisposed(!m_xRow.is());
206 return m_xRow->getDate(m_nPos);
209 com::sun::star::util::Time ODataColumn::getTime(void) throw( SQLException, RuntimeException )
211 MutexGuard aGuard(m_aMutex);
212 ::connectivity::checkDisposed(!m_xRow.is());
214 return m_xRow->getTime(m_nPos);
217 com::sun::star::util::DateTime ODataColumn::getTimestamp(void) throw( SQLException, RuntimeException )
219 MutexGuard aGuard(m_aMutex);
220 ::connectivity::checkDisposed(!m_xRow.is());
222 return m_xRow->getTimestamp(m_nPos);
225 Reference< ::com::sun::star::io::XInputStream > ODataColumn::getBinaryStream(void) throw( SQLException, RuntimeException )
227 MutexGuard aGuard(m_aMutex);
228 ::connectivity::checkDisposed(!m_xRow.is());
230 return m_xRow->getBinaryStream(m_nPos);
233 Reference< ::com::sun::star::io::XInputStream > ODataColumn::getCharacterStream(void) throw( SQLException, RuntimeException )
235 MutexGuard aGuard(m_aMutex);
236 ::connectivity::checkDisposed(!m_xRow.is());
238 return m_xRow->getCharacterStream(m_nPos);
241 Any ODataColumn::getObject(const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException )
243 MutexGuard aGuard(m_aMutex);
244 ::connectivity::checkDisposed(!m_xRow.is());
246 return m_xRow->getObject(m_nPos, typeMap);
249 Reference< XRef > ODataColumn::getRef(void) throw( SQLException, RuntimeException )
251 MutexGuard aGuard(m_aMutex);
252 ::connectivity::checkDisposed(!m_xRow.is());
254 return m_xRow->getRef(m_nPos);
257 Reference< XBlob > ODataColumn::getBlob(void) throw( SQLException, RuntimeException )
259 MutexGuard aGuard(m_aMutex);
260 ::connectivity::checkDisposed(!m_xRow.is());
262 return m_xRow->getBlob(m_nPos);
265 Reference< XClob > ODataColumn::getClob(void) throw( SQLException, RuntimeException )
267 MutexGuard aGuard(m_aMutex);
268 ::connectivity::checkDisposed(!m_xRow.is());
270 return m_xRow->getClob(m_nPos);
273 Reference< XArray > ODataColumn::getArray(void) throw( SQLException, RuntimeException )
275 MutexGuard aGuard(m_aMutex);
276 ::connectivity::checkDisposed(!m_xRow.is());
278 return m_xRow->getArray(m_nPos);
281 // ::com::sun::star::sdb::XColumnUpdate
282 void ODataColumn::updateNull(void) throw( SQLException, RuntimeException )
284 MutexGuard aGuard( m_aMutex );
285 ::connectivity::checkDisposed(!m_xRowUpdate.is());
287 m_xRowUpdate->updateNull(m_nPos);
290 void ODataColumn::updateBoolean(sal_Bool x) throw( SQLException, RuntimeException )
292 MutexGuard aGuard( m_aMutex );
293 ::connectivity::checkDisposed(!m_xRowUpdate.is());
295 m_xRowUpdate->updateBoolean(m_nPos, x);
298 void ODataColumn::updateByte(sal_Int8 x) throw( SQLException, RuntimeException )
300 MutexGuard aGuard( m_aMutex );
301 ::connectivity::checkDisposed(!m_xRowUpdate.is());
303 m_xRowUpdate->updateByte(m_nPos, x);
306 void ODataColumn::updateShort(sal_Int16 x) throw( SQLException, RuntimeException )
308 MutexGuard aGuard( m_aMutex );
309 ::connectivity::checkDisposed(!m_xRowUpdate.is());
311 m_xRowUpdate->updateShort(m_nPos, x);
314 void ODataColumn::updateInt(sal_Int32 x) throw( SQLException, RuntimeException )
316 MutexGuard aGuard( m_aMutex );
317 ::connectivity::checkDisposed(!m_xRowUpdate.is());
319 m_xRowUpdate->updateInt(m_nPos, x);
322 void ODataColumn::updateLong(sal_Int64 x) throw( SQLException, RuntimeException )
324 MutexGuard aGuard( m_aMutex );
325 ::connectivity::checkDisposed(!m_xRowUpdate.is());
327 m_xRowUpdate->updateLong(m_nPos, x);
330 void ODataColumn::updateFloat(float x) throw( SQLException, RuntimeException )
332 MutexGuard aGuard( m_aMutex );
333 ::connectivity::checkDisposed(!m_xRowUpdate.is());
335 m_xRowUpdate->updateFloat(m_nPos, x);
338 void ODataColumn::updateDouble(double x) throw( SQLException, RuntimeException )
340 MutexGuard aGuard( m_aMutex );
341 ::connectivity::checkDisposed(!m_xRowUpdate.is());
343 m_xRowUpdate->updateDouble(m_nPos, x);
346 void ODataColumn::updateString(const rtl::OUString& x) throw( SQLException, RuntimeException )
348 MutexGuard aGuard( m_aMutex );
349 ::connectivity::checkDisposed(!m_xRowUpdate.is());
351 m_xRowUpdate->updateString(m_nPos, x);
354 void ODataColumn::updateBytes(const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
356 MutexGuard aGuard( m_aMutex );
357 ::connectivity::checkDisposed(!m_xRowUpdate.is());
359 m_xRowUpdate->updateBytes(m_nPos, x);
362 void ODataColumn::updateDate(const com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
364 MutexGuard aGuard( m_aMutex );
365 ::connectivity::checkDisposed(!m_xRowUpdate.is());
367 m_xRowUpdate->updateDate(m_nPos, x);
370 void ODataColumn::updateTime(const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
372 MutexGuard aGuard( m_aMutex );
373 ::connectivity::checkDisposed(!m_xRowUpdate.is());
375 m_xRowUpdate->updateTime(m_nPos, x);
378 void ODataColumn::updateTimestamp(const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
380 MutexGuard aGuard( m_aMutex );
381 ::connectivity::checkDisposed(!m_xRowUpdate.is());
383 m_xRowUpdate->updateTimestamp(m_nPos, x);
386 void ODataColumn::updateCharacterStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
388 MutexGuard aGuard( m_aMutex );
389 ::connectivity::checkDisposed(!m_xRowUpdate.is());
391 m_xRowUpdate->updateCharacterStream(m_nPos, x, length);
394 void ODataColumn::updateBinaryStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
396 MutexGuard aGuard( m_aMutex );
397 ::connectivity::checkDisposed(!m_xRowUpdate.is());
399 m_xRowUpdate->updateBinaryStream(m_nPos, x, length);
402 void ODataColumn::updateNumericObject(const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
404 MutexGuard aGuard( m_aMutex );
405 ::connectivity::checkDisposed(!m_xRowUpdate.is());
407 m_xRowUpdate->updateNumericObject(m_nPos, x, scale);
410 void ODataColumn::updateObject(const Any& x) throw( SQLException, RuntimeException )
412 MutexGuard aGuard( m_aMutex );
413 ::connectivity::checkDisposed(!m_xRowUpdate.is());
415 m_xRowUpdate->updateObject(m_nPos, x);
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */