KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > modules > database > AutoIncrementModule


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.modules.database;
18
19 import java.sql.Connection JavaDoc;
20 import java.sql.Statement JavaDoc;
21 import java.sql.SQLException JavaDoc;
22 import java.util.Map JavaDoc;
23 import org.apache.avalon.framework.component.Component;
24 import org.apache.avalon.framework.configuration.Configuration;
25 import org.apache.avalon.framework.configuration.ConfigurationException;
26
27 /**
28  * Abstraction layer to encapsulate different DBMS behaviour for key
29  * attribute columns.
30  *
31  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
32  * @version CVS $Id: AutoIncrementModule.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  * */

34 public interface AutoIncrementModule extends Component {
35
36     String JavaDoc ROLE = AutoIncrementModule.class.getName();
37
38
39     /**
40      * Return key attribute value of last inserted row.
41      *
42      * @param tableConf Table's configuration from resource description.
43      * @param columnConf column's configuration from resource description.
44      * @param modeConf this mode's configuration from resource description.
45      * @param conn Connection
46      * @param stmt Statement that was executed to insert the last row.
47      * @param objectModel The objectModel
48      * @return value representing the last key value value.
49      * */

50     Object JavaDoc getPostValue( Configuration tableConf, Configuration columnConf, Configuration modeConf,
51                          Connection JavaDoc conn, Statement JavaDoc stmt, Map JavaDoc objectModel ) throws SQLException JavaDoc, ConfigurationException;
52
53
54     /**
55      * Boolean whether the key attribute column needs to be included
56      * in the insert query.
57      *
58      * @return true if the column is needed, false if the column
59      * should be skipped.
60      * */

61     boolean includeInQuery( );
62
63
64     /**
65      * Boolean whether the key attribute needs to be included in the
66      * insert query as an attribute value (no subquery).
67      *
68      * @return true if a value is needed, false if a subquery
69      * expression is used or the column is skipped altogether.
70      * */

71     boolean includeAsValue( );
72
73
74     /**
75      * Provide the value for the key attribute column.
76      *
77      * If a value for the key value column is needed (i.e. the column
78      * is not skipped), this value is computed here.
79      *
80      * @param tableConf Table's configuration from resource description.
81      * @param columnConf column's configuration from resource description.
82      * @param modeConf this mode's configuration from resource description.
83      * @param conn Connection
84      * @param objectModel The objectModel
85      * @return exact value for key attribute column
86      * */

87     Object JavaDoc getPreValue( Configuration tableConf, Configuration columnConf, Configuration modeConf,
88                         Connection JavaDoc conn, Map JavaDoc objectModel ) throws SQLException JavaDoc, ConfigurationException;
89
90
91     /**
92      * Provide subquery string for the key attribute column.
93      *
94      * If a value for the autoincrement column is needed (i.e. the
95      * column is not skipped), and the value can be determined through
96      * a nested subquery, this function provides the subquery as a
97      * string.
98      *
99      * @return subquery string for autoincrement column.
100      */

101     String JavaDoc getSubquery( Configuration tableConf, Configuration columnConf, Configuration modeConf ) throws ConfigurationException;
102
103 }
104
Popular Tags