bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / commontools / FDatabaseMetaDataResultSet.cxx
blob0662f68d87970a6e8e32de7aee86298cba23b752
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 .
21 #include "ParameterSubstitution.hxx"
22 #include "FDatabaseMetaDataResultSet.hxx"
23 #include "FDatabaseMetaDataResultSetMetaData.hxx"
24 #include <com/sun/star/sdbc/DataType.hpp>
25 #include <com/sun/star/sdbc/ColumnSearch.hpp>
26 #include <com/sun/star/sdbc/KeyRule.hpp>
27 #include <com/sun/star/sdbc/ProcedureResult.hpp>
28 #include <com/sun/star/sdbc/IndexType.hpp>
29 #include <comphelper/property.hxx>
30 #include <com/sun/star/lang/DisposedException.hpp>
31 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
32 #include <com/sun/star/sdbc/ResultSetType.hpp>
33 #include <com/sun/star/sdbc/FetchDirection.hpp>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <cppuhelper/typeprovider.hxx>
36 #include <comphelper/sequence.hxx>
37 #include <cppuhelper/factory.hxx>
38 #include <cppuhelper/implementationentry.hxx>
39 #include <cppuhelper/supportsservice.hxx>
40 #include <connectivity/dbexception.hxx>
41 #include "resource/common_res.hrc"
42 #include "TConnection.hxx"
44 using namespace connectivity;
45 using namespace dbtools;
46 using namespace cppu;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::sdbcx;
51 using namespace ::com::sun::star::sdbc;
52 using namespace ::com::sun::star::container;
53 using namespace ::com::sun::star::lang;
55 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
56 :ODatabaseMetaDataResultSet_BASE(m_aMutex)
57 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
58 ,m_aStatement(NULL)
59 ,m_xMetaData(NULL)
60 ,m_nColPos(0)
61 ,m_bBOF(true)
62 ,m_bEOF(true)
64 construct();
68 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
69 :ODatabaseMetaDataResultSet_BASE(m_aMutex)
70 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
71 ,m_aStatement(NULL)
72 ,m_xMetaData(NULL)
73 ,m_nColPos(0)
74 ,m_bBOF(true)
75 ,m_bEOF(true)
77 construct();
79 setType(_eType);
83 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
87 void ODatabaseMetaDataResultSet::construct()
89 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::cppu::UnoType<sal_Int32>::get());
90 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::cppu::UnoType<sal_Int32>::get());
91 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
92 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::cppu::UnoType<sal_Int32>::get());
95 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
97 switch( _eType )
99 case eCatalogs: setCatalogsMap(); break;
100 case eSchemas: setSchemasMap(); break;
101 case eColumnPrivileges: setColumnPrivilegesMap(); break;
102 case eColumns: setColumnsMap(); break;
103 case eTables: setTablesMap(); break;
104 case eTableTypes: setTableTypes(); break;
105 case eProcedureColumns: setProcedureColumnsMap(); break;
106 case eProcedures: setProceduresMap(); break;
107 case eExportedKeys: setExportedKeysMap(); break;
108 case eImportedKeys: setImportedKeysMap(); break;
109 case ePrimaryKeys: setPrimaryKeysMap(); break;
110 case eIndexInfo: setIndexInfoMap(); break;
111 case eTablePrivileges: setTablePrivilegesMap(); break;
112 case eCrossReference: setCrossReferenceMap(); break;
113 case eTypeInfo: setTypeInfoMap(); break;
114 case eBestRowIdentifier: setBestRowIdentifierMap(); break;
115 case eVersionColumns: setVersionColumnsMap(); break;
116 case eUDTs: setUDTsMap(); break;
117 default:
118 OSL_FAIL("Wrong type!");
122 void ODatabaseMetaDataResultSet::disposing()
124 OPropertySetHelper::disposing();
126 ::osl::MutexGuard aGuard(m_aMutex);
127 m_aStatement = NULL;
128 m_xMetaData.clear();
129 m_aRowsIter = m_aRows.end();
130 m_aRows.clear();
131 m_aRowsIter = m_aRows.end();
134 void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
136 ODatabaseMetaDataResultSet_BASE::acquire();
139 void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
141 ODatabaseMetaDataResultSet_BASE::release();
144 Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
146 Any aRet = OPropertySetHelper::queryInterface(rType);
147 return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
150 Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException, std::exception)
152 ::cppu::OTypeCollection aTypes( cppu::UnoType<com::sun::star::beans::XMultiPropertySet>::get(),
153 cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(),
154 cppu::UnoType<com::sun::star::beans::XPropertySet>::get());
156 return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
159 void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
161 m_aRows = _rRows;
162 m_bBOF = true;
163 m_bEOF = m_aRows.empty();
166 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
168 ::osl::MutexGuard aGuard( m_aMutex );
169 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
172 Reference< XResultSetMetaData > xMeta = getMetaData();
173 sal_Int32 nLen = xMeta->getColumnCount();
174 sal_Int32 i = 1;
175 for(;i<=nLen;++i)
177 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
178 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
180 return i;
183 ::dbtools::throwInvalidColumnException( columnName, *this );
184 assert(false);
185 return 0; // Never reached
188 void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
190 if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1)
191 ::dbtools::throwInvalidIndexException(*this);
194 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
196 return NULL;
199 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
201 return NULL;
205 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
207 return getValue(columnIndex);
211 sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
213 return getValue(columnIndex);
217 Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
219 return getValue(columnIndex);
223 ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
225 return getValue(columnIndex);
229 double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
231 return getValue(columnIndex);
235 float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
237 return getValue(columnIndex);
241 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
243 return getValue(columnIndex);
248 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException, std::exception)
250 return 0;
254 sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
256 return getValue(columnIndex);
260 Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException, std::exception)
262 ::osl::MutexGuard aGuard( m_aMutex );
263 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
266 if(!m_xMetaData.is())
267 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
269 return m_xMetaData;
272 Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
274 return NULL;
279 Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
281 return NULL;
284 Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
286 return NULL;
290 Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
292 return NULL;
296 Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
298 return getValue(columnIndex).makeAny();
302 sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
304 return getValue(columnIndex);
308 OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
310 return getValue(columnIndex);
316 ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
318 return getValue(columnIndex);
323 ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
325 return getValue(columnIndex);
329 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException, std::exception)
331 return m_bEOF;
335 SAL_WNOUNREACHABLE_CODE_PUSH
337 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException, std::exception)
339 ::dbtools::throwFunctionSequenceException(*this);
340 return sal_False;
343 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException, std::exception)
345 ::dbtools::throwFunctionSequenceException(*this);
346 return sal_False;
349 SAL_WNOUNREACHABLE_CODE_POP
352 void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException, std::exception)
354 ::dbtools::throwFunctionSequenceException(*this);
357 void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException, std::exception)
359 ::dbtools::throwFunctionSequenceException(*this);
363 void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException, std::exception)
366 ::osl::MutexGuard aGuard( m_aMutex );
367 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
370 dispose();
374 SAL_WNOUNREACHABLE_CODE_PUSH
376 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException, std::exception)
378 ::dbtools::throwFunctionSequenceException(*this);
379 return sal_False;
383 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException, std::exception)
385 ::dbtools::throwFunctionSequenceException(*this);
386 return sal_False;
389 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
391 ::dbtools::throwFunctionSequenceException(*this);
392 return sal_False;
395 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
397 ::dbtools::throwFunctionSequenceException(*this);
398 return sal_False;
401 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException, std::exception)
403 ::dbtools::throwFunctionSequenceException(*this);
404 return sal_False;
407 SAL_WNOUNREACHABLE_CODE_POP
410 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException, std::exception)
412 return m_aStatement.get();
416 SAL_WNOUNREACHABLE_CODE_PUSH
418 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException, std::exception)
420 ::dbtools::throwFunctionSequenceException(*this);
421 return sal_False;
424 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException, std::exception)
426 ::dbtools::throwFunctionSequenceException(*this);
427 return sal_False;
430 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException, std::exception)
432 ::dbtools::throwFunctionSequenceException(*this);
433 return sal_False;
436 SAL_WNOUNREACHABLE_CODE_POP
440 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException, std::exception)
442 return m_bBOF;
446 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException, std::exception)
448 ::osl::MutexGuard aGuard( m_aMutex );
449 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
451 if ( m_bBOF )
453 m_aRowsIter = m_aRows.begin();
454 m_bBOF = false;
456 else
458 if ( m_bEOF )
459 throwFunctionSequenceException( *this );
460 else
461 if ( m_aRowsIter != m_aRows.end() )
462 ++m_aRowsIter;
465 bool bSuccess = m_aRowsIter != m_aRows.end();
466 if ( !bSuccess )
468 m_bEOF = true;
469 m_bBOF = m_aRows.empty();
471 return bSuccess;
475 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException, std::exception)
477 ::osl::MutexGuard aGuard( m_aMutex );
478 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
481 if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
482 return sal_True;
484 return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
487 void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException, std::exception)
492 void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException, std::exception)
496 void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException, std::exception)
500 Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException, std::exception)
502 return Any();
505 ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
507 Sequence< Property > aProps;
508 describeProperties(aProps);
509 return new ::cppu::OPropertyArrayHelper(aProps);
512 ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
514 return *getArrayHelper();
517 void ODatabaseMetaDataResultSet::setProceduresMap()
519 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
520 pMetaData->setProceduresMap();
521 m_xMetaData = pMetaData;
524 void ODatabaseMetaDataResultSet::setCatalogsMap()
526 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
527 pMetaData->setCatalogsMap();
528 m_xMetaData = pMetaData;
531 void ODatabaseMetaDataResultSet::setSchemasMap()
533 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
534 pMetaData->setSchemasMap();
535 m_xMetaData = pMetaData;
538 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
540 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
541 pMetaData->setColumnPrivilegesMap();
542 m_xMetaData = pMetaData;
545 void ODatabaseMetaDataResultSet::setColumnsMap()
548 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
549 pMetaData->setColumnsMap();
550 m_xMetaData = pMetaData;
553 void ODatabaseMetaDataResultSet::setTablesMap()
556 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
557 pMetaData->setTablesMap();
558 m_xMetaData = pMetaData;
561 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
563 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
564 pMetaData->setProcedureColumnsMap();
565 m_xMetaData = pMetaData;
568 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
570 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
571 pMetaData->setPrimaryKeysMap();
572 m_xMetaData = pMetaData;
575 void ODatabaseMetaDataResultSet::setIndexInfoMap()
577 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
578 pMetaData->setIndexInfoMap();
579 m_xMetaData = pMetaData;
582 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
584 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
585 pMetaData->setTablePrivilegesMap();
586 m_xMetaData = pMetaData;
589 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
591 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
592 pMetaData->setCrossReferenceMap();
593 m_xMetaData = pMetaData;
596 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
598 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
599 pMetaData->setVersionColumnsMap();
600 m_xMetaData = pMetaData;
603 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
605 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
606 pMetaData->setBestRowIdentifierMap();
607 m_xMetaData = pMetaData;
610 void ODatabaseMetaDataResultSet::setTypeInfoMap()
612 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
613 pMetaData->setTypeInfoMap();
614 m_xMetaData = pMetaData;
617 void ODatabaseMetaDataResultSet::setUDTsMap()
619 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
620 pMetaData->setUDTsMap();
621 m_xMetaData = pMetaData;
624 void ODatabaseMetaDataResultSet::setTableTypes()
626 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
627 pMetaData->setTableTypes();
628 m_xMetaData = pMetaData;
631 void ODatabaseMetaDataResultSet::setExportedKeysMap()
633 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
634 pMetaData->setExportedKeysMap();
635 m_xMetaData = pMetaData;
638 void ODatabaseMetaDataResultSet::setImportedKeysMap()
640 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
641 pMetaData->setImportedKeysMap();
642 m_xMetaData = pMetaData;
645 Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException, std::exception)
647 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
650 ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
652 m_aValue = _aValue;
653 return *this;
656 const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
658 ::osl::MutexGuard aGuard( m_aMutex );
659 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
661 if ( isBeforeFirst() || isAfterLast() )
662 ::dbtools::throwFunctionSequenceException( *this );
664 checkIndex(columnIndex );
665 m_nColPos = columnIndex;
667 if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
668 return *(*m_aRowsIter)[columnIndex];
669 return m_aEmptyValue;
672 /// return an empty ORowSetValueDecorator
673 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue()
675 static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
676 return aEmptyValueRef;
679 /// return an ORowSetValueDecorator with 0 as value
680 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value()
682 static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0);
683 return a0ValueRef;
686 /// return an ORowSetValueDecorator with 1 as value
687 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get1Value()
689 static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1);
690 return a1ValueRef;
693 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
694 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getBasicValue()
696 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
697 return aValueRef;
700 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue()
702 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT"));
703 return aValueRef;
706 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue()
708 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT"));
709 return aValueRef;
712 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue()
714 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE"));
715 return aValueRef;
718 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue()
720 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE"));
721 return aValueRef;
724 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue()
726 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE"));
727 return aValueRef;
730 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue()
732 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ"));
733 return aValueRef;
736 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue()
738 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER"));
739 return aValueRef;
742 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue()
744 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP"));
745 return aValueRef;
748 ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue()
750 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'"));
751 return aValueRef;
754 void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException, std::exception)
756 if ( _aArguments.getLength() == 2 )
758 sal_Int32 nResultSetType = 0;
759 if ( _aArguments[0] >>= nResultSetType)
761 setType(static_cast<MetaDataResultSetType>(nResultSetType));
762 Sequence< Sequence<Any> > aRows;
763 if ( _aArguments[1] >>= aRows )
765 ORows aRowsToSet;
766 const Sequence<Any>* pRowsIter = aRows.getConstArray();
767 const Sequence<Any>* pRowsEnd = pRowsIter + aRows.getLength();
768 for (; pRowsIter != pRowsEnd;++pRowsIter)
770 ORow aRowToSet;
771 const Any* pRowIter = pRowsIter->getConstArray();
772 const Any* pRowEnd = pRowIter + pRowsIter->getLength();
773 for (; pRowIter != pRowEnd;++pRowIter)
775 ORowSetValueDecoratorRef aValue;
776 switch( pRowIter->getValueTypeClass() )
778 case TypeClass_BOOLEAN:
780 bool bValue = false;
781 *pRowIter >>= bValue;
782 aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
784 break;
785 case TypeClass_BYTE:
787 sal_Int8 nValue(0);
788 *pRowIter >>= nValue;
789 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
791 break;
792 case TypeClass_SHORT:
793 case TypeClass_UNSIGNED_SHORT:
795 sal_Int16 nValue(0);
796 *pRowIter >>= nValue;
797 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
799 break;
800 case TypeClass_LONG:
801 case TypeClass_UNSIGNED_LONG:
803 sal_Int32 nValue(0);
804 *pRowIter >>= nValue;
805 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
807 break;
808 case TypeClass_HYPER:
809 case TypeClass_UNSIGNED_HYPER:
811 sal_Int64 nValue(0);
812 *pRowIter >>= nValue;
813 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
815 break;
816 case TypeClass_FLOAT:
818 float nValue(0.0);
819 *pRowIter >>= nValue;
820 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
822 break;
823 case TypeClass_DOUBLE:
825 double nValue(0.0);
826 *pRowIter >>= nValue;
827 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
829 break;
830 case TypeClass_STRING:
832 OUString sValue;
833 *pRowIter >>= sValue;
834 aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
836 break;
837 default:
838 break;
840 aRowToSet.push_back(aValue);
842 aRowsToSet.push_back(aRowToSet);
843 } // for (; pRowsIter != pRowsEnd;++pRowsIter
844 setRows(aRowsToSet);
849 // XServiceInfo
852 OUString ODatabaseMetaDataResultSet::getImplementationName_Static( ) throw(RuntimeException)
854 return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
857 Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) throw (RuntimeException)
859 Sequence< OUString > aSNS( 1 );
860 aSNS[0] = "com.sun.star.sdbc.ResultSet";
861 return aSNS;
864 OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( ) throw(RuntimeException, std::exception)
866 return getImplementationName_Static();
869 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
871 return cppu::supportsService(this, _rServiceName);
874 Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( ) throw(RuntimeException, std::exception)
876 return getSupportedServiceNames_Static();
879 namespace connectivity
881 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) throw( Exception )
883 return *(new ODatabaseMetaDataResultSet());
888 namespace
890 cppu::ImplementationEntry entries[] = {
891 { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static,
892 &cppu::createSingleComponentFactory, 0, 0 },
893 { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static,
894 &cppu::createSingleComponentFactory, 0, 0 },
895 { 0, 0, 0, 0, 0, 0 }
899 extern "C"
903 SAL_DLLPUBLIC_EXPORT void* SAL_CALL dbtools_component_getFactory(const sal_Char* implName, void* serviceManager, void* registryKey)
905 return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
910 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */