KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > db > jdbc > ResultSetMetaDataImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29 package com.caucho.db.jdbc;
30
31 import com.caucho.db.sql.Expr;
32 import com.caucho.db.sql.SelectResult;
33
34 import java.sql.ResultSetMetaData JavaDoc;
35
36 /**
37  * Metadata for the result
38  */

39 public class ResultSetMetaDataImpl implements ResultSetMetaData JavaDoc {
40   private final SelectResult _rs;
41   
42   ResultSetMetaDataImpl(SelectResult rs)
43   {
44     _rs = rs;
45   }
46
47   /**
48    * Returns the number of columns.
49    */

50   public int getColumnCount()
51   {
52     return _rs.getExprs().length;
53   }
54
55   /**
56    * Returns true if the column is auto-numbered.
57    */

58   public boolean isAutoIncrement(int column)
59   {
60     return false;
61   }
62
63   /**
64    * Returns true if the column is case sensitive
65    */

66   public boolean isCaseSensitive(int column)
67   {
68     return true;
69   }
70
71   /**
72    * Returns true if the column can be in a where clause
73    */

74   public boolean isSearchable(int column)
75   {
76     return false;
77   }
78
79   /**
80    * Returns true if the column is a currency;
81    */

82   public boolean isCurrency(int column)
83   {
84     return false;
85   }
86
87   /**
88    * Returns true if the column is nullable
89    */

90   public int isNullable(int column)
91   {
92     throw new UnsupportedOperationException JavaDoc();
93   }
94
95   /**
96    * Returns the normal width
97    */

98   public int getColumnDisplaySize(int column)
99   {
100     return 16;
101   }
102
103   /**
104    * Returns the column label
105    */

106   public String JavaDoc getColumnLabel(int column)
107   {
108     return getColumnName(column);
109   }
110
111   /**
112    * Returns the column name
113    */

114   public String JavaDoc getColumnName(int column)
115   {
116     return getColumn(column).getName();
117   }
118
119   /**
120    * Returns the column schema
121    */

122   public String JavaDoc getColumnSchema(int column)
123   {
124     throw new UnsupportedOperationException JavaDoc();
125   }
126
127   /**
128    * Returns true for signed results.
129    */

130   public boolean isSigned(int column)
131   {
132     return true;
133   }
134
135   /**
136    * Returns the column precision
137    */

138   public int getPrecision(int column)
139   {
140     return 0;
141   }
142
143   /**
144    * Returns the column scale
145    */

146   public int getScale(int column)
147   {
148     return 0;
149   }
150
151   /**
152    * Returns the column table name
153    */

154   public String JavaDoc getSchemaName(int column)
155   {
156     return getTableName(column);
157   }
158
159   /**
160    * Returns the column table name
161    */

162   public String JavaDoc getTableName(int column)
163   {
164     return getColumn(column).getTable().getName();
165   }
166
167   /**
168    * Returns the column catalog name
169    */

170   public String JavaDoc getCatalogName(int column)
171   {
172     return null;
173   }
174
175   /**
176    * Returns the column type
177    */

178   public int getColumnType(int column)
179   {
180     return getColumn(column).getSQLType();
181   }
182
183   /**
184    * Returns the column type name
185    */

186   public String JavaDoc getColumnTypeName(int column)
187   {
188     throw new UnsupportedOperationException JavaDoc();
189   }
190
191   /**
192    * Returns the column writability
193    */

194   public boolean isReadOnly(int column)
195   {
196     throw new UnsupportedOperationException JavaDoc();
197   }
198
199   /**
200    * Returns the column writability
201    */

202   public boolean isWritable(int column)
203   {
204     throw new UnsupportedOperationException JavaDoc();
205   }
206
207   /**
208    * Returns the column writability
209    */

210   public boolean isDefinitelyWritable(int column)
211   {
212     throw new UnsupportedOperationException JavaDoc();
213   }
214
215   /**
216    * Returns the column class namewritability
217    */

218   public String JavaDoc getColumnClassName(int column)
219   {
220     throw new UnsupportedOperationException JavaDoc();
221   }
222
223   /**
224    * Returns the column.
225    */

226   public Expr getColumn(int column)
227   {
228     return _rs.getExprs()[column - 1];
229   }
230 }
231
Popular Tags