1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FDatabaseMetaDataResultSet.cxx,v $
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_connectivity.hxx"
34 #include "ParameterSubstitution.hxx"
35 #include "FDatabaseMetaDataResultSet.hxx"
36 #include "FDatabaseMetaDataResultSetMetaData.hxx"
37 #include <com/sun/star/sdbc/DataType.hpp>
38 #include <com/sun/star/sdbc/ColumnSearch.hpp>
39 #include <com/sun/star/sdbc/KeyRule.hpp>
40 #include <com/sun/star/sdbc/ProcedureResult.hpp>
41 #include <com/sun/star/sdbc/IndexType.hpp>
42 #include <comphelper/property.hxx>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
45 #include <com/sun/star/sdbc/ResultSetType.hpp>
46 #include <com/sun/star/sdbc/FetchDirection.hpp>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <cppuhelper/typeprovider.hxx>
49 #include <comphelper/sequence.hxx>
50 #include <cppuhelper/factory.hxx>
51 #include <cppuhelper/implementationentry.hxx>
52 #include "connectivity/dbexception.hxx"
53 #include "TConnection.hxx"
55 using namespace connectivity
;
56 using namespace dbtools
;
58 //------------------------------------------------------------------------------
59 using namespace ::com::sun::star::beans
;
60 using namespace ::com::sun::star::uno
;
61 using namespace ::com::sun::star::sdbcx
;
62 using namespace ::com::sun::star::sdbc
;
63 using namespace ::com::sun::star::container
;
64 using namespace ::com::sun::star::lang
;
65 // -------------------------------------------------------------------------
66 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
67 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
68 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
77 // -------------------------------------------------------------------------
78 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType
)
79 :ODatabaseMetaDataResultSet_BASE(m_aMutex
)
80 ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper
)
91 // -------------------------------------------------------------------------
92 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
95 // -------------------------------------------------------------------------
96 void ODatabaseMetaDataResultSet::construct()
98 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE
), PROPERTY_ID_FETCHSIZE
, 0,&m_nFetchSize
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
99 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE
), PROPERTY_ID_RESULTSETTYPE
, PropertyAttribute::READONLY
,&m_nResultSetType
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
100 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION
), PROPERTY_ID_FETCHDIRECTION
, 0, &m_nFetchDirection
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
101 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY
), PROPERTY_ID_RESULTSETCONCURRENCY
, PropertyAttribute::READONLY
,&m_nResultSetConcurrency
, ::getCppuType(reinterpret_cast<sal_Int32
*>(NULL
)));
103 // -----------------------------------------------------------------------------
104 void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType
)
108 case eCatalogs
: setCatalogsMap(); break;
109 case eSchemas
: setSchemasMap(); break;
110 case eColumnPrivileges
: setColumnPrivilegesMap(); break;
111 case eColumns
: setColumnsMap(); break;
112 case eTables
: setTablesMap(); break;
113 case eTableTypes
: setTableTypes(); break;
114 case eProcedureColumns
: setProcedureColumnsMap(); break;
115 case eProcedures
: setProceduresMap(); break;
116 case eExportedKeys
: setExportedKeysMap(); break;
117 case eImportedKeys
: setImportedKeysMap(); break;
118 case ePrimaryKeys
: setPrimaryKeysMap(); break;
119 case eIndexInfo
: setIndexInfoMap(); break;
120 case eTablePrivileges
: setTablePrivilegesMap(); break;
121 case eCrossReference
: setCrossReferenceMap(); break;
122 case eTypeInfo
: setTypeInfoMap(); break;
123 case eBestRowIdentifier
: setBestRowIdentifierMap(); break;
124 case eVersionColumns
: setVersionColumnsMap(); break;
126 OSL_ENSURE(0,"Wrong type!");
129 // -------------------------------------------------------------------------
130 void ODatabaseMetaDataResultSet::disposing(void)
132 OPropertySetHelper::disposing();
134 ::osl::MutexGuard
aGuard(m_aMutex
);
137 m_aRowsIter
= m_aRows
.end();
139 m_aRowsIter
= m_aRows
.end();
141 // -----------------------------------------------------------------------------
142 void SAL_CALL
ODatabaseMetaDataResultSet::acquire() throw()
144 ODatabaseMetaDataResultSet_BASE::acquire();
146 // -----------------------------------------------------------------------------
147 void SAL_CALL
ODatabaseMetaDataResultSet::release() throw()
149 ODatabaseMetaDataResultSet_BASE::release();
151 // -------------------------------------------------------------------------
152 Any SAL_CALL
ODatabaseMetaDataResultSet::queryInterface( const Type
& rType
) throw(RuntimeException
)
154 Any aRet
= OPropertySetHelper::queryInterface(rType
);
155 return aRet
.hasValue() ? aRet
: ODatabaseMetaDataResultSet_BASE::queryInterface(rType
);
157 // -------------------------------------------------------------------------
158 Sequence
< Type
> SAL_CALL
ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException
)
160 ::cppu::OTypeCollection
aTypes( ::getCppuType( (const Reference
< ::com::sun::star::beans::XMultiPropertySet
> *)0 ),
161 ::getCppuType( (const Reference
< ::com::sun::star::beans::XFastPropertySet
> *)0 ),
162 ::getCppuType( (const Reference
< ::com::sun::star::beans::XPropertySet
> *)0 ));
164 return ::comphelper::concatSequences(aTypes
.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
166 // -----------------------------------------------------------------------------
167 void ODatabaseMetaDataResultSet::setRows(const ORows
& _rRows
)
171 m_bEOF
= m_aRows
.empty();
173 // -------------------------------------------------------------------------
174 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString
& columnName
) throw(SQLException
, RuntimeException
)
176 ::osl::MutexGuard
aGuard( m_aMutex
);
177 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
180 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
181 sal_Int32 nLen
= xMeta
->getColumnCount();
184 if(xMeta
->isCaseSensitive(i
) ? columnName
== xMeta
->getColumnName(i
) :
185 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
))
190 // -----------------------------------------------------------------------------
191 void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
)
193 if(columnIndex
>= (sal_Int32
)(*m_aRowsIter
).size() || columnIndex
< 1)
194 ::dbtools::throwInvalidIndexException(*this);
196 // -------------------------------------------------------------------------
197 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
201 // -------------------------------------------------------------------------
202 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
207 // -------------------------------------------------------------------------
208 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
210 return getValue(columnIndex
);
212 // -------------------------------------------------------------------------
214 sal_Int8 SAL_CALL
ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
216 return getValue(columnIndex
);
218 // -------------------------------------------------------------------------
220 Sequence
< sal_Int8
> SAL_CALL
ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
222 return getValue(columnIndex
);
224 // -------------------------------------------------------------------------
226 ::com::sun::star::util::Date SAL_CALL
ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
228 return getValue(columnIndex
);
230 // -------------------------------------------------------------------------
232 double SAL_CALL
ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
234 return getValue(columnIndex
);
236 // -------------------------------------------------------------------------
238 float SAL_CALL
ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
240 return getValue(columnIndex
);
242 // -------------------------------------------------------------------------
244 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
246 return getValue(columnIndex
);
249 // -------------------------------------------------------------------------
251 sal_Int32 SAL_CALL
ODatabaseMetaDataResultSet::getRow( ) throw(SQLException
, RuntimeException
)
255 // -------------------------------------------------------------------------
257 sal_Int64 SAL_CALL
ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
259 return getValue(columnIndex
);
261 // -------------------------------------------------------------------------
263 Reference
< XResultSetMetaData
> SAL_CALL
ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException
, RuntimeException
)
265 ::osl::MutexGuard
aGuard( m_aMutex
);
266 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
269 if(!m_xMetaData
.is())
270 m_xMetaData
= new ODatabaseMetaDataResultSetMetaData();
274 // -------------------------------------------------------------------------
275 Reference
< XArray
> SAL_CALL
ODatabaseMetaDataResultSet::getArray( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
280 // -------------------------------------------------------------------------
282 Reference
< XClob
> SAL_CALL
ODatabaseMetaDataResultSet::getClob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
286 // -------------------------------------------------------------------------
287 Reference
< XBlob
> SAL_CALL
ODatabaseMetaDataResultSet::getBlob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
291 // -------------------------------------------------------------------------
293 Reference
< XRef
> SAL_CALL
ODatabaseMetaDataResultSet::getRef( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
297 // -------------------------------------------------------------------------
299 Any SAL_CALL
ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex
, const Reference
< ::com::sun::star::container::XNameAccess
>& /*typeMap*/ ) throw(SQLException
, RuntimeException
)
301 return getValue(columnIndex
).makeAny();
303 // -------------------------------------------------------------------------
305 sal_Int16 SAL_CALL
ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
307 return getValue(columnIndex
);
309 // -------------------------------------------------------------------------
311 ::rtl::OUString SAL_CALL
ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
313 return getValue(columnIndex
);
316 // -------------------------------------------------------------------------
319 ::com::sun::star::util::Time SAL_CALL
ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
321 return getValue(columnIndex
);
323 // -------------------------------------------------------------------------
326 ::com::sun::star::util::DateTime SAL_CALL
ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
328 return getValue(columnIndex
);
330 // -------------------------------------------------------------------------
332 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException
, RuntimeException
)
336 // -------------------------------------------------------------------------
337 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException
, RuntimeException
)
339 ::dbtools::throwFunctionSequenceException(*this);
342 // -------------------------------------------------------------------------
343 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isLast( ) throw(SQLException
, RuntimeException
)
345 ::dbtools::throwFunctionSequenceException(*this);
348 // -------------------------------------------------------------------------
349 void SAL_CALL
ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException
, RuntimeException
)
351 ::dbtools::throwFunctionSequenceException(*this);
353 // -------------------------------------------------------------------------
354 void SAL_CALL
ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException
, RuntimeException
)
356 ::dbtools::throwFunctionSequenceException(*this);
358 // -------------------------------------------------------------------------
360 void SAL_CALL
ODatabaseMetaDataResultSet::close( ) throw(SQLException
, RuntimeException
)
363 ::osl::MutexGuard
aGuard( m_aMutex
);
364 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
369 // -------------------------------------------------------------------------
371 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::first( ) throw(SQLException
, RuntimeException
)
373 ::dbtools::throwFunctionSequenceException(*this);
376 // -------------------------------------------------------------------------
378 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::last( ) throw(SQLException
, RuntimeException
)
380 ::dbtools::throwFunctionSequenceException(*this);
383 // -------------------------------------------------------------------------
384 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::absolute( sal_Int32
/*row*/ ) throw(SQLException
, RuntimeException
)
386 ::dbtools::throwFunctionSequenceException(*this);
389 // -------------------------------------------------------------------------
390 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::relative( sal_Int32
/*row*/ ) throw(SQLException
, RuntimeException
)
392 ::dbtools::throwFunctionSequenceException(*this);
395 // -------------------------------------------------------------------------
396 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::previous( ) throw(SQLException
, RuntimeException
)
398 ::dbtools::throwFunctionSequenceException(*this);
401 // -------------------------------------------------------------------------
402 Reference
< XInterface
> SAL_CALL
ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException
, RuntimeException
)
404 return m_aStatement
.get();
406 // -------------------------------------------------------------------------
408 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException
, RuntimeException
)
410 ::dbtools::throwFunctionSequenceException(*this);
413 // -------------------------------------------------------------------------
414 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException
, RuntimeException
)
416 ::dbtools::throwFunctionSequenceException(*this);
419 // -------------------------------------------------------------------------
420 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException
, RuntimeException
)
422 ::dbtools::throwFunctionSequenceException(*this);
425 // -------------------------------------------------------------------------
427 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException
, RuntimeException
)
431 // -------------------------------------------------------------------------
433 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::next( ) throw(SQLException
, RuntimeException
)
435 ::osl::MutexGuard
aGuard( m_aMutex
);
436 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
440 m_aRowsIter
= m_aRows
.begin();
446 throwFunctionSequenceException( *this );
448 if ( m_aRowsIter
!= m_aRows
.end() )
452 bool bSuccess
= m_aRowsIter
!= m_aRows
.end();
456 m_bBOF
= m_aRows
.empty();
460 // -------------------------------------------------------------------------
462 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException
, RuntimeException
)
464 ::osl::MutexGuard
aGuard( m_aMutex
);
465 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
468 if(m_aRowsIter
== m_aRows
.end() || !(*m_aRowsIter
)[m_nColPos
].isValid())
471 return (*m_aRowsIter
)[m_nColPos
]->getValue().isNull();
473 // -------------------------------------------------------------------------
474 void SAL_CALL
ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException
, RuntimeException
)
477 // -------------------------------------------------------------------------
479 void SAL_CALL
ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException
)
482 // -------------------------------------------------------------------------
483 void SAL_CALL
ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException
, RuntimeException
)
486 // -------------------------------------------------------------------------
487 Any SAL_CALL
ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException
, RuntimeException
)
491 // -------------------------------------------------------------------------
492 ::cppu::IPropertyArrayHelper
* ODatabaseMetaDataResultSet::createArrayHelper( ) const
494 Sequence
< Property
> aProps
;
495 describeProperties(aProps
);
496 return new ::cppu::OPropertyArrayHelper(aProps
);
498 // -------------------------------------------------------------------------
499 ::cppu::IPropertyArrayHelper
& ODatabaseMetaDataResultSet::getInfoHelper()
501 return *const_cast<ODatabaseMetaDataResultSet
*>(this)->getArrayHelper();
503 // -------------------------------------------------------------------------
504 void ODatabaseMetaDataResultSet::setProceduresMap()
506 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
507 pMetaData
->setProceduresMap();
508 m_xMetaData
= pMetaData
;
510 // -------------------------------------------------------------------------
511 void ODatabaseMetaDataResultSet::setCatalogsMap()
513 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
514 pMetaData
->setCatalogsMap();
515 m_xMetaData
= pMetaData
;
517 // -------------------------------------------------------------------------
518 void ODatabaseMetaDataResultSet::setSchemasMap()
520 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
521 pMetaData
->setSchemasMap();
522 m_xMetaData
= pMetaData
;
524 // -------------------------------------------------------------------------
525 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
527 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
528 pMetaData
->setColumnPrivilegesMap();
529 m_xMetaData
= pMetaData
;
531 // -------------------------------------------------------------------------
532 void ODatabaseMetaDataResultSet::setColumnsMap()
535 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
536 pMetaData
->setColumnsMap();
537 m_xMetaData
= pMetaData
;
539 // -------------------------------------------------------------------------
540 void ODatabaseMetaDataResultSet::setTablesMap()
543 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
544 pMetaData
->setTablesMap();
545 m_xMetaData
= pMetaData
;
547 // -------------------------------------------------------------------------
548 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
550 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
551 pMetaData
->setProcedureColumnsMap();
552 m_xMetaData
= pMetaData
;
554 // -------------------------------------------------------------------------
555 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
557 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
558 pMetaData
->setPrimaryKeysMap();
559 m_xMetaData
= pMetaData
;
561 // -------------------------------------------------------------------------
562 void ODatabaseMetaDataResultSet::setIndexInfoMap()
564 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
565 pMetaData
->setIndexInfoMap();
566 m_xMetaData
= pMetaData
;
568 // -------------------------------------------------------------------------
569 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
571 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
572 pMetaData
->setTablePrivilegesMap();
573 m_xMetaData
= pMetaData
;
575 // -------------------------------------------------------------------------
576 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
578 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
579 pMetaData
->setCrossReferenceMap();
580 m_xMetaData
= pMetaData
;
582 // -------------------------------------------------------------------------
583 void ODatabaseMetaDataResultSet::setVersionColumnsMap()
585 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
586 pMetaData
->setVersionColumnsMap();
587 m_xMetaData
= pMetaData
;
589 // -------------------------------------------------------------------------
590 void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
592 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
593 pMetaData
->setBestRowIdentifierMap();
594 m_xMetaData
= pMetaData
;
596 // -------------------------------------------------------------------------
597 void ODatabaseMetaDataResultSet::setTypeInfoMap()
599 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
600 pMetaData
->setTypeInfoMap();
601 m_xMetaData
= pMetaData
;
603 // -------------------------------------------------------------------------
604 void ODatabaseMetaDataResultSet::setTableTypes()
606 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
607 pMetaData
->setTableTypes();
608 m_xMetaData
= pMetaData
;
610 // -------------------------------------------------------------------------
611 void ODatabaseMetaDataResultSet::setExportedKeysMap()
613 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
614 pMetaData
->setExportedKeysMap();
615 m_xMetaData
= pMetaData
;
617 // -------------------------------------------------------------------------
618 void ODatabaseMetaDataResultSet::setImportedKeysMap()
620 ODatabaseMetaDataResultSetMetaData
* pMetaData
= new ODatabaseMetaDataResultSetMetaData();
621 pMetaData
->setImportedKeysMap();
622 m_xMetaData
= pMetaData
;
624 // -----------------------------------------------------------------------------
625 Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException
)
627 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
629 // -----------------------------------------------------------------------------
630 ORowSetValueDecorator
& ORowSetValueDecorator::operator=(const ORowSetValue
& _aValue
)
635 // -----------------------------------------------------------------------------
636 const ORowSetValue
& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex
)
638 ::osl::MutexGuard
aGuard( m_aMutex
);
639 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper
.bDisposed
);
641 if ( isBeforeFirst() || isAfterLast() )
642 ::dbtools::throwFunctionSequenceException( *this );
644 checkIndex(columnIndex
);
645 m_nColPos
= columnIndex
;
647 if(m_aRowsIter
!= m_aRows
.end() && (*m_aRowsIter
)[columnIndex
].isValid())
648 return *(*m_aRowsIter
)[columnIndex
];
649 return m_aEmptyValue
;
651 // -----------------------------------------------------------------------------
652 /// return an empty ORowSetValueDecorator
653 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getEmptyValue()
655 static ORowSetValueDecoratorRef aEmptyValueRef
= new ORowSetValueDecorator();
656 return aEmptyValueRef
;
658 // -----------------------------------------------------------------------------
659 /// return an ORowSetValueDecorator with 0 as value
660 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::get0Value()
662 static ORowSetValueDecoratorRef a0ValueRef
= new ORowSetValueDecorator((sal_Int32
)0);
665 // -----------------------------------------------------------------------------
666 /// return an ORowSetValueDecorator with 1 as value
667 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::get1Value()
669 static ORowSetValueDecoratorRef a1ValueRef
= new ORowSetValueDecorator((sal_Int32
)1);
672 // -----------------------------------------------------------------------------
673 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
674 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getBasicValue()
676 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(ColumnSearch::BASIC
);
679 // -----------------------------------------------------------------------------
680 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getSelectValue()
682 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("SELECT"));
685 // -----------------------------------------------------------------------------
686 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getInsertValue()
688 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INSERT"));
691 // -----------------------------------------------------------------------------
692 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getDeleteValue()
694 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DELETE"));
697 // -----------------------------------------------------------------------------
698 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getUpdateValue()
700 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("UPDATE"));
703 // -----------------------------------------------------------------------------
704 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getCreateValue()
706 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CREATE"));
709 // -----------------------------------------------------------------------------
710 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getReadValue()
712 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("READ"));
715 // -----------------------------------------------------------------------------
716 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getAlterValue()
718 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("ALTER"));
721 // -----------------------------------------------------------------------------
722 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getDropValue()
724 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DROP"));
727 // -----------------------------------------------------------------------------
728 ORowSetValueDecoratorRef
ODatabaseMetaDataResultSet::getQuoteValue()
730 static ORowSetValueDecoratorRef aValueRef
= new ORowSetValueDecorator(::rtl::OUString::createFromAscii("'"));
733 // -----------------------------------------------------------------------------
734 void SAL_CALL
ODatabaseMetaDataResultSet::initialize( const Sequence
< Any
>& _aArguments
) throw (Exception
, RuntimeException
)
736 if ( _aArguments
.getLength() == 2 )
738 sal_Int32 nResultSetType
= 0;
739 if ( _aArguments
[0] >>= nResultSetType
)
741 setType(static_cast<MetaDataResultSetType
>(nResultSetType
));
742 Sequence
< Sequence
<Any
> > aRows
;
743 if ( _aArguments
[1] >>= aRows
)
746 const Sequence
<Any
>* pRowsIter
= aRows
.getConstArray();
747 const Sequence
<Any
>* pRowsEnd
= pRowsIter
+ aRows
.getLength();
748 for (; pRowsIter
!= pRowsEnd
;++pRowsIter
)
751 const Any
* pRowIter
= pRowsIter
->getConstArray();
752 const Any
* pRowEnd
= pRowIter
+ pRowsIter
->getLength();
753 for (; pRowIter
!= pRowEnd
;++pRowIter
)
755 ORowSetValueDecoratorRef aValue
;
756 switch( pRowIter
->getValueTypeClass() )
758 case TypeClass_BOOLEAN
:
760 sal_Bool bValue
= sal_False
;
761 *pRowIter
>>= bValue
;
762 aValue
= new ORowSetValueDecorator(ORowSetValue(bValue
));
768 *pRowIter
>>= nValue
;
769 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
772 case TypeClass_SHORT
:
773 case TypeClass_UNSIGNED_SHORT
:
776 *pRowIter
>>= nValue
;
777 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
781 case TypeClass_UNSIGNED_LONG
:
784 *pRowIter
>>= nValue
;
785 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
788 case TypeClass_HYPER
:
789 case TypeClass_UNSIGNED_HYPER
:
792 *pRowIter
>>= nValue
;
793 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
796 case TypeClass_FLOAT
:
799 *pRowIter
>>= nValue
;
800 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
803 case TypeClass_DOUBLE
:
806 *pRowIter
>>= nValue
;
807 aValue
= new ORowSetValueDecorator(ORowSetValue(nValue
));
810 case TypeClass_STRING
:
812 ::rtl::OUString sValue
;
813 *pRowIter
>>= sValue
;
814 aValue
= new ORowSetValueDecorator(ORowSetValue(sValue
));
820 aRowToSet
.push_back(aValue
);
822 aRowsToSet
.push_back(aRowToSet
);
823 } // for (; pRowsIter != pRowsEnd;++pRowsIter
830 // --------------------------------------------------------------------------------
831 //------------------------------------------------------------------------------
832 rtl::OUString
ODatabaseMetaDataResultSet::getImplementationName_Static( ) throw(RuntimeException
)
834 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.helper.DatabaseMetaDataResultSet"));
836 //------------------------------------------------------------------------------
837 Sequence
< ::rtl::OUString
> ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) throw (RuntimeException
)
839 Sequence
< ::rtl::OUString
> aSNS( 1 );
840 aSNS
[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
843 //------------------------------------------------------------------
844 ::rtl::OUString SAL_CALL
ODatabaseMetaDataResultSet::getImplementationName( ) throw(RuntimeException
)
846 return getImplementationName_Static();
849 //------------------------------------------------------------------
850 sal_Bool SAL_CALL
ODatabaseMetaDataResultSet::supportsService( const ::rtl::OUString
& _rServiceName
) throw(RuntimeException
)
852 Sequence
< ::rtl::OUString
> aSupported(getSupportedServiceNames());
853 const ::rtl::OUString
* pSupported
= aSupported
.getConstArray();
854 const ::rtl::OUString
* pEnd
= pSupported
+ aSupported
.getLength();
855 for (;pSupported
!= pEnd
&& !pSupported
->equals(_rServiceName
); ++pSupported
)
858 return pSupported
!= pEnd
;
860 //------------------------------------------------------------------
861 Sequence
< ::rtl::OUString
> SAL_CALL
ODatabaseMetaDataResultSet::getSupportedServiceNames( ) throw(RuntimeException
)
863 return getSupportedServiceNames_Static();
865 // -------------------------------------------------------------------------
866 namespace connectivity
868 Reference
< XInterface
> SAL_CALL
ODatabaseMetaDataResultSet_CreateInstance(const Reference
< XComponentContext
>& ) throw( Exception
)
870 return *(new ODatabaseMetaDataResultSet());
874 // -----------------------------------------------------------------------------
877 cppu::ImplementationEntry entries
[] = {
878 { &ODatabaseMetaDataResultSet_CreateInstance
, &ODatabaseMetaDataResultSet::getImplementationName_Static
, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static
,
879 &cppu::createSingleComponentFactory
, 0, 0 },
880 { &ParameterSubstitution::create
, &ParameterSubstitution::getImplementationName_Static
, &ParameterSubstitution::getSupportedServiceNames_Static
,
881 &cppu::createSingleComponentFactory
, 0, 0 },
885 using ::rtl::OUString
;
886 using ::com::sun::star::uno::Reference
;
887 using ::com::sun::star::uno::Sequence
;
888 using ::com::sun::star::registry::XRegistryKey
;
889 using ::com::sun::star::registry::InvalidRegistryException
;
890 using ::com::sun::star::registry::InvalidValueException
;
891 using ::com::sun::star::lang::XMultiServiceFactory
;
893 //==========================================================================
895 //==========================================================================
899 //---------------------------------------------------------------------------------------
900 SAL_DLLPUBLIC_EXPORT
void SAL_CALL
component_getImplementationEnvironment(const sal_Char
** _ppEnvTypeName
, uno_Environment
** /*_ppEnv*/)
902 *_ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
905 //---------------------------------------------------------------------------------------
906 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL
component_writeInfo(void* serviceManager
, com::sun::star::registry::XRegistryKey
* registryKey
)
908 return cppu::component_writeInfoHelper(serviceManager
, registryKey
, entries
);
910 //---------------------------------------------------------------------------------------
911 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
component_getFactory(const sal_Char
* implName
, ::com::sun::star::lang::XMultiServiceFactory
* serviceManager
, void* registryKey
)
913 return cppu::component_getFactoryHelper(implName
, serviceManager
, registryKey
, entries
);