1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/queryinterface.hxx>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <tools/debug.hxx>
28 #include "dbastrings.hrc"
29 #include "apitools.hxx"
31 using namespace dbaccess
;
32 using namespace ::com::sun::star::sdbc
;
33 using namespace ::com::sun::star::sdb
;
34 using namespace ::com::sun::star::beans
;
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::lang
;
37 using namespace ::com::sun::star::container
;
38 using namespace ::osl
;
39 using namespace ::comphelper
;
40 using namespace ::cppu
;
43 ODataColumn::ODataColumn(
44 const Reference
< XResultSetMetaData
>& _xMetaData
,
45 const Reference
< XRow
>& _xRow
,
46 const Reference
< XRowUpdate
>& _xRowUpdate
,
48 const Reference
< XDatabaseMetaData
>& _rxDBMeta
)
49 :OResultColumn(_xMetaData
, _nPos
, _rxDBMeta
)
51 ,m_xRowUpdate(_xRowUpdate
)
55 ODataColumn::~ODataColumn()
59 // com::sun::star::lang::XTypeProvider
60 Sequence
< Type
> ODataColumn::getTypes() throw (RuntimeException
, std::exception
)
62 OTypeCollection
aTypes(cppu::UnoType
<XColumn
>::get(),
63 cppu::UnoType
<XColumnUpdate
>::get(),
65 return aTypes
.getTypes();
68 Sequence
< sal_Int8
> ODataColumn::getImplementationId() throw (RuntimeException
, std::exception
)
70 return css::uno::Sequence
<sal_Int8
>();
73 Any SAL_CALL
ODataColumn::queryInterface( const Type
& _rType
) throw (RuntimeException
, std::exception
)
75 Any aReturn
= OResultColumn::queryInterface(_rType
);
76 if (!aReturn
.hasValue())
77 aReturn
= ::cppu::queryInterface(_rType
,
78 static_cast< XColumn
* >(this),
79 static_cast< XColumnUpdate
* >(this)
85 OUString
ODataColumn::getImplementationName( ) throw(RuntimeException
, std::exception
)
87 return OUString("com.sun.star.sdb.ODataColumn");
90 Sequence
< OUString
> ODataColumn::getSupportedServiceNames( ) throw (RuntimeException
, std::exception
)
92 Sequence
< OUString
> aSNS( 3 );
93 aSNS
[0] = SERVICE_SDBCX_COLUMN
;
94 aSNS
[1] = SERVICE_SDB_RESULTCOLUMN
;
95 aSNS
[2] = SERVICE_SDB_DATACOLUMN
;
100 void ODataColumn::disposing()
102 OResultColumn::disposing();
108 // ::com::sun::star::sdb::XColumn
109 sal_Bool
ODataColumn::wasNull() throw( SQLException
, RuntimeException
, std::exception
)
111 MutexGuard
aGuard(m_aMutex
);
112 ::connectivity::checkDisposed(!m_xRow
.is());
114 return m_xRow
->wasNull();
117 OUString
ODataColumn::getString() throw( SQLException
, RuntimeException
, std::exception
)
119 MutexGuard
aGuard(m_aMutex
);
120 ::connectivity::checkDisposed(!m_xRow
.is());
122 return m_xRow
->getString(m_nPos
);
125 sal_Bool
ODataColumn::getBoolean() throw( SQLException
, RuntimeException
, std::exception
)
127 MutexGuard
aGuard(m_aMutex
);
128 ::connectivity::checkDisposed(!m_xRow
.is());
130 return m_xRow
->getBoolean(m_nPos
);
133 sal_Int8
ODataColumn::getByte() throw( SQLException
, RuntimeException
, std::exception
)
135 MutexGuard
aGuard(m_aMutex
);
136 ::connectivity::checkDisposed(!m_xRow
.is());
138 return m_xRow
->getByte(m_nPos
);
141 sal_Int16
ODataColumn::getShort() throw( SQLException
, RuntimeException
, std::exception
)
143 MutexGuard
aGuard(m_aMutex
);
144 ::connectivity::checkDisposed(!m_xRow
.is());
146 return m_xRow
->getShort(m_nPos
);
149 sal_Int32
ODataColumn::getInt() throw( SQLException
, RuntimeException
, std::exception
)
151 MutexGuard
aGuard(m_aMutex
);
152 ::connectivity::checkDisposed(!m_xRow
.is());
154 return m_xRow
->getInt(m_nPos
);
157 sal_Int64
ODataColumn::getLong() throw( SQLException
, RuntimeException
, std::exception
)
159 MutexGuard
aGuard(m_aMutex
);
160 ::connectivity::checkDisposed(!m_xRow
.is());
162 return m_xRow
->getLong(m_nPos
);
165 float ODataColumn::getFloat() throw( SQLException
, RuntimeException
, std::exception
)
167 MutexGuard
aGuard(m_aMutex
);
168 ::connectivity::checkDisposed(!m_xRow
.is());
170 return m_xRow
->getFloat(m_nPos
);
173 double ODataColumn::getDouble() throw( SQLException
, RuntimeException
, std::exception
)
175 MutexGuard
aGuard(m_aMutex
);
176 ::connectivity::checkDisposed(!m_xRow
.is());
178 return m_xRow
->getDouble(m_nPos
);
181 Sequence
< sal_Int8
> ODataColumn::getBytes() throw( SQLException
, RuntimeException
, std::exception
)
183 MutexGuard
aGuard(m_aMutex
);
184 ::connectivity::checkDisposed(!m_xRow
.is());
186 return m_xRow
->getBytes(m_nPos
);
189 com::sun::star::util::Date
ODataColumn::getDate() throw( SQLException
, RuntimeException
, std::exception
)
191 MutexGuard
aGuard(m_aMutex
);
192 ::connectivity::checkDisposed(!m_xRow
.is());
194 return m_xRow
->getDate(m_nPos
);
197 com::sun::star::util::Time
ODataColumn::getTime() throw( SQLException
, RuntimeException
, std::exception
)
199 MutexGuard
aGuard(m_aMutex
);
200 ::connectivity::checkDisposed(!m_xRow
.is());
202 return m_xRow
->getTime(m_nPos
);
205 com::sun::star::util::DateTime
ODataColumn::getTimestamp() throw( SQLException
, RuntimeException
, std::exception
)
207 MutexGuard
aGuard(m_aMutex
);
208 ::connectivity::checkDisposed(!m_xRow
.is());
210 return m_xRow
->getTimestamp(m_nPos
);
213 Reference
< ::com::sun::star::io::XInputStream
> ODataColumn::getBinaryStream() throw( SQLException
, RuntimeException
, std::exception
)
215 MutexGuard
aGuard(m_aMutex
);
216 ::connectivity::checkDisposed(!m_xRow
.is());
218 return m_xRow
->getBinaryStream(m_nPos
);
221 Reference
< ::com::sun::star::io::XInputStream
> ODataColumn::getCharacterStream() throw( SQLException
, RuntimeException
, std::exception
)
223 MutexGuard
aGuard(m_aMutex
);
224 ::connectivity::checkDisposed(!m_xRow
.is());
226 return m_xRow
->getCharacterStream(m_nPos
);
229 Any
ODataColumn::getObject(const Reference
< ::com::sun::star::container::XNameAccess
> & typeMap
) throw( SQLException
, RuntimeException
, std::exception
)
231 MutexGuard
aGuard(m_aMutex
);
232 ::connectivity::checkDisposed(!m_xRow
.is());
234 return m_xRow
->getObject(m_nPos
, typeMap
);
237 Reference
< XRef
> ODataColumn::getRef() throw( SQLException
, RuntimeException
, std::exception
)
239 MutexGuard
aGuard(m_aMutex
);
240 ::connectivity::checkDisposed(!m_xRow
.is());
242 return m_xRow
->getRef(m_nPos
);
245 Reference
< XBlob
> ODataColumn::getBlob() throw( SQLException
, RuntimeException
, std::exception
)
247 MutexGuard
aGuard(m_aMutex
);
248 ::connectivity::checkDisposed(!m_xRow
.is());
250 return m_xRow
->getBlob(m_nPos
);
253 Reference
< XClob
> ODataColumn::getClob() throw( SQLException
, RuntimeException
, std::exception
)
255 MutexGuard
aGuard(m_aMutex
);
256 ::connectivity::checkDisposed(!m_xRow
.is());
258 return m_xRow
->getClob(m_nPos
);
261 Reference
< XArray
> ODataColumn::getArray() throw( SQLException
, RuntimeException
, std::exception
)
263 MutexGuard
aGuard(m_aMutex
);
264 ::connectivity::checkDisposed(!m_xRow
.is());
266 return m_xRow
->getArray(m_nPos
);
269 // ::com::sun::star::sdb::XColumnUpdate
270 void ODataColumn::updateNull() throw( SQLException
, RuntimeException
, std::exception
)
272 MutexGuard
aGuard( m_aMutex
);
273 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
275 m_xRowUpdate
->updateNull(m_nPos
);
278 void ODataColumn::updateBoolean(sal_Bool x
) throw( SQLException
, RuntimeException
, std::exception
)
280 MutexGuard
aGuard( m_aMutex
);
281 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
283 m_xRowUpdate
->updateBoolean(m_nPos
, x
);
286 void ODataColumn::updateByte(sal_Int8 x
) throw( SQLException
, RuntimeException
, std::exception
)
288 MutexGuard
aGuard( m_aMutex
);
289 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
291 m_xRowUpdate
->updateByte(m_nPos
, x
);
294 void ODataColumn::updateShort(sal_Int16 x
) throw( SQLException
, RuntimeException
, std::exception
)
296 MutexGuard
aGuard( m_aMutex
);
297 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
299 m_xRowUpdate
->updateShort(m_nPos
, x
);
302 void ODataColumn::updateInt(sal_Int32 x
) throw( SQLException
, RuntimeException
, std::exception
)
304 MutexGuard
aGuard( m_aMutex
);
305 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
307 m_xRowUpdate
->updateInt(m_nPos
, x
);
310 void ODataColumn::updateLong(sal_Int64 x
) throw( SQLException
, RuntimeException
, std::exception
)
312 MutexGuard
aGuard( m_aMutex
);
313 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
315 m_xRowUpdate
->updateLong(m_nPos
, x
);
318 void ODataColumn::updateFloat(float x
) throw( SQLException
, RuntimeException
, std::exception
)
320 MutexGuard
aGuard( m_aMutex
);
321 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
323 m_xRowUpdate
->updateFloat(m_nPos
, x
);
326 void ODataColumn::updateDouble(double x
) throw( SQLException
, RuntimeException
, std::exception
)
328 MutexGuard
aGuard( m_aMutex
);
329 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
331 m_xRowUpdate
->updateDouble(m_nPos
, x
);
334 void ODataColumn::updateString(const OUString
& x
) throw( SQLException
, RuntimeException
, std::exception
)
336 MutexGuard
aGuard( m_aMutex
);
337 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
339 m_xRowUpdate
->updateString(m_nPos
, x
);
342 void ODataColumn::updateBytes(const Sequence
< sal_Int8
>& x
) throw( SQLException
, RuntimeException
, std::exception
)
344 MutexGuard
aGuard( m_aMutex
);
345 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
347 m_xRowUpdate
->updateBytes(m_nPos
, x
);
350 void ODataColumn::updateDate(const com::sun::star::util::Date
& x
) throw( SQLException
, RuntimeException
, std::exception
)
352 MutexGuard
aGuard( m_aMutex
);
353 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
355 m_xRowUpdate
->updateDate(m_nPos
, x
);
358 void ODataColumn::updateTime(const ::com::sun::star::util::Time
& x
) throw( SQLException
, RuntimeException
, std::exception
)
360 MutexGuard
aGuard( m_aMutex
);
361 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
363 m_xRowUpdate
->updateTime(m_nPos
, x
);
366 void ODataColumn::updateTimestamp(const ::com::sun::star::util::DateTime
& x
) throw( SQLException
, RuntimeException
, std::exception
)
368 MutexGuard
aGuard( m_aMutex
);
369 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
371 m_xRowUpdate
->updateTimestamp(m_nPos
, x
);
374 void ODataColumn::updateCharacterStream(const Reference
< ::com::sun::star::io::XInputStream
> & x
, sal_Int32 length
) throw( SQLException
, RuntimeException
, std::exception
)
376 MutexGuard
aGuard( m_aMutex
);
377 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
379 m_xRowUpdate
->updateCharacterStream(m_nPos
, x
, length
);
382 void ODataColumn::updateBinaryStream(const Reference
< ::com::sun::star::io::XInputStream
> & x
, sal_Int32 length
) throw( SQLException
, RuntimeException
, std::exception
)
384 MutexGuard
aGuard( m_aMutex
);
385 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
387 m_xRowUpdate
->updateBinaryStream(m_nPos
, x
, length
);
390 void ODataColumn::updateNumericObject(const Any
& x
, sal_Int32 scale
) throw( SQLException
, RuntimeException
, std::exception
)
392 MutexGuard
aGuard( m_aMutex
);
393 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
395 m_xRowUpdate
->updateNumericObject(m_nPos
, x
, scale
);
398 void ODataColumn::updateObject(const Any
& x
) throw( SQLException
, RuntimeException
, std::exception
)
400 MutexGuard
aGuard( m_aMutex
);
401 ::connectivity::checkDisposed(!m_xRowUpdate
.is());
403 m_xRowUpdate
->updateObject(m_nPos
, x
);
406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */