KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > mapping > TableMapping


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mapper.mapping;
24
25 import java.util.List JavaDoc;
26 ;
27
28 /**
29  * Interface giving access to information for mapping XML elements
30  * on rdbms tables.
31  *
32  */

33 public interface TableMapping extends Mapping, MappingInfo
34 {
35
36
37
38     /**
39      * Setter for the table mapping index (unique ID).
40      * @param index a positive integer.
41      */

42     public void setIndex(int index);
43
44     /**
45      * Accessor to user table relational metadata.
46      * @return a TableMetaData object.
47      */

48     public TableMetaData getMetaData();
49
50     /**
51      * Accessor to column mapping information for all the columns of the user
52      * table.
53      * @return an iterator on ColumnMapping objects.
54      */

55 // public Iterator getColumnMappingIterator();
56

57     /**
58      * Accessor to column mapping in a dense array where index does not match
59      * the column index. Unmapped columns are discarded. Implemented because
60      * query module uses arrays instead of iterators
61      * @return a ColumnMapping array.
62      */

63     public ColumnMapping[] getColumnMappings();
64
65     /**
66      * Accessor to column mapping information by name.
67      * @param name the name of the user table column.
68      * @return a ColumnMapping object.
69      */

70     public ColumnMapping getColumnMapping(String JavaDoc name);
71
72     /**
73      * Accessor to column mapping information by index.
74      * @param index the index of the user table column. This index depends on
75      * the order of the column in the user table.
76      * @return a ColumnMapping object or null if the user column has no mapping.
77      */

78     public ColumnMapping getColumnMapping(int index);
79
80     /**
81      * Returns the number of columns in the user table.
82      */

83     public int getColumnCount();
84
85     /**
86      * Returns the number of column mappings in the table mapping. It may be
87      * inferior to the actual number of columns in the table.
88      * @return the number of column mappings.
89      */

90     public int getColumnMappingCount();
91
92     /**
93      * Returns the column mappings of the relational user table PK or if no PK
94      * exists, the columns mapping which flag "inKey" is true.
95      * @return a ColumnMapping array.
96      */

97     public ColumnMapping[] getPrimaryKey();
98
99     /**
100     * Returns the number of column mappings involved in the user table PK or
101     * if no PK exists, the columns mapping which flag "inKey" is true.
102     * @return a positive integer.
103     */

104     public int getKeyColumnCount();
105
106     /**
107      * Returns the number of columns of the OID table (external XQuark index
108      * table), including XQuark index columns. <b>Different from
109      * {@link #getJoinColumns()}.length</b>.
110      * @return a positive integer.
111      */

112     public int getOIDTableColumnCount(); // includes docOID & OID (OID table)
113

114     /**
115      * Returns the column mappings involved in natural join between XQuark index
116      * and user tables. That is not necessarily the relational user table PK.
117      * <b>XQuark index columns are not included</b>.
118      * @return a ColumnMapping array.
119      */

120     public ColumnMapping[] getJoinColumns();
121
122     /**
123      * Returns the columns of the relational user table that will be updated
124      * if the insert mode (action) is "update".
125      * @return a ColumnMapping array. May be null if action is not "update".
126      * @see #getAction()
127      */

128     public ColumnMapping[] getUpdateColumns();
129
130     /**
131      * Returns the number of columns of the relational user table that will be
132      * updated if the insert mode (action) is "update".
133      * @return a positive integer.
134      */

135     public int getUpdateColumnCount();
136
137     /**
138      * Returns the columns of the relational user table that will be used for
139      * retrieving the tuple to be selected or updated if the insert mode
140      * (action) is different from "insert".
141      * @return a ColumnMapping array. May be null if action is "insert".
142      * @see #getAction()
143      */

144     public ColumnMapping[] getSelectColumns();
145
146     /**
147      * Returns the number of columns of the relational user table that will be
148      * used for retrieving the tuple to be selected or updated if the insert
149      * mode (action) is different from "insert".
150      * @return a positive integer.
151      */

152     public int getSelectColumnCount();
153
154     /**
155      * Returns the columns of the relational user table that will be
156      * retrieved from the tuple to be selected or updated if the insert mode
157      * (action) is different from "insert".
158      * @return a ColumnMapping array. May be null if action is "insert".
159      * @see #getAction()
160      */

161     public ColumnMapping[] getFetchColumns();
162
163     /**
164      * Returns the number of columns of the relational user table that will be
165      * retrieved from the tuple to be selected or updated if the insert mode
166      * (action) is different from "insert".
167      * @return a positive integer.
168      */

169     public int getFetchColumnCount();
170
171     /**
172      * Returns column mapping corresponding to generators or to optional or
173      * nillable elements which column are nullable or have default value. For
174      * these columns, a default value is generated at the beginning of the
175      * element of the table mapping so that it may be overwritten if the
176      * element eventually exists.
177      * @return a list containing ColumnMapping objects.
178      */

179     public List JavaDoc initParameters();
180
181     /**
182      * Returns column mapping that are ready (and must be added to tuple)
183      * when the table mapping is complete. Mainly used to store an element
184      * value when a table mapping has been defined on it for instance to store
185      * attributes.
186      * @return a list containing ColumnMapping objects.
187      */

188     public List JavaDoc finalParameters();
189
190     /**
191      * Returns the insertion mode of the table mapping.
192      * @return an integer within the values INSERT, CHECK, UPDATE & SELECT
193      * defined in {@link MappingConstants}.
194      */

195     public int getAction();
196
197     /**
198      * Returns the batch size used for storage in the mapping's table. May be
199      * the default one, the user set one (in the configuration or mapping file)
200      * or a value imposed by the data types (for instance LOBs enforce batch
201      * size to 1.
202      * @return a positive non-null integer.
203      */

204     public int getBatchSize();
205
206     /**
207      * Returns the cluster mode of the table mapping. "Clustered" means XQuark
208      * index columns are incorporated in user tables in the form of generators.
209      * This is only possible if the insertion mode is "INSERT".
210      * @return true if the OID table is clustered
211      */

212     public boolean isClustered();
213
214     /**
215      * Returns the XQuark index path OID column index either in the user table,
216      * if clustered, either in the OID table if not.
217      * @return an integer index beginning with 0.
218      */

219     public int getPathIDIndex();
220
221     /**
222      * Returns the name of the column containing the path OID (both in
223      * clustered and not clustered case).
224      * @return the path OID column name.
225      */

226     public String JavaDoc getPathIDColumnName();
227
228     /**
229      * Returns the XQuark index node UOID column index either in the user table,
230      * if clustered, either in the OID table if not.
231      * @return an integer index beginning with 0.
232      */

233     public int getUOIDIndex();
234
235     /**
236      * Returns the name of the column containing the node UOID (both in
237      * clustered and not clustered case).
238      * @return the node UOID column name.
239      */

240     public String JavaDoc getUOIDColumnName();
241
242     /**
243      * Returns the SQL statement fragment corresponding to the columns of the
244      * user table to put in a SELECT clause.
245      * @return a comma-separated list of column names.
246      */

247     public String JavaDoc getColumnList();
248     
249     /**
250      * Returns the SQL statement fragment corresponding to the columns of the
251      * user table to put in a SELECT clause.
252      * @return a comma-separated list of column names using table aliases.
253      */

254     public String JavaDoc getNamedColumnList();
255     
256     /**
257      * Returns the SQL statement fragment corresponding to the columns of the
258      * user table to put in a SELECT clause of a prepared statement.
259      * @return a comma-separated list of question marks.
260      */

261     public String JavaDoc getWildcards();
262     
263     /**
264      * Returns the SQL statement fragment corresponding to the columns of the
265      * user table that participate in the join with the OID table.
266      * @return a comma-separated list of column names.
267      */

268     public String JavaDoc getJoinColumnList();
269
270     /**
271      * Returns the SQL statement fragment corresponding to the columns of the
272      * user table that participate in the join with the OID table of a prepared
273      * statement.
274      * @return a comma-separated list of question marks.
275      */

276     public String JavaDoc getJoinWildcards();
277     
278     /**
279      * Returns the DDL statement fragment corresponding to the columns of the
280      * user table that participate in the join with the OID table of a prepared
281      * statement. Used for OID table creation.
282      * @return a comma-separated list DDL column specifications.
283      */

284     public String JavaDoc getJoinColumnTypes();
285
286     /**
287      * Returns the SQL statement fragment to put in a WHERE clause to perform
288      * natural join between the OID table and the user table.
289      * @return null if clustered.
290      */

291     public String JavaDoc getJoinCondition();
292     
293     /**
294      * Says if all statements can be shared among the table mappings defined on
295      * the same user table.
296      * @return boolean
297      */

298     public boolean isShareable();
299
300     /**
301      * Says if this mapping is shared by multiple paths. This is the case for
302      * default mapping an most of the time type mappings.
303      * @return boolean
304      */

305     public boolean isShared();
306
307     /**
308      * True if this table mapping shares its user table with other table
309      * mappings or if this mapping is shared itself, i.e., multiple path are
310      * mapped on the same user table.
311      * @return boolean
312      */

313     public boolean isTableShared();
314 }
315
Popular Tags