001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029: package com.caucho.db.jdbc;
030:
031: import com.caucho.db.sql.Expr;
032: import com.caucho.db.sql.SelectResult;
033:
034: import java.sql.ResultSetMetaData;
035: import java.sql.SQLException;
036:
037: /**
038: * Metadata for the result
039: */
040: public class ResultSetMetaDataImpl implements ResultSetMetaData {
041: private final SelectResult _rs;
042:
043: ResultSetMetaDataImpl(SelectResult rs) {
044: _rs = rs;
045: }
046:
047: /**
048: * Returns the number of columns.
049: */
050: public int getColumnCount() {
051: return _rs.getExprs().length;
052: }
053:
054: /**
055: * Returns true if the column is auto-numbered.
056: */
057: public boolean isAutoIncrement(int column) {
058: return false;
059: }
060:
061: /**
062: * Returns true if the column is case sensitive
063: */
064: public boolean isCaseSensitive(int column) {
065: return true;
066: }
067:
068: /**
069: * Returns true if the column can be in a where clause
070: */
071: public boolean isSearchable(int column) {
072: return false;
073: }
074:
075: /**
076: * Returns true if the column is a currency;
077: */
078: public boolean isCurrency(int column) {
079: return false;
080: }
081:
082: /**
083: * Returns true if the column is nullable
084: */
085: public int isNullable(int column) {
086: throw new UnsupportedOperationException();
087: }
088:
089: /**
090: * Returns the normal width
091: */
092: public int getColumnDisplaySize(int column) {
093: return 16;
094: }
095:
096: /**
097: * Returns the column label
098: */
099: public String getColumnLabel(int column) {
100: return getColumnName(column);
101: }
102:
103: /**
104: * Returns the column name
105: */
106: public String getColumnName(int column) {
107: return getColumn(column).getName();
108: }
109:
110: /**
111: * Returns the column schema
112: */
113: public String getColumnSchema(int column) {
114: throw new UnsupportedOperationException();
115: }
116:
117: /**
118: * Returns true for signed results.
119: */
120: public boolean isSigned(int column) {
121: return true;
122: }
123:
124: /**
125: * Returns the column precision
126: */
127: public int getPrecision(int column) {
128: return 0;
129: }
130:
131: /**
132: * Returns the column scale
133: */
134: public int getScale(int column) {
135: return 0;
136: }
137:
138: /**
139: * Returns the column table name
140: */
141: public String getSchemaName(int column) {
142: return getTableName(column);
143: }
144:
145: /**
146: * Returns the column table name
147: */
148: public String getTableName(int column) {
149: return getColumn(column).getTable().getName();
150: }
151:
152: /**
153: * Returns the column catalog name
154: */
155: public String getCatalogName(int column) {
156: return null;
157: }
158:
159: /**
160: * Returns the column type
161: */
162: public int getColumnType(int column) {
163: return getColumn(column).getSQLType();
164: }
165:
166: /**
167: * Returns the column type name
168: */
169: public String getColumnTypeName(int column) {
170: throw new UnsupportedOperationException();
171: }
172:
173: /**
174: * Returns the column writability
175: */
176: public boolean isReadOnly(int column) {
177: throw new UnsupportedOperationException();
178: }
179:
180: /**
181: * Returns the column writability
182: */
183: public boolean isWritable(int column) {
184: throw new UnsupportedOperationException();
185: }
186:
187: /**
188: * Returns the column writability
189: */
190: public boolean isDefinitelyWritable(int column) {
191: throw new UnsupportedOperationException();
192: }
193:
194: /**
195: * Returns the column class namewritability
196: */
197: public String getColumnClassName(int column) {
198: throw new UnsupportedOperationException();
199: }
200:
201: /**
202: * Returns the column.
203: */
204: public Expr getColumn(int column) {
205: return _rs.getExprs()[column - 1];
206: }
207:
208: public <T> T unwrap(Class<T> iface) throws SQLException {
209: throw new UnsupportedOperationException("Not supported yet.");
210: }
211:
212: public boolean isWrapperFor(Class<?> iface) throws SQLException {
213: throw new UnsupportedOperationException("Not supported yet.");
214: }
215: }
|