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 #ifndef INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX
21 #define INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/lang/XTypeProvider.hpp>
27 #include <com/sun/star/sdbc/ColumnValue.hpp>
28 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
29 #include <cppuhelper/weak.hxx>
30 #include <ucbhelper/macros.hxx>
31 #include <ucbhelper/ucbhelperdllapi.h>
33 namespace com
{ namespace sun
{ namespace star
{
34 namespace lang
{ class XMultiServiceFactory
; }
35 namespace beans
{ struct Property
; }
38 namespace ucbhelper_impl
{
39 struct ResultSetMetaData_Impl
;
48 * This is a structure that holds additional meta data for one column
49 * of a resultset. The default values set in the constructor should be a
50 * good guess for many UCB use cases.
52 struct ResultSetColumnData
54 /** @see ResultSetMetaData::isAutoIncrement */
57 /** @see ResultSetMetaData::isCaseSensitive */
60 /** @see ResultSetMetaData::isSearchable */
63 /** @see ResultSetMetaData::isCurrency */
66 /** @see ResultSetMetaData::isNullable */
69 /** @see ResultSetMetaData::isSigned */
72 /** @see ResultSetMetaData::getColumnDisplaySize */
73 sal_Int32 columnDisplaySize
;
75 /** @see ResultSetMetaData::getColumnLabel */
78 /** @see ResultSetMetaData::getSchemaName */
81 /** @see ResultSetMetaData::getPrecision */
84 /** @see ResultSetMetaData::getScale */
87 /** @see ResultSetMetaData::getTableName */
90 /** @see ResultSetMetaData::getCatalogName */
93 /** @see ResultSetMetaData::getColumnTypeName */
94 OUString columnTypeName
;
96 /** @see ResultSetMetaData::isReadOnly */
99 /** @see ResultSetMetaData::isWritable */
102 /** @see ResultSetMetaData::isDefinitelyWritable */
103 bool isDefinitelyWritable
;
105 /** @see ResultSetMetaData::getColumnServiceName */
106 OUString columnServiceName
;
108 inline ResultSetColumnData();
111 // Note: Never change the initial values! Implementations using this struct
112 // may havily depend on the behaviour of the default constructor.
114 ResultSetColumnData::ResultSetColumnData()
115 : isAutoIncrement( false ),
116 isCaseSensitive( true ),
117 isSearchable( false ),
119 isNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE
),
121 columnDisplaySize( 16 ),
126 isDefinitelyWritable( false )
133 * This is an implementation of the interface XResultSetMetaData. It can be
134 * used to implement the interface
135 * com::sun::star::sdbc::XResultSetMetaDataSupplier, which is required for
136 * implementations of service com.sun.star.ucb.ContentResultSet.
138 class UCBHELPER_DLLPUBLIC ResultSetMetaData
:
139 public ::cppu::OWeakObject
,
140 public ::com::sun::star::lang::XTypeProvider
,
141 public ::com::sun::star::sdbc::XResultSetMetaData
144 ucbhelper_impl::ResultSetMetaData_Impl
* m_pImpl
;
147 ::com::sun::star::uno::Reference
<
148 ::com::sun::star::uno::XComponentContext
> m_xContext
;
149 ::com::sun::star::uno::Sequence
<
150 ::com::sun::star::beans::Property
> m_aProps
;
158 * @param rxSMgr is a Servive Manager.
159 * @param rProps is a sequence of properties (partially) describing the
160 * columns of a resultset.
161 * @param bReadOnly is used to specify whether the whole(!) resultset
165 const ::com::sun::star::uno::Reference
<
166 ::com::sun::star::uno::XComponentContext
>& rxContext
,
167 const ::com::sun::star::uno::Sequence
<
168 ::com::sun::star::beans::Property
>& rProps
,
169 bool bReadOnly
= true );
174 * @param rxSMgr is a Servive Manager.
175 * @param rProps is a sequence of properties (partially) describing the
176 * columns of a resultset.
177 * @param rColumnData contains additional meta data for the columns of
178 * a resultset, which override the default values returned by the
179 * appropriate methods of this class. The length of rColumnData
180 * must be the same as length of rProps.
181 * rColumnData[ 0 ] corresponds to data in rProps[ 0 ],
182 * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ...
185 const ::com::sun::star::uno::Reference
<
186 ::com::sun::star::uno::XComponentContext
>& rxContext
,
187 const ::com::sun::star::uno::Sequence
<
188 ::com::sun::star::beans::Property
>& rProps
,
189 const std::vector
< ResultSetColumnData
>& rColumnData
);
194 virtual ~ResultSetMetaData();
197 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
198 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 virtual void SAL_CALL
acquire()
200 throw() SAL_OVERRIDE
;
201 virtual void SAL_CALL
release()
202 throw() SAL_OVERRIDE
;
205 virtual com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
206 getImplementationId()
207 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
208 virtual com::sun::star::uno::Sequence
< com::sun::star::uno::Type
> SAL_CALL
210 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
212 // XResultSetMetaData
215 * Returns the number of columns of the resultset.
217 * @return the length of the property sequence.
219 virtual sal_Int32 SAL_CALL
221 throw( ::com::sun::star::sdbc::SQLException
,
222 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
224 * Checks whether column is automatically numbered, which makes it
227 * @param column is the number of the column for that a value shall
228 * be returned. The first column is 1, the second is 2, ...
229 * @return true, if column is automatically numbered.
231 virtual sal_Bool SAL_CALL
232 isAutoIncrement( sal_Int32 column
)
233 throw( ::com::sun::star::sdbc::SQLException
,
234 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
236 * Checks whether column is case sensitive.
238 * @param column is the number of the column for that a value shall
239 * be returned. The first column is 1, the second is 2, ...
240 * @return true, if column is case sensitive.
242 virtual sal_Bool SAL_CALL
243 isCaseSensitive( sal_Int32 column
)
244 throw( ::com::sun::star::sdbc::SQLException
,
245 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
247 * Checks whether the value stored in column can be used in a
250 * @param column is the number of the column for that a value shall
251 * be returned. The first column is 1, the second is 2, ...
252 * @return true, if the column is searchable.
254 virtual sal_Bool SAL_CALL
255 isSearchable( sal_Int32 column
)
256 throw( ::com::sun::star::sdbc::SQLException
,
257 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
259 * Checks whether column is a cash value.
261 * @param column is the number of the column for that a value shall
262 * be returned. The first column is 1, the second is 2, ...
263 * @return true, if the column is a cash value.
265 virtual sal_Bool SAL_CALL
266 isCurrency( sal_Int32 column
)
267 throw( ::com::sun::star::sdbc::SQLException
,
268 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
270 * Checks whether a NULL can be stored in column.
272 * @see com::sun::star::sdbc::ColumnValue
274 * @param column is the number of the column for that a value shall
275 * be returned. The first column is 1, the second is 2, ...
276 * @return ::com::sun::star::sdbc::ColumnValue::NULLABLE, if a NULL
277 * can be stored in the column.
279 virtual sal_Int32 SAL_CALL
280 isNullable( sal_Int32 column
)
281 throw( ::com::sun::star::sdbc::SQLException
,
282 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
284 * Checks whether the value stored in column is a signed number.
286 * @param column is the number of the column for that a value shall
287 * be returned. The first column is 1, the second is 2, ...
288 * @return true, if the value stored in column is a signed number.
290 virtual sal_Bool SAL_CALL
291 isSigned( sal_Int32 column
)
292 throw( ::com::sun::star::sdbc::SQLException
,
293 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
295 * Gets the normal maximum width in characters for column.
297 * @param column is the number of the column for that a value shall
298 * be returned. The first column is 1, the second is 2, ...
299 * @return the normal maximum width in characters for column.
301 virtual sal_Int32 SAL_CALL
302 getColumnDisplaySize( sal_Int32 column
)
303 throw( ::com::sun::star::sdbc::SQLException
,
304 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
306 * Gets the suggested column title for column, to be used in print-
309 * @param column is the number of the column for that a value shall
310 * be returned. The first column is 1, the second is 2, ...
311 * @return the column label.
313 virtual OUString SAL_CALL
314 getColumnLabel( sal_Int32 column
)
315 throw( ::com::sun::star::sdbc::SQLException
,
316 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
318 * Gets the name of column.
320 * @param column is the number of the column for that a value shall
321 * be returned. The first column is 1, the second is 2, ...
322 * @return the name of the property that corresponds to column.
324 virtual OUString SAL_CALL
325 getColumnName( sal_Int32 column
)
326 throw( ::com::sun::star::sdbc::SQLException
,
327 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
329 * Gets the schema name for the table from which column of this
330 * result set was derived.
331 * Because this feature is not widely supported, the return value
332 * for many DBMSs will be an empty string.
334 * @param column is the number of the column for that a value shall
335 * be returned. The first column is 1, the second is 2, ...
336 * @return the schema name of column or an empty string.
338 virtual OUString SAL_CALL
339 getSchemaName( sal_Int32 column
)
340 throw( ::com::sun::star::sdbc::SQLException
,
341 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
343 * For number types, getprecision gets the number of decimal digits
345 * For character types, it gets the maximum length in characters for
347 * For binary types, it gets the maximum length in bytes for column.
349 * @param column is the number of the column for that a value shall
350 * be returned. The first column is 1, the second is 2, ...
351 * @return the precision for the column.
353 virtual sal_Int32 SAL_CALL
354 getPrecision( sal_Int32 column
)
355 throw( ::com::sun::star::sdbc::SQLException
,
356 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
358 * Gets the number of digits to the right of the decimal point for
361 * @param column is the number of the column for that a value shall
362 * be returned. The first column is 1, the second is 2, ...
363 * @return the scale of the column.
365 virtual sal_Int32 SAL_CALL
366 getScale( sal_Int32 column
)
367 throw( ::com::sun::star::sdbc::SQLException
,
368 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
370 * Gets the name of the table from which column of this result set
371 * was derived or "" if there is none (for example, for a join).
372 * Because this feature is not widely supported, the return value
373 * for many DBMSs will be an empty string.
375 * @param column is the number of the column for that a value shall
376 * be returned. The first column is 1, the second is 2, ...
377 * @return the table name for column or an empty string.
379 virtual OUString SAL_CALL
380 getTableName( sal_Int32 column
)
381 throw( ::com::sun::star::sdbc::SQLException
,
382 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
383 virtual OUString SAL_CALL
385 * Gets the catalog name for the table from which column of this
386 * result set was derived.
387 * Because this feature is not widely supported, the return value
388 * for many DBMSs will be an empty string.
390 * @param column is the number of the column for that a value shall
391 * be returned. The first column is 1, the second is 2, ...
392 * @return the catalog name for column or an empty string.
394 getCatalogName( sal_Int32 column
)
395 throw( ::com::sun::star::sdbc::SQLException
,
396 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
398 * Gets the JDBC type for the value stored in column. ... The STRUCT
399 * and DISTINCT type codes are always returned for structured and
400 * distinct types, regardless of whether the value will be mapped
401 * according to the standard mapping or be a custom mapping.
403 * @param column is the number of the column for that a value shall
404 * be returned. The first column is 1, the second is 2, ...
405 * @return the type of the property that corresponds to column - mapped
406 * from UNO-Type to SQL-Type.
408 virtual sal_Int32 SAL_CALL
409 getColumnType( sal_Int32 column
)
410 throw( ::com::sun::star::sdbc::SQLException
,
411 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
413 * Gets the type name used by this particular data source for the
414 * values stored in column. If the type code for the type of value
415 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
416 * returns a fully-qualified SQL type name.
418 * @param column is the number of the column for that a value shall
419 * be returned. The first column is 1, the second is 2, ...
420 * @return the column type name.
422 virtual OUString SAL_CALL
423 getColumnTypeName( sal_Int32 column
)
424 throw( ::com::sun::star::sdbc::SQLException
,
425 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
427 * Indicates whether a column is definitely not writable.
429 * @param column is the number of the column for that a value shall
430 * be returned. The first column is 1, the second is 2, ...
431 * @return true, if the column is definetely not writable.
433 virtual sal_Bool SAL_CALL
434 isReadOnly( sal_Int32 column
)
435 throw( ::com::sun::star::sdbc::SQLException
,
436 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
438 * Indicates whether it is possible for a write on the column to succeed.
440 * @param column is the number of the column for that a value shall
441 * be returned. The first column is 1, the second is 2, ...
442 * @return true, if it is possible for a write to succeed.
444 virtual sal_Bool SAL_CALL
445 isWritable( sal_Int32 column
)
446 throw( ::com::sun::star::sdbc::SQLException
,
447 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
449 * Indicates whether a write on the column will definitely succeed.
451 * @param column is the number of the column for that a value shall
452 * be returned. The first column is 1, the second is 2, ...
453 * @return true, if a write on the column will definetely succeed.
455 virtual sal_Bool SAL_CALL
456 isDefinitelyWritable( sal_Int32 column
)
457 throw( ::com::sun::star::sdbc::SQLException
,
458 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
460 * Returns the fully-qualified name of the service whose instances
461 * are manufactured if the method
462 * com::sun::star::sdbc::ResultSet::getObject is called to retrieve a
463 * value from the column.
465 * @param column is the number of the column for that a value shall
466 * be returned. The first column is 1, the second is 2, ...
467 * @return the service name for column or an empty string, if no service
470 virtual OUString SAL_CALL
471 getColumnServiceName( sal_Int32 column
)
472 throw( ::com::sun::star::sdbc::SQLException
,
473 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
476 } // namespace ucbhelper
478 #endif /* ! INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX */
480 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */