KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > jdbc > typing > ColumnMetaData


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

23
24 package org.xquark.jdbc.typing;
25
26 /**
27  * This interface gives acess to meta information about a column in a relational
28  * table. This information is useful to verify the integrity constraints
29  * in the the relational tables.
30  */

31 public interface ColumnMetaData
32 {
33     /**
34      * Accessor to the column name.
35      * @return the name of the column.
36      */

37     public String JavaDoc getColumnName();
38
39     /**
40      * Accessor to the column's table name.
41      * @return the name of the column's table.
42      */

43     public String JavaDoc getTableName();
44     
45     /**
46      * Whether this column can be null.
47      * @return true if the column is nullable in the RDBMS.
48      */

49     public boolean isNullable();
50     
51     /**
52      * Whether filling this column is optional.
53      * @return true if column is nullable or has a default value.
54      */

55     public boolean isOptional();
56     
57     /**
58      * Returns the base SQL type corresponding to the column. The base SQL
59      * types is a subset of SQL data types defined in {@link java.sql.Types}
60      * which represent a family of types, aka VARCHAR, VARBINARY, DECIMAL,
61      * REAL, DOUBLE, TIMESTAMP. Whithin a family mainly size limits differ.
62      * @return a constant defined in {@link java.sql.Types}.
63      */

64     public short getDataType();
65     
66     /**
67      * Returns information on the native SQL type.
68      * @return an object containing many information on the RDBMS specific type.
69      */

70     public TypeMap.SQLType getSqlType();
71     
72     /**
73      * Accessor to the native type name.
74      * @return a native DDL data type.
75      */

76     public String JavaDoc getTypeName();
77     
78     /**
79      * Gets column size or precision. Given in bytes, bits, characters
80      * or digits depending on the base type.
81      * @return -1 if not significant.
82      */

83     public long getColumnSize();
84     
85     /**
86      * Gets scale for the DECIMAL family types.
87      * @return -1 if not significant.
88      */

89     public int getDecimalDigits();
90     
91     /**
92      * Returns the default value defined in the RDBMS for this column.
93      * @return the default value as a String
94      */

95     public String JavaDoc getDefaultValue();
96     
97     /**
98      * Gets the RDBMS position of the column within the table. May be used for
99      * "SELECT *" statements.
100      * @return a positive non-nul integer.
101      */

102     public int getOrdinalPosition();
103     
104     /**
105      * Whether the column belongs to the RDBMS Primary Key of the table.
106      * @return true if column is part of the PK.
107      */

108     public boolean isPrimaryKey();
109     
110     /**
111      * Whether the column type belongs to the SQL types BLOB, CLOB, LONG,
112      * TEXT or more generally types allowing large amount of data to be stored
113      * and that are not indexed in the standard way in RDBMS. With most JDBC
114      * implementations these type must be accessed through streams.
115      * @return true if column has the corresponding type.
116      */

117     public boolean isLongType();
118     
119     /**
120      * Whether the column type belongs to the SQL types BLOB, CLOB.
121      * @return true if column has the corresponding type.
122      */

123     public boolean isLOB();
124
125     /**
126      * Gives the position in the table Primary Key.
127      * @return -1 if does not belong to PK.
128      */

129     public short getPrimaryKeySeq();
130     
131     /**
132      * Returned the reference table if the column belongs to a Foreign Key.
133      * @return the reference table name or null if not relevant.
134      */

135     public String JavaDoc getRefTable();
136     
137     /**
138      * Returned the reference column if the column belongs to a Foreign Key.
139      * @return the reference column name or null if not relevant.
140      */

141     public String JavaDoc getRefColumn();
142
143     /**
144      * Returns the DDL statement fragment corresponding to the creation of
145      * a column with the same specifications (default value is ignored).
146      * @return a native DDL fragment.
147      */

148     public String JavaDoc getTypeCreationString();
149     
150     public DbType getType();
151 }
152
Popular Tags