KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hsqldb > jdbc > jdbcColumnMetaData


1 /* Copyright (c) 2001-2005, The HSQL Development Group
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * Neither the name of the HSQL Development Group nor the names of its
15  * contributors may be used to endorse or promote products derived from this
16  * software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31
32 package org.hsqldb.jdbc;
33
34 import java.lang.reflect.Field JavaDoc;
35
36 /**
37  * Provides a site for holding the ResultSetMetaData for individual ResultSet
38  * columns. <p>
39  *
40  * @author boucherb@users
41  * @version 1.7.2
42  * @since HSQLDB 1.7.2
43  */

44 public final class jdbcColumnMetaData {
45
46     /** The column's table's catalog name. */
47     public String JavaDoc catalogName;
48
49     /**
50      * The fully-qualified name of the Java class whose instances are
51      * manufactured if the method ResultSet.getObject is called to retrieve
52      * a value from the column.
53      */

54     public String JavaDoc columnClassName;
55
56     /** The column's normal max width in chars. */
57     public int columnDisplaySize;
58
59     /** The suggested column title for use in printouts and displays. */
60     public String JavaDoc columnLabel;
61
62     /** The column's name. */
63     public String JavaDoc columnName;
64
65     /** The column's SQL type. */
66     public int columnType;
67
68     /** The column's database-specific type name. */
69     public String JavaDoc columnTypeName;
70
71     /** The column's value's number of decimal digits. */
72     public int precision;
73
74     /** The column's value's number of digits to right of the decimal point. */
75     public int scale;
76
77     /** The column's table's schema. */
78     public String JavaDoc schemaName;
79
80     /** The column's table's name. */
81     public String JavaDoc tableName;
82
83     /** Whether the value of the column are automatically numbered. */
84     public boolean isAutoIncrement;
85
86     /** Whether the column's value's case matters. */
87     public boolean isCaseSensitive;
88
89     /** Whether the values in the column are cash values. */
90     public boolean isCurrency;
91
92     /** Whether a write on the column will definitely succeed. */
93     public boolean isDefinitelyWritable;
94
95     /** The nullability of values in the column. */
96     public int isNullable;
97
98     /** Whether the column's values are definitely not writable. */
99     public boolean isReadOnly;
100
101     /** Whether the column's values can be used in a where clause. */
102     public boolean isSearchable;
103
104     /** Whether values in the column are signed numbers. */
105     public boolean isSigned;
106
107     /** Whether it is possible for a write on the column to succeed. */
108     public boolean isWritable;
109
110     /**
111      * Retrieves a String representation of this object.
112      *
113      * @return a Sring representation of this object
114      */

115     public String JavaDoc toString() {
116
117         try {
118             return toStringImpl();
119         } catch (Exception JavaDoc e) {
120             return super.toString() + "[" + e + "]";
121         }
122     }
123
124     /**
125      * Provides the implementation of the toString() method.
126      *
127      * @return a Sring representation of this object
128      */

129     private String JavaDoc toStringImpl() throws Exception JavaDoc {
130
131         StringBuffer JavaDoc sb;
132         Field JavaDoc[] fields;
133         Field JavaDoc field;
134
135         sb = new StringBuffer JavaDoc();
136
137         sb.append('[');
138
139         fields = getClass().getFields();
140
141         int len = fields.length;
142
143         for (int i = 0; i < len; i++) {
144             field = fields[i];
145
146             sb.append(field.getName());
147             sb.append('=');
148             sb.append(field.get(this));
149
150             if (i + 1 < len) {
151                 sb.append(',');
152                 sb.append(' ');
153             }
154         }
155
156         sb.append(']');
157
158         return sb.toString();
159     }
160 }
161
Popular Tags