1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24#ifndef __com_sun_star_sdb_tools_XConnectionTools_idl__
25#define __com_sun_star_sdb_tools_XConnectionTools_idl__
26
27#ifndef __com_sun_star_uno_XInterface_idl__
28#include <com/sun/star/uno/XInterface.idl>
29#endif
30#ifndef __com_sun_star_sdbc_SQLException_idl__
31#include <com/sun/star/sdbc/SQLException.idl>
32#endif
33
34module com {  module sun {  module star {
35    module container {
36        published interface XNameAccess;
37    };
38    module lang {
39        published interface XComponent;
40    };
41};};};
42//=============================================================================
43module com {  module sun {  module star {  module sdb {
44    published interface XSingleSelectQueryComposer;
45    module tools {
46//=============================================================================
47
48published interface XTableName;
49published interface XObjectNames;
50published interface XDataSourceMetaData;
51
52//-----------------------------------------------------------------------------
53/** encapsulates various useful functionality around a
54    <type scope="com::sun::star::sdb">Connection</type>
55
56    <p>Most of the functionality provided here is meaningful only relative to
57    a given database connection. For instance, for quoting table names, you need
58    the meta data instance of the connection. Thus, the entry point for obtaining
59    a <type>XConnectionTools</type> instance is the
60    <type scope="com::sun::star::sdb">Connection</type> service.</p>
61
62    <p>Note that nearly all functionality provided by this interface is also
63    available by other means, it's only provided here for convenience purposes.</p>
64
65    @since OOo 2.0.4
66*/
67published interface XConnectionTools
68{
69    /** creates an instance supporting the <type>XTableName</type> interface,
70        which can be used to manipulate table names for various purposes.
71
72        <p>The returned object is guanrateed to not be <NULL/>.</p>
73    */
74    XTableName      createTableName();
75
76    /** returns an instance supporting the <type>XObjectNames</type> interface,
77        which provides access to functionality around table and query names.
78
79        <p>The returned object is guanrateed to not be <NULL/>.</p>
80    */
81    XObjectNames    getObjectNames();
82
83    /** provides access to the application-level data source meta data
84    */
85    XDataSourceMetaData
86                    getDataSourceMetaData();
87
88    /** get fields for a result set given by a "command descriptor"
89
90        <p>A command descriptor here means:
91        <ul><li>a SDB-level connection (<type scope="com.sun.star.sdb">Connection</type></li>
92            <li>a string specifying the name of an object relative to the connection</li>
93            <li>a <type scope="com.sun.star.sdb">CommandType</type> value specifying the type
94                of the object</type></li>
95        </ul>
96        </p>
97
98        @param commandType
99            the type of the object
100
101        @param command
102            the object. This may be a table name, a query name, or an SQL statement, depending on the value
103            of <arg>_nCommandType</arg>
104
105        @param _rxCollectionOner
106            If (and only if) <arg>CommandType</arg> is CommandType.COMMAND, the fields collection which is returned
107            by this function here is a temporary object. It is kept alive by another object, which is to be
108            created temporarily, too. To ensure that the fields you get are valid as long as you need them,
109            the owner which controls their life time is transfered to this parameter upon return.<br/>
110
111            Your fields live as long as this component lives.<br/>
112
113            Additionally, you are encouraged to dispose this component as soon as you don't need the fields anymore.
114            It depends on the connection's implementation if this is necessary, but the is no guarantee, so to
115            be on the safe side with respect to resource leaks, you should dispose the component.
116
117        @return
118            the container of the columns (aka fields) of the object
119    */
120    ::com::sun::star::container::XNameAccess getFieldsByCommandDescriptor(  [in] long commandType,
121                                                                            [in] string command,
122                                                                            [out] ::com::sun::star::lang::XComponent  keepFieldsAlive
123                                                                            ) raises( com::sun::star::sdbc::SQLException );
124
125    /** get the composer initialized with a command and command type.
126        @param commandType
127            the type of the object
128
129        @param command
130            the object. This may be a table name, a query name, or an SQL statement, depending on the value
131            of <arg>_nCommandType</arg>
132        @return
133            the composer filled with command and command type.
134    */
135    ::com::sun::star::sdb::XSingleSelectQueryComposer getComposer([in] long commandType,[in] string command);
136};
137
138//=============================================================================
139}; }; }; }; };
140//=============================================================================
141
142#endif
143