KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > Table


1 /*
2  * Copyright 2003, 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.ws.jaxme.sqls;
18
19 import java.util.Iterator JavaDoc;
20
21
22 /** <p>Abstract description of a table.</p>
23  *
24  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
25  */

26 public interface Table {
27    public interface Name extends SQLFactory.Ident {
28    }
29
30    /** <p>Returns the table name.</p>
31     */

32    public Name getName();
33
34    /** <p>Returns the table schema.</p>
35     */

36    public Schema getSchema();
37
38    /** <p>Returns the table columns.</p>
39     */

40    public Iterator JavaDoc getColumns();
41
42    /** <p>Creates a new column.</p>
43     */

44    public Column newColumn(Column.Name name, Column.Type pType);
45
46    /** <p>Creates a new column.</p>
47     */

48    public Column newColumn(String JavaDoc name, Column.Type pType);
49
50    /** <p>Returns the column with the given name or null,
51     * if no such column exists.</p>
52     */

53    public Column getColumn(Column.Name name);
54
55    /** <p>Returns the column with the given name or null,
56     * if no such column exists.</p>
57     */

58    public Column getColumn(String JavaDoc name);
59
60    /** <p>Creates a new, unique index on the table.</p>
61     */

62    public Index newKey();
63
64    /** <p>Creates a new, non-unique index on the table.</p>
65     */

66    public Index newIndex();
67
68    /** <p>Creates a new primary key on the table.</p>
69     * @throws IllegalStateException A primary key has already been created.
70     */

71    public Index newPrimaryKey();
72
73    /** <p>Creates a new foreign key referencing the given table.</p>
74     */

75    public ForeignKey newForeignKey(Table pReferencedTable);
76
77   /** <p>Returns an INSERT statement for filling all the values. In
78    * other words: If the table FOO has the columns A, B, and C,
79    * then the statement <code>INSERT INTO FOO (A,B,C) VALUES (?, ?, ?)</code>
80    * will be returned.</p>
81    * @see SQLFactory#newInsertStatement()
82    */

83   public InsertStatement getInsertStatement();
84
85   /** <p>Returns a SELECT statement for selecting all the columns. In
86    * other words: If the table FOO has the columns A, B, and C,
87    * then the statement <code>SELECT A, B, C FROM FOO</code> will
88    * be returned.</p>
89    * @see SQLFactory#newSelectStatement()
90    */

91   public SelectStatement getSelectStatement();
92
93   /** <p>Returns an UPDATE statement for updating a column in the table.
94    * In other words: If the table FOO has the columns A, B, C and D
95    * with the primary key columns A and B, then the statement
96    * <code>UPDATE FOO SET C = ?, D = ? WHERE A = ? AND B = ?</code>
97    * will be returned.</p>
98    * @see SQLFactory#newUpdateStatement()
99    * @throws IllegalStateException The table doesn't have a primary key.
100    */

101   public UpdateStatement getUpdateStatement();
102
103   /** <p>Returns an UPDATE statement for updating a column in the table.
104    * In other words: If the table FOO has the primary key columns A and B,
105    * then the statement <code>DELETE FROM FOO WHERE A = ? AND B = ?</code>
106    * will be returned.</p>
107    * @see SQLFactory#newDeleteStatement()
108    * @throws IllegalStateException The table doesn't have a primary key.
109    */

110   public DeleteStatement getDeleteStatement();
111
112   /** <p>Returns the tables qualified name, which is
113    * <code>getSchema().getName() + "." + getName()</code>. If the
114    * schema is the default schema, returns <code>getName()</code>.</p>
115    */

116   public String JavaDoc getQName();
117
118   /** <p>Returns the tables primary key, if any, or null, if the table
119    * doesn't have a primary key.</p>
120    */

121   public Index getPrimaryKey();
122
123   /** <p>Returns an {@link Iterator} to the indexes defined on the table.
124    * This iterator includes the primary key, if any.</p>
125    */

126   public Iterator JavaDoc getIndexes();
127
128   /** <p>Returns an {@link Iterator} to the foreign keys defined on the
129    * table.</p>
130    */

131   public Iterator JavaDoc getForeignKeys();
132 }
133
Popular Tags