001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.resource.adapter.jdbc.remote;
023:
024: import java.sql.ResultSetMetaData;
025: import java.sql.SQLException;
026: import java.io.Serializable;
027:
028: /** A wrapper to marshall ResultSetMetaData remotely.
029: *
030: * @author Scott.Stark@jboss.org
031: * @version $Revision: 57189 $
032: */
033: public class SerializableResultSetMetaData implements
034: ResultSetMetaData, Serializable {
035: /** @since 1.3 */
036: static final long serialVersionUID = -6663485432752348789L;
037:
038: private ColumnData[] columnData;
039:
040: private static class ColumnData implements Serializable {
041: static final long serialVersionUID = 5060626133767712300L;
042: String className;
043: String label;
044: String name;
045: int type;
046: String typeName;
047: }
048:
049: SerializableResultSetMetaData(ResultSetMetaData metaData)
050: throws SQLException {
051: int count = metaData.getColumnCount();
052: columnData = new ColumnData[count + 1];
053: for (int c = 1; c <= count; c++) {
054: ColumnData data = new ColumnData();
055: columnData[c] = data;
056: data.label = metaData.getColumnLabel(c);
057: data.name = metaData.getColumnName(c);
058: data.type = metaData.getColumnType(c);
059:
060: }
061: }
062:
063: public int getColumnCount() throws SQLException {
064: // Adjust the usable count by 1 for the 1 base index
065: return columnData.length - 1;
066: }
067:
068: public boolean isAutoIncrement(int column) throws SQLException {
069: return false;
070: }
071:
072: public boolean isCaseSensitive(int column) throws SQLException {
073: return false;
074: }
075:
076: public boolean isSearchable(int column) throws SQLException {
077: return false;
078: }
079:
080: public boolean isCurrency(int column) throws SQLException {
081: return false;
082: }
083:
084: public int isNullable(int column) throws SQLException {
085: return 0;
086: }
087:
088: public boolean isSigned(int column) throws SQLException {
089: return false;
090: }
091:
092: public int getColumnDisplaySize(int column) throws SQLException {
093: return 0;
094: }
095:
096: public String getColumnLabel(int column) throws SQLException {
097: return columnData[column].label;
098: }
099:
100: public String getColumnName(int column) throws SQLException {
101: return columnData[column].name;
102: }
103:
104: public String getSchemaName(int column) throws SQLException {
105: return null;
106: }
107:
108: public int getPrecision(int column) throws SQLException {
109: return 0;
110: }
111:
112: public int getScale(int column) throws SQLException {
113: return 0;
114: }
115:
116: public String getTableName(int column) throws SQLException {
117: return "";
118: }
119:
120: public String getCatalogName(int column) throws SQLException {
121: return "";
122: }
123:
124: public int getColumnType(int column) throws SQLException {
125: return columnData[column].type;
126: }
127:
128: public String getColumnTypeName(int column) throws SQLException {
129: return columnData[column].typeName;
130: }
131:
132: public boolean isReadOnly(int column) throws SQLException {
133: return false;
134: }
135:
136: public boolean isWritable(int column) throws SQLException {
137: return false;
138: }
139:
140: public boolean isDefinitelyWritable(int column) throws SQLException {
141: return false;
142: }
143:
144: public String getColumnClassName(int column) throws SQLException {
145: return columnData[column].className;
146: }
147: }
|