update credits
[LibreOffice.git] / include / ucbhelper / resultsetmetadata.hxx
blob35996657553a229a84ff6a3e76d08017c1358fde
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 .
20 #ifndef _UCBHELPER_RESULTSETMETADATA_HXX
21 #define _UCBHELPER_RESULTSETMETADATA_HXX
23 #include <vector>
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; }
36 } } }
38 namespace ucbhelper_impl {
39 struct ResultSetMetaData_Impl;
42 namespace ucbhelper
45 //=========================================================================
47 /**
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 */
55 sal_Bool isAutoIncrement;
57 /** @see ResultSetMetaData::isCaseSensitive */
58 sal_Bool isCaseSensitive;
60 /** @see ResultSetMetaData::isSearchable */
61 sal_Bool isSearchable;
63 /** @see ResultSetMetaData::isCurrency */
64 sal_Bool isCurrency;
66 /** @see ResultSetMetaData::isNullable */
67 sal_Int32 isNullable;
69 /** @see ResultSetMetaData::isSigned */
70 sal_Bool isSigned;
72 /** @see ResultSetMetaData::getColumnDisplaySize */
73 sal_Int32 columnDisplaySize;
75 /** @see ResultSetMetaData::getColumnLabel */
76 OUString columnLabel;
78 /** @see ResultSetMetaData::getSchemaName */
79 OUString schemaName;
81 /** @see ResultSetMetaData::getPrecision */
82 sal_Int32 precision;
84 /** @see ResultSetMetaData::getScale */
85 sal_Int32 scale;
87 /** @see ResultSetMetaData::getTableName */
88 OUString tableName;
90 /** @see ResultSetMetaData::getCatalogName */
91 OUString catalogName;
93 /** @see ResultSetMetaData::getColumnTypeName */
94 OUString columnTypeName;
96 /** @see ResultSetMetaData::isReadOnly */
97 sal_Bool isReadOnly;
99 /** @see ResultSetMetaData::isWritable */
100 sal_Bool isWritable;
102 /** @see ResultSetMetaData::isDefinitelyWritable */
103 sal_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( sal_False ),
116 isCaseSensitive( sal_True ),
117 isSearchable( sal_False ),
118 isCurrency( sal_False ),
119 isNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE ),
120 isSigned( sal_False ),
121 columnDisplaySize( 16 ),
122 precision( -1 ),
123 scale( 0 ),
124 isReadOnly( sal_True ),
125 isWritable( sal_False ),
126 isDefinitelyWritable( sal_False )
130 //=========================================================================
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
143 private:
144 ucbhelper_impl::ResultSetMetaData_Impl* m_pImpl;
146 protected:
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;
151 sal_Bool m_bReadOnly;
153 public:
156 * Constructor.
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
162 * is read-only.
164 ResultSetMetaData(
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 sal_Bool bReadOnly = sal_True );
172 * Constructor.
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 ], ...
184 ResultSetMetaData(
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 );
192 * Destructor.
194 virtual ~ResultSetMetaData();
196 // XInterface
197 XINTERFACE_DECL()
199 // XTypeProvider
200 XTYPEPROVIDER_DECL()
202 // XResultSetMetaData
205 * Returns the number of columns of the resultset.
207 * @return the length of the property sequence.
209 virtual sal_Int32 SAL_CALL
210 getColumnCount()
211 throw( ::com::sun::star::sdbc::SQLException,
212 ::com::sun::star::uno::RuntimeException );
214 * Checks whether column is automatically numbered, which makes it
215 * read-only.
217 * @param column is the number of the column for that a value shall
218 * be returned. The first column is 1, the second is 2, ...
219 * @return true, if column is automatically numbered.
221 virtual sal_Bool SAL_CALL
222 isAutoIncrement( sal_Int32 column )
223 throw( ::com::sun::star::sdbc::SQLException,
224 ::com::sun::star::uno::RuntimeException );
226 * Checks whether column is case sensitive.
228 * @param column is the number of the column for that a value shall
229 * be returned. The first column is 1, the second is 2, ...
230 * @return true, if column is case sensitive.
232 virtual sal_Bool SAL_CALL
233 isCaseSensitive( sal_Int32 column )
234 throw( ::com::sun::star::sdbc::SQLException,
235 ::com::sun::star::uno::RuntimeException );
237 * Checks whether the value stored in column can be used in a
238 * WHERE clause.
240 * @param column is the number of the column for that a value shall
241 * be returned. The first column is 1, the second is 2, ...
242 * @return true, if the column is searchable.
244 virtual sal_Bool SAL_CALL
245 isSearchable( sal_Int32 column )
246 throw( ::com::sun::star::sdbc::SQLException,
247 ::com::sun::star::uno::RuntimeException );
249 * Checks whether column is a cash value.
251 * @param column is the number of the column for that a value shall
252 * be returned. The first column is 1, the second is 2, ...
253 * @return true, if the column is a cash value.
255 virtual sal_Bool SAL_CALL
256 isCurrency( sal_Int32 column )
257 throw( ::com::sun::star::sdbc::SQLException,
258 ::com::sun::star::uno::RuntimeException );
260 * Checks whether a NULL can be stored in column.
262 * @see com::sun::star::sdbc::ColumnValue
264 * @param column is the number of the column for that a value shall
265 * be returned. The first column is 1, the second is 2, ...
266 * @return ::com::sun::star::sdbc::ColumnValue::NULLABLE, if a NULL
267 * can be stored in the column.
269 virtual sal_Int32 SAL_CALL
270 isNullable( sal_Int32 column )
271 throw( ::com::sun::star::sdbc::SQLException,
272 ::com::sun::star::uno::RuntimeException );
274 * Checks whether the value stored in column is a signed number.
276 * @param column is the number of the column for that a value shall
277 * be returned. The first column is 1, the second is 2, ...
278 * @return true, if the value stored in column is a signed number.
280 virtual sal_Bool SAL_CALL
281 isSigned( sal_Int32 column )
282 throw( ::com::sun::star::sdbc::SQLException,
283 ::com::sun::star::uno::RuntimeException );
285 * Gets the normal maximum width in characters for column.
287 * @param column is the number of the column for that a value shall
288 * be returned. The first column is 1, the second is 2, ...
289 * @return the normal maximum width in characters for column.
291 virtual sal_Int32 SAL_CALL
292 getColumnDisplaySize( sal_Int32 column )
293 throw( ::com::sun::star::sdbc::SQLException,
294 ::com::sun::star::uno::RuntimeException );
296 * Gets the suggested column title for column, to be used in print-
297 * outs and displays.
299 * @param column is the number of the column for that a value shall
300 * be returned. The first column is 1, the second is 2, ...
301 * @return the column label.
303 virtual OUString SAL_CALL
304 getColumnLabel( sal_Int32 column )
305 throw( ::com::sun::star::sdbc::SQLException,
306 ::com::sun::star::uno::RuntimeException );
308 * Gets the name of column.
310 * @param column is the number of the column for that a value shall
311 * be returned. The first column is 1, the second is 2, ...
312 * @return the name of the property that corresponds to column.
314 virtual OUString SAL_CALL
315 getColumnName( sal_Int32 column )
316 throw( ::com::sun::star::sdbc::SQLException,
317 ::com::sun::star::uno::RuntimeException );
319 * Gets the schema name for the table from which column of this
320 * result set was derived.
321 * Because this feature is not widely supported, the return value
322 * for many DBMSs will be an empty string.
324 * @param column is the number of the column for that a value shall
325 * be returned. The first column is 1, the second is 2, ...
326 * @return the schema name of column or an empty string.
328 virtual OUString SAL_CALL
329 getSchemaName( sal_Int32 column )
330 throw( ::com::sun::star::sdbc::SQLException,
331 ::com::sun::star::uno::RuntimeException );
333 * For number types, getprecision gets the number of decimal digits
334 * in column.
335 * For character types, it gets the maximum length in characters for
336 * column.
337 * For binary types, it gets the maximum length in bytes for column.
339 * @param column is the number of the column for that a value shall
340 * be returned. The first column is 1, the second is 2, ...
341 * @return the precision for the column.
343 virtual sal_Int32 SAL_CALL
344 getPrecision( sal_Int32 column )
345 throw( ::com::sun::star::sdbc::SQLException,
346 ::com::sun::star::uno::RuntimeException );
348 * Gets the number of digits to the right of the decimal point for
349 * values in column.
351 * @param column is the number of the column for that a value shall
352 * be returned. The first column is 1, the second is 2, ...
353 * @return the scale of the column.
355 virtual sal_Int32 SAL_CALL
356 getScale( sal_Int32 column )
357 throw( ::com::sun::star::sdbc::SQLException,
358 ::com::sun::star::uno::RuntimeException );
360 * Gets the name of the table from which column of this result set
361 * was derived or "" if there is none (for example, for a join).
362 * Because this feature is not widely supported, the return value
363 * for many DBMSs will be an empty string.
365 * @param column is the number of the column for that a value shall
366 * be returned. The first column is 1, the second is 2, ...
367 * @return the table name for column or an empty string.
369 virtual OUString SAL_CALL
370 getTableName( sal_Int32 column )
371 throw( ::com::sun::star::sdbc::SQLException,
372 ::com::sun::star::uno::RuntimeException );
373 virtual OUString SAL_CALL
375 * Gets the catalog name for the table from which column of this
376 * result set was derived.
377 * Because this feature is not widely supported, the return value
378 * for many DBMSs will be an empty string.
380 * @param column is the number of the column for that a value shall
381 * be returned. The first column is 1, the second is 2, ...
382 * @return the catalog name for column or an empty string.
384 getCatalogName( sal_Int32 column )
385 throw( ::com::sun::star::sdbc::SQLException,
386 ::com::sun::star::uno::RuntimeException );
388 * Gets the JDBC type for the value stored in column. ... The STRUCT
389 * and DISTINCT type codes are always returned for structured and
390 * distinct types, regardless of whether the value will be mapped
391 * according to the standard mapping or be a custom mapping.
393 * @param column is the number of the column for that a value shall
394 * be returned. The first column is 1, the second is 2, ...
395 * @return the type of the property that corresponds to column - mapped
396 * from UNO-Type to SQL-Type.
398 virtual sal_Int32 SAL_CALL
399 getColumnType( sal_Int32 column )
400 throw( ::com::sun::star::sdbc::SQLException,
401 ::com::sun::star::uno::RuntimeException );
403 * Gets the type name used by this particular data source for the
404 * values stored in column. If the type code for the type of value
405 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
406 * returns a fully-qualified SQL type name.
408 * @param column is the number of the column for that a value shall
409 * be returned. The first column is 1, the second is 2, ...
410 * @return the column type name.
412 virtual OUString SAL_CALL
413 getColumnTypeName( sal_Int32 column )
414 throw( ::com::sun::star::sdbc::SQLException,
415 ::com::sun::star::uno::RuntimeException );
417 * Indicates whether a column is definitely not writable.
419 * @param column is the number of the column for that a value shall
420 * be returned. The first column is 1, the second is 2, ...
421 * @return true, if the column is definetely not writable.
423 virtual sal_Bool SAL_CALL
424 isReadOnly( sal_Int32 column )
425 throw( ::com::sun::star::sdbc::SQLException,
426 ::com::sun::star::uno::RuntimeException );
428 * Indicates whether it is possible for a write on the column to succeed.
430 * @param column is the number of the column for that a value shall
431 * be returned. The first column is 1, the second is 2, ...
432 * @return true, if it is possible for a write to succeed.
434 virtual sal_Bool SAL_CALL
435 isWritable( sal_Int32 column )
436 throw( ::com::sun::star::sdbc::SQLException,
437 ::com::sun::star::uno::RuntimeException );
439 * Indicates whether a write on the column will definitely succeed.
441 * @param column is the number of the column for that a value shall
442 * be returned. The first column is 1, the second is 2, ...
443 * @return true, if a write on the column will definetely succeed.
445 virtual sal_Bool SAL_CALL
446 isDefinitelyWritable( sal_Int32 column )
447 throw( ::com::sun::star::sdbc::SQLException,
448 ::com::sun::star::uno::RuntimeException );
450 * Returns the fully-qualified name of the service whose instances
451 * are manufactured if the method
452 * com::sun::star::sdbc::ResultSet::getObject is called to retrieve a
453 * value from the column.
455 * @param column is the number of the column for that a value shall
456 * be returned. The first column is 1, the second is 2, ...
457 * @return the service name for column or an empty string, if no service
458 * is applicable.
460 virtual OUString SAL_CALL
461 getColumnServiceName( sal_Int32 column )
462 throw( ::com::sun::star::sdbc::SQLException,
463 ::com::sun::star::uno::RuntimeException );
466 } // namespace ucbhelper
468 #endif /* !_UCBHELPER_RESULTSETMETADATA_HXX */
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */