xref: /AOO42X/main/offapi/com/sun/star/sdb/tools/XObjectNames.idl (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir/*************************************************************************
2*cdf0e10cSrcweir *
3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir *
5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir *
7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir *
9*cdf0e10cSrcweir * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir *
11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir *
15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir *
21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir *
26*cdf0e10cSrcweir ************************************************************************/
27*cdf0e10cSrcweir
28*cdf0e10cSrcweir#ifndef __com_sun_star_sdb_tools_XObjectNames_idl__
29*cdf0e10cSrcweir#define __com_sun_star_sdb_tools_XObjectNames_idl__
30*cdf0e10cSrcweir
31*cdf0e10cSrcweir#ifndef __com_sun_star_lang_IllegalArgumentException_idl__
32*cdf0e10cSrcweir#include <com/sun/star/lang/IllegalArgumentException.idl>
33*cdf0e10cSrcweir#endif
34*cdf0e10cSrcweir
35*cdf0e10cSrcweir#ifndef __com_sun_star_sdbc_SQLException_idl__
36*cdf0e10cSrcweir#include <com/sun/star/sdbc/SQLException.idl>
37*cdf0e10cSrcweir#endif
38*cdf0e10cSrcweir
39*cdf0e10cSrcweir//=============================================================================
40*cdf0e10cSrcweirmodule com {  module sun {  module star {  module sdb { module tools {
41*cdf0e10cSrcweir//=============================================================================
42*cdf0e10cSrcweir
43*cdf0e10cSrcweir//-----------------------------------------------------------------------------
44*cdf0e10cSrcweir/** encapsulates functionality which you might find useful when writing a
45*cdf0e10cSrcweir    database application which deals with query and table names.
46*cdf0e10cSrcweir
47*cdf0e10cSrcweir    <p>The most important task fulfilled by this instance is that it hides
48*cdf0e10cSrcweir    different naming restrictions from you, which are caused by server-side
49*cdf0e10cSrcweir    or client side specialities.</p>
50*cdf0e10cSrcweir
51*cdf0e10cSrcweir    <p>For instance, it can validate names against
52*cdf0e10cSrcweir    the characters allowed in the object names of a connection. Also, it
53*cdf0e10cSrcweir    relieves you from caring whether a database supports queries in a <code>SELECT</code>
54*cdf0e10cSrcweir    statment's <code>FROM</code> part (known as "queries in queries"). In such
55*cdf0e10cSrcweir    databases, query and table names share a common namespace, thus they must be
56*cdf0e10cSrcweir    unique. Using this interface, you can easily ensure this uniqueness.</p>
57*cdf0e10cSrcweir
58*cdf0e10cSrcweir    <p>All of the functionality present in this interface depends on a connection,
59*cdf0e10cSrcweir    thus it entry point for obtaining it is a <type scope="com::sun::star::sdb">Connection</type>
60*cdf0e10cSrcweir    service.</p>
61*cdf0e10cSrcweir
62*cdf0e10cSrcweir    <p>The component itself does not have life-time control mechanimns, i.e. you
63*cdf0e10cSrcweir    cannot explicitly dispose it (<member scope="com::sun::star::lang">XComponent::dispose</member>),
64*cdf0e10cSrcweir    and you cannot be notified when it dies.<br/>
65*cdf0e10cSrcweir    However, if your try to access any of its methods or attributes, after the
66*cdf0e10cSrcweir    connection which was used to create it was closed, a <type scope="com::sun::star::lang">DisposedException</type>
67*cdf0e10cSrcweir    will be thrown.</p>
68*cdf0e10cSrcweir
69*cdf0e10cSrcweir    @see XConnectionTools
70*cdf0e10cSrcweir
71*cdf0e10cSrcweir    @since OOo 2.0.4
72*cdf0e10cSrcweir*/
73*cdf0e10cSrcweirpublished interface XObjectNames
74*cdf0e10cSrcweir{
75*cdf0e10cSrcweir    /** suggests a (unique) table or query name
76*cdf0e10cSrcweir
77*cdf0e10cSrcweir        <p>If in the database, tables and queries share a common namespace, this will be respected
78*cdf0e10cSrcweir        by this function.</p>
79*cdf0e10cSrcweir
80*cdf0e10cSrcweir        <p>Note that in an multi-threaded environment, the name you obtain here is not absolutely
81*cdf0e10cSrcweir        guaranteed to be unique. It is unique at the very moment the function returns to you.
82*cdf0e10cSrcweir        But already when you evaluate the returned value, it might not be uniquey anymore, if
83*cdf0e10cSrcweir        another process or thread created a query or table with this name.</p>
84*cdf0e10cSrcweir
85*cdf0e10cSrcweir        <p>This implies that you cannot rely on the name's uniqueness, but you can use it as
86*cdf0e10cSrcweir        first guess to present to the user. In most cases, it will still be sufficient when
87*cdf0e10cSrcweir        you are actually creating the table respectively query.</p>
88*cdf0e10cSrcweir
89*cdf0e10cSrcweir        @param CommandType
90*cdf0e10cSrcweir            specifies the <type scope="com::sun::star::sdb">CommandType</type> of the object for which
91*cdf0e10cSrcweir            a unique name is to be generated. Must be either <member scope="com::sun::star::sdb">CommandType::TABLE</member>
92*cdf0e10cSrcweir            or <member scope="com::sun::star::sdb">CommandType::QUERY</member>.
93*cdf0e10cSrcweir
94*cdf0e10cSrcweir        @param BaseName
95*cdf0e10cSrcweir            specifies the base of the to-be-created object name. If empty, a default
96*cdf0e10cSrcweir            base name will be used.
97*cdf0e10cSrcweir
98*cdf0e10cSrcweir        @throws com::sun::star::lang::IllegalArgumentException
99*cdf0e10cSrcweir            if <arg>CommandType</arg> specifies an invalid command type.
100*cdf0e10cSrcweir    */
101*cdf0e10cSrcweir    string  suggestName( [in] long CommandType, [in] string BaseName )
102*cdf0e10cSrcweir        raises ( com::sun::star::lang::IllegalArgumentException );
103*cdf0e10cSrcweir
104*cdf0e10cSrcweir    /** converts the given object name to a name which is valid in the database.
105*cdf0e10cSrcweir
106*cdf0e10cSrcweir        <p>The conversion takes place by converting every character which is neither
107*cdf0e10cSrcweir        allowed by the SQL-92 standard, nor part of the special characters supported
108*cdf0e10cSrcweir        by the database, with an underscore character (_).</p>
109*cdf0e10cSrcweir
110*cdf0e10cSrcweir        @see com::sun::star::sdbc::XDatabaseMetaData::getExtraNameCharacters
111*cdf0e10cSrcweir    */
112*cdf0e10cSrcweir    string  convertToSQLName( [in] string Name );
113*cdf0e10cSrcweir
114*cdf0e10cSrcweir    /** checks whether a given name is used as table respectively query name in the database.
115*cdf0e10cSrcweir
116*cdf0e10cSrcweir        <p>If in the database, tables and queries share a common namespace, this will be respected
117*cdf0e10cSrcweir        by this function.</p>
118*cdf0e10cSrcweir
119*cdf0e10cSrcweir        <p>As before, the information you obtain by calling this method might be obsolete
120*cdf0e10cSrcweir        in the very moment you evaluate this, in case another process or thread interferes.
121*cdf0e10cSrcweir        However, it's usually sufficiently up-to-date for purpose of using it in a database
122*cdf0e10cSrcweir        application driven by user interactions.</p>
123*cdf0e10cSrcweir
124*cdf0e10cSrcweir        @param CommandType
125*cdf0e10cSrcweir            specifies the <type scope="com::sun::star::sdb">CommandType</type> of the object whose
126*cdf0e10cSrcweir            name should be checked. Must be either <member scope="com::sun::star::sdb">CommandType::TABLE</member>
127*cdf0e10cSrcweir            or <member scope="com::sun::star::sdb">CommandType::QUERY</member>.
128*cdf0e10cSrcweir
129*cdf0e10cSrcweir        @param Name
130*cdf0e10cSrcweir            specifies the to-be-checked name of the object.
131*cdf0e10cSrcweir
132*cdf0e10cSrcweir        @return
133*cdf0e10cSrcweir            <TRUE/> if and only if the given name is legitimate as table respectively query name
134*cdf0e10cSrcweir            to be used in the database.
135*cdf0e10cSrcweir
136*cdf0e10cSrcweir        @throws com::sun::star::lang::IllegalArgumentException
137*cdf0e10cSrcweir            if <arg>CommandType</arg> specifies an invalid command type.
138*cdf0e10cSrcweir
139*cdf0e10cSrcweir        @see checkNameIsUsed
140*cdf0e10cSrcweir    */
141*cdf0e10cSrcweir    boolean isNameUsed( [in] long CommandType, [in] string Name )
142*cdf0e10cSrcweir        raises ( com::sun::star::lang::IllegalArgumentException );
143*cdf0e10cSrcweir
144*cdf0e10cSrcweir    /** checks whether a given name is valid as table or query name
145*cdf0e10cSrcweir
146*cdf0e10cSrcweir        <p>For tables, the name must consist of characters allowed by the SQL-92 standard,
147*cdf0e10cSrcweir        plus characters allowed by the connection as extra name characters.</p>
148*cdf0e10cSrcweir
149*cdf0e10cSrcweir        <p>For queries, names are nearly arbitrary, except that usual quoting characters
150*cdf0e10cSrcweir        must not be part of the name.</p>
151*cdf0e10cSrcweir
152*cdf0e10cSrcweir        @see com::sun::star::sdbc::XDatabaseMetaData::getExtraNameCharacters
153*cdf0e10cSrcweir    */
154*cdf0e10cSrcweir    boolean isNameValid( [in] long CommandType, [in] string Name )
155*cdf0e10cSrcweir        raises ( com::sun::star::lang::IllegalArgumentException );
156*cdf0e10cSrcweir
157*cdf0e10cSrcweir    /** checks whether a given name is allowed for a to-be-created table or query in the
158*cdf0e10cSrcweir        database.
159*cdf0e10cSrcweir
160*cdf0e10cSrcweir        <p>This method basically does the same checks as <member>isNameUsed</member> and
161*cdf0e10cSrcweir        <member>isNameValid</member>. In case the given name is not allowed, it throws an
162*cdf0e10cSrcweir        exception. This error can be presented to the user, to give it a common experience
163*cdf0e10cSrcweir        in all cases where he's required to enter an object name.</p>
164*cdf0e10cSrcweir
165*cdf0e10cSrcweir        @see isNameUsed
166*cdf0e10cSrcweir        @see isNameValid
167*cdf0e10cSrcweir        @see com::sun::star::sdb::ErrorMessageDialog
168*cdf0e10cSrcweir        @see com::sun::star::sdb::InteractionHandler
169*cdf0e10cSrcweir    */
170*cdf0e10cSrcweir    void    checkNameForCreate( [in] long CommandType, [in] string Name )
171*cdf0e10cSrcweir            raises ( com::sun::star::sdbc::SQLException );
172*cdf0e10cSrcweir};
173*cdf0e10cSrcweir
174*cdf0e10cSrcweir//=============================================================================
175*cdf0e10cSrcweir}; }; }; }; };
176*cdf0e10cSrcweir//=============================================================================
177*cdf0e10cSrcweir
178*cdf0e10cSrcweir#endif
179*cdf0e10cSrcweir
180