1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27
28#ifndef __com_sun_star_sdb_tools_XConnectionTools_idl__
29#define __com_sun_star_sdb_tools_XConnectionTools_idl__
30
31#ifndef __com_sun_star_uno_XInterface_idl__
32#include <com/sun/star/uno/XInterface.idl>
33#endif
34#ifndef __com_sun_star_sdbc_SQLException_idl__
35#include <com/sun/star/sdbc/SQLException.idl>
36#endif
37
38module com {  module sun {  module star {
39    module container {
40        published interface XNameAccess;
41    };
42    module lang {
43        published interface XComponent;
44    };
45};};};
46//=============================================================================
47module com {  module sun {  module star {  module sdb {
48    published interface XSingleSelectQueryComposer;
49    module tools {
50//=============================================================================
51
52published interface XTableName;
53published interface XObjectNames;
54published interface XDataSourceMetaData;
55
56//-----------------------------------------------------------------------------
57/** encapsulates various useful functionality around a
58    <type scope="com::sun::star::sdb">Connection</type>
59
60    <p>Most of the functionality provided here is meaningful only relative to
61    a given database connection. For instance, for quoting table names, you need
62    the meta data instance of the connection. Thus, the entry point for obtaining
63    a <type>XConnectionTools</type> instance is the
64    <type scope="com::sun::star::sdb">Connection</type> service.</p>
65
66    <p>Note that nearly all functionality provided by this interface is also
67    available by other means, it's only provided here for convenience purposes.</p>
68
69    @since OOo 2.0.4
70*/
71published interface XConnectionTools
72{
73    /** creates an instance supporting the <type>XTableName</type> interface,
74        which can be used to manipulate table names for various purposes.
75
76        <p>The returned object is guanrateed to not be <NULL/>.</p>
77    */
78    XTableName      createTableName();
79
80    /** returns an instance supporting the <type>XObjectNames</type> interface,
81        which provides access to functionality around table and query names.
82
83        <p>The returned object is guanrateed to not be <NULL/>.</p>
84    */
85    XObjectNames    getObjectNames();
86
87    /** provides access to the application-level data source meta data
88    */
89    XDataSourceMetaData
90                    getDataSourceMetaData();
91
92    /** get fields for a result set given by a "command descriptor"
93
94        <p>A command descriptor here means:
95        <ul><li>a SDB-level connection (<type scope="com.sun.star.sdb">Connection</type></li>
96            <li>a string specifying the name of an object relative to the connection</li>
97            <li>a <type scope="com.sun.star.sdb">CommandType</type> value specifying the type
98                of the object</type></li>
99        </ul>
100        </p>
101
102        @param commandType
103            the type of the object
104
105        @param command
106            the object. This may be a table name, a query name, or an SQL statement, depending on the value
107            of <arg>_nCommandType</arg>
108
109        @param _rxCollectionOner
110            If (and only if) <arg>CommandType</arg> is CommandType.COMMAND, the fields collection which is returned
111            by this function here is a temporary object. It is kept alive by another object, which is to be
112            created temporarily, too. To ensure that the fields you get are valid as long as you need them,
113            the owner which controls their life time is transfered to this parameter upon return.<br/>
114
115            Your fields live as long as this component lives.<br/>
116
117            Additionally, you are encouraged to dispose this component as soon as you don't need the fields anymore.
118            It depends on the connection's implementation if this is necessary, but the is no guarantee, so to
119            be on the safe side with respect to resource leaks, you should dispose the component.
120
121        @return
122            the container of the columns (aka fields) of the object
123    */
124    ::com::sun::star::container::XNameAccess getFieldsByCommandDescriptor(  [in] long commandType,
125                                                                            [in] string command,
126                                                                            [out] ::com::sun::star::lang::XComponent  keepFieldsAlive
127                                                                            ) raises( com::sun::star::sdbc::SQLException );
128
129    /** get the composer initialized with a command and command type.
130        @param commandType
131            the type of the object
132
133        @param command
134            the object. This may be a table name, a query name, or an SQL statement, depending on the value
135            of <arg>_nCommandType</arg>
136        @return
137            the composer filled with command and command type.
138    */
139    ::com::sun::star::sdb::XSingleSelectQueryComposer getComposer([in] long commandType,[in] string command);
140};
141
142//=============================================================================
143}; }; }; }; };
144//=============================================================================
145
146#endif
147