bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / commontools / FDatabaseMetaDataResultSet.cxx
blob68c71a299f4b4d579218a5c21b9f6aded1c72602
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 <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
31 #include <com/sun/star/sdbc/ResultSetType.hpp>
32 #include <com/sun/star/sdbc/FetchDirection.hpp>
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <cppuhelper/typeprovider.hxx>
35 #include <comphelper/sequence.hxx>
36 #include <cppuhelper/factory.hxx>
37 #include <cppuhelper/implementationentry.hxx>
38 #include <cppuhelper/supportsservice.hxx>
39 #include <connectivity/dbexception.hxx>
40 #include <strings.hrc>
41 #include <TConnection.hxx>
43 using namespace connectivity;
44 using namespace dbtools;
45 using namespace cppu;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::sdbcx;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::container;
52 using namespace ::com::sun::star::lang;
54 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
55 :ODatabaseMetaDataResultSet_BASE(m_aMutex)
56 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
57 ,m_aStatement(nullptr)
58 ,m_nColPos(0)
59 ,m_bBOF(true)
60 ,m_bEOF(true)
62 construct();
66 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
67 :ODatabaseMetaDataResultSet_BASE(m_aMutex)
68 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
69 ,m_aStatement(nullptr)
70 ,m_nColPos(0)
71 ,m_bBOF(true)
72 ,m_bEOF(true)
74 construct();
76 setType(_eType);
80 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
84 void ODatabaseMetaDataResultSet::construct()
86 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::cppu::UnoType<sal_Int32>::get());
87 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::cppu::UnoType<sal_Int32>::get());
88 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
89 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::cppu::UnoType<sal_Int32>::get());
92 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
94 switch( _eType )
96 case eCatalogs: setCatalogsMap(); break;
97 case eSchemas: setSchemasMap(); break;
98 case eColumnPrivileges: setColumnPrivilegesMap(); break;
99 case eColumns: setColumnsMap(); break;
100 case eTables: setTablesMap(); break;
101 case eTableTypes: setTableTypes(); break;
102 case eProcedureColumns: setProcedureColumnsMap(); break;
103 case eProcedures: setProceduresMap(); break;
104 case eExportedKeys: setExportedKeysMap(); break;
105 case eImportedKeys: setImportedKeysMap(); break;
106 case ePrimaryKeys: setPrimaryKeysMap(); break;
107 case eIndexInfo: setIndexInfoMap(); break;
108 case eTablePrivileges: setTablePrivilegesMap(); break;
109 case eCrossReference: setCrossReferenceMap(); break;
110 case eTypeInfo: setTypeInfoMap(); break;
111 case eBestRowIdentifier: setBestRowIdentifierMap(); break;
112 case eVersionColumns: setVersionColumnsMap(); break;
113 case eUDTs: setUDTsMap(); break;
114 default:
115 OSL_FAIL("Wrong type!");
119 void ODatabaseMetaDataResultSet::disposing()
121 OPropertySetHelper::disposing();
123 ::osl::MutexGuard aGuard(m_aMutex);
124 m_aStatement = nullptr;
125 m_xMetaData.clear();
126 m_aRowsIter = m_aRows.end();
127 m_aRows.clear();
128 m_aRowsIter = m_aRows.end();
131 void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
133 ODatabaseMetaDataResultSet_BASE::acquire();
136 void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
138 ODatabaseMetaDataResultSet_BASE::release();
141 Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType )
143 Any aRet = OPropertySetHelper::queryInterface(rType);
144 return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
147 Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( )
149 ::cppu::OTypeCollection aTypes( cppu::UnoType<css::beans::XMultiPropertySet>::get(),
150 cppu::UnoType<css::beans::XFastPropertySet>::get(),
151 cppu::UnoType<css::beans::XPropertySet>::get());
153 return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
156 void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
158 m_aRows = _rRows;
159 m_bBOF = true;
160 m_bEOF = m_aRows.empty();
163 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName )
165 ::osl::MutexGuard aGuard( m_aMutex );
166 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
169 Reference< XResultSetMetaData > xMeta = getMetaData();
170 sal_Int32 nLen = xMeta->getColumnCount();
171 sal_Int32 i = 1;
172 for(;i<=nLen;++i)
174 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
175 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
177 return i;
180 ::dbtools::throwInvalidColumnException( columnName, *this );
181 #if !(defined(_MSC_VER) && defined(ENABLE_LTO))
182 assert(false);
183 return 0; // Never reached
184 #endif
187 void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex )
189 if(columnIndex >= static_cast<sal_Int32>((*m_aRowsIter).size()) || columnIndex < 1)
190 ::dbtools::throwInvalidIndexException(*this);
193 Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ )
195 return nullptr;
198 Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ )
200 return nullptr;
204 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex )
206 return bool(getValue(columnIndex));
210 sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex )
212 return getValue(columnIndex);
216 Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex )
218 return getValue(columnIndex);
222 css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex )
224 return getValue(columnIndex);
228 double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex )
230 return getValue(columnIndex);
234 float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex )
236 return getValue(columnIndex);
240 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex )
242 return getValue(columnIndex);
246 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( )
248 return 0;
252 sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex )
254 return getValue(columnIndex);
258 Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( )
260 ::osl::MutexGuard aGuard( m_aMutex );
261 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
264 if(!m_xMetaData.is())
265 m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
267 return m_xMetaData;
270 Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ )
272 return nullptr;
276 Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ )
278 return nullptr;
281 Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ )
283 return nullptr;
287 Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ )
289 return nullptr;
293 Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& /*typeMap*/ )
295 return getValue(columnIndex).makeAny();
299 sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex )
301 return getValue(columnIndex);
305 OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex )
307 return getValue(columnIndex);
311 css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex )
313 return getValue(columnIndex);
317 css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex )
319 return getValue(columnIndex);
323 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( )
325 return m_bEOF;
329 SAL_WNOUNREACHABLE_CODE_PUSH
331 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( )
333 ::dbtools::throwFunctionSequenceException(*this);
334 return false;
337 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( )
339 ::dbtools::throwFunctionSequenceException(*this);
340 return false;
343 SAL_WNOUNREACHABLE_CODE_POP
346 void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( )
348 ::dbtools::throwFunctionSequenceException(*this);
351 void SAL_CALL ODatabaseMetaDataResultSet::afterLast( )
353 ::dbtools::throwFunctionSequenceException(*this);
357 void SAL_CALL ODatabaseMetaDataResultSet::close( )
360 ::osl::MutexGuard aGuard( m_aMutex );
361 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
364 dispose();
368 SAL_WNOUNREACHABLE_CODE_PUSH
370 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( )
372 ::dbtools::throwFunctionSequenceException(*this);
373 return false;
377 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( )
379 ::dbtools::throwFunctionSequenceException(*this);
380 return false;
383 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ )
385 ::dbtools::throwFunctionSequenceException(*this);
386 return false;
389 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ )
391 ::dbtools::throwFunctionSequenceException(*this);
392 return false;
395 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( )
397 ::dbtools::throwFunctionSequenceException(*this);
398 return false;
401 SAL_WNOUNREACHABLE_CODE_POP
404 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( )
406 return m_aStatement.get();
410 SAL_WNOUNREACHABLE_CODE_PUSH
412 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( )
414 ::dbtools::throwFunctionSequenceException(*this);
415 return false;
418 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( )
420 ::dbtools::throwFunctionSequenceException(*this);
421 return false;
424 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( )
426 ::dbtools::throwFunctionSequenceException(*this);
427 return false;
430 SAL_WNOUNREACHABLE_CODE_POP
433 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( )
435 return m_bBOF;
439 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( )
441 ::osl::MutexGuard aGuard( m_aMutex );
442 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
444 if ( m_bBOF )
446 m_aRowsIter = m_aRows.begin();
447 m_bBOF = false;
449 else
451 if ( m_bEOF )
452 throwFunctionSequenceException( *this );
453 else
454 if ( m_aRowsIter != m_aRows.end() )
455 ++m_aRowsIter;
458 bool bSuccess = m_aRowsIter != m_aRows.end();
459 if ( !bSuccess )
461 m_bEOF = true;
462 m_bBOF = m_aRows.empty();
464 return bSuccess;
468 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( )
470 ::osl::MutexGuard aGuard( m_aMutex );
471 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
474 if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
475 return true;
477 return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
480 void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( )
485 void SAL_CALL ODatabaseMetaDataResultSet::cancel( )
489 void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( )
493 Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( )
495 return Any();
498 ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
500 Sequence< Property > aProps;
501 describeProperties(aProps);
502 return new ::cppu::OPropertyArrayHelper(aProps);
505 ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
507 return *getArrayHelper();
510 void ODatabaseMetaDataResultSet::setProceduresMap()
512 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
513 pMetaData->setProceduresMap();
514 m_xMetaData = pMetaData;
517 void ODatabaseMetaDataResultSet::setCatalogsMap()
519 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
520 pMetaData->setCatalogsMap();
521 m_xMetaData = pMetaData;
524 void ODatabaseMetaDataResultSet::setSchemasMap()
526 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
527 pMetaData->setSchemasMap();
528 m_xMetaData = pMetaData;
531 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
533 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
534 pMetaData->setColumnPrivilegesMap();
535 m_xMetaData = pMetaData;
538 void ODatabaseMetaDataResultSet::setColumnsMap()
541 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
542 pMetaData->setColumnsMap();
543 m_xMetaData = pMetaData;
546 void ODatabaseMetaDataResultSet::setTablesMap()
549 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
550 pMetaData->setTablesMap();
551 m_xMetaData = pMetaData;
554 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
556 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
557 pMetaData->setProcedureColumnsMap();
558 m_xMetaData = pMetaData;
561 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
563 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
564 pMetaData->setPrimaryKeysMap();
565 m_xMetaData = pMetaData;
568 void ODatabaseMetaDataResultSet::setIndexInfoMap()
570 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
571 pMetaData->setIndexInfoMap();
572 m_xMetaData = pMetaData;
575 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
577 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
578 pMetaData->setTablePrivilegesMap();
579 m_xMetaData = pMetaData;
582 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
584 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
585 pMetaData->setCrossReferenceMap();
586 m_xMetaData = pMetaData;
589 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
591 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
592 pMetaData->setVersionColumnsMap();
593 m_xMetaData = pMetaData;
596 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
598 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
599 pMetaData->setBestRowIdentifierMap();
600 m_xMetaData = pMetaData;
603 void ODatabaseMetaDataResultSet::setTypeInfoMap()
605 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
606 pMetaData->setTypeInfoMap();
607 m_xMetaData = pMetaData;
610 void ODatabaseMetaDataResultSet::setUDTsMap()
612 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
613 pMetaData->setUDTsMap();
614 m_xMetaData = pMetaData;
617 void ODatabaseMetaDataResultSet::setTableTypes()
619 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
620 pMetaData->setTableTypes();
621 m_xMetaData = pMetaData;
624 void ODatabaseMetaDataResultSet::setExportedKeysMap()
626 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
627 pMetaData->setExportedKeysMap();
628 m_xMetaData = pMetaData;
631 void ODatabaseMetaDataResultSet::setImportedKeysMap()
633 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
634 pMetaData->setImportedKeysMap();
635 m_xMetaData = pMetaData;
638 Reference< css::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( )
640 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
643 ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
645 m_aValue = _aValue;
646 return *this;
649 const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
651 ::osl::MutexGuard aGuard( m_aMutex );
652 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
654 if ( isBeforeFirst() || isAfterLast() )
655 ::dbtools::throwFunctionSequenceException( *this );
657 checkIndex(columnIndex );
658 m_nColPos = columnIndex;
660 if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
661 return *(*m_aRowsIter)[columnIndex];
662 return m_aEmptyValue;
665 /// return an empty ORowSetValueDecorator
666 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getEmptyValue()
668 static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
669 return aEmptyValueRef;
672 /// return an ORowSetValueDecorator with 0 as value
673 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get0Value()
675 static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator(sal_Int32(0));
676 return a0ValueRef;
679 /// return an ORowSetValueDecorator with 1 as value
680 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get1Value()
682 static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator(sal_Int32(1));
683 return a1ValueRef;
686 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
687 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getBasicValue()
689 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
690 return aValueRef;
693 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getSelectValue()
695 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT"));
696 return aValueRef;
699 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getInsertValue()
701 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT"));
702 return aValueRef;
705 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDeleteValue()
707 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE"));
708 return aValueRef;
711 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getUpdateValue()
713 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE"));
714 return aValueRef;
717 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getCreateValue()
719 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE"));
720 return aValueRef;
723 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getReadValue()
725 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ"));
726 return aValueRef;
729 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getAlterValue()
731 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER"));
732 return aValueRef;
735 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDropValue()
737 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP"));
738 return aValueRef;
741 ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getQuoteValue()
743 static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'"));
744 return aValueRef;
747 void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments )
749 if ( _aArguments.getLength() == 2 )
751 sal_Int32 nResultSetType = 0;
752 if ( _aArguments[0] >>= nResultSetType)
754 setType(static_cast<MetaDataResultSetType>(nResultSetType));
755 Sequence< Sequence<Any> > aRows;
756 if ( _aArguments[1] >>= aRows )
758 ORows aRowsToSet;
759 const Sequence<Any>* pRowsIter = aRows.getConstArray();
760 const Sequence<Any>* pRowsEnd = pRowsIter + aRows.getLength();
761 for (; pRowsIter != pRowsEnd;++pRowsIter)
763 ORow aRowToSet;
764 const Any* pRowIter = pRowsIter->getConstArray();
765 const Any* pRowEnd = pRowIter + pRowsIter->getLength();
766 for (; pRowIter != pRowEnd;++pRowIter)
768 ORowSetValueDecoratorRef aValue;
769 switch( pRowIter->getValueTypeClass() )
771 case TypeClass_BOOLEAN:
773 bool bValue = false;
774 *pRowIter >>= bValue;
775 aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
777 break;
778 case TypeClass_BYTE:
780 sal_Int8 nValue(0);
781 *pRowIter >>= nValue;
782 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
784 break;
785 case TypeClass_SHORT:
786 case TypeClass_UNSIGNED_SHORT:
788 sal_Int16 nValue(0);
789 *pRowIter >>= nValue;
790 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
792 break;
793 case TypeClass_LONG:
794 case TypeClass_UNSIGNED_LONG:
796 sal_Int32 nValue(0);
797 *pRowIter >>= nValue;
798 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
800 break;
801 case TypeClass_HYPER:
802 case TypeClass_UNSIGNED_HYPER:
804 sal_Int64 nValue(0);
805 *pRowIter >>= nValue;
806 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
808 break;
809 case TypeClass_FLOAT:
811 float nValue(0.0);
812 *pRowIter >>= nValue;
813 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
815 break;
816 case TypeClass_DOUBLE:
818 double nValue(0.0);
819 *pRowIter >>= nValue;
820 aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
822 break;
823 case TypeClass_STRING:
825 OUString sValue;
826 *pRowIter >>= sValue;
827 aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
829 break;
830 default:
831 break;
833 aRowToSet.push_back(aValue);
835 aRowsToSet.push_back(aRowToSet);
836 } // for (; pRowsIter != pRowsEnd;++pRowsIter
837 setRows(aRowsToSet);
842 // XServiceInfo
845 OUString ODatabaseMetaDataResultSet::getImplementationName_Static( )
847 return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
850 Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( )
852 Sequence<OUString> aSNS { "com.sun.star.sdbc.ResultSet" };
853 return aSNS;
856 OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( )
858 return getImplementationName_Static();
861 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName )
863 return cppu::supportsService(this, _rServiceName);
866 Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( )
868 return getSupportedServiceNames_Static();
871 namespace connectivity
873 /// @throws Exception
874 static Reference< XInterface > ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& )
876 return *(new ODatabaseMetaDataResultSet());
881 namespace
883 cppu::ImplementationEntry const entries[] = {
884 { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static,
885 &cppu::createSingleComponentFactory, nullptr, 0 },
886 { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static,
887 &cppu::createSingleComponentFactory, nullptr, 0 },
888 { nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
892 extern "C"
896 SAL_DLLPUBLIC_EXPORT void* dbtools_component_getFactory(const sal_Char* implName, void* serviceManager, void* registryKey)
898 return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
903 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */