KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > adapter > jdbc > remote > SerializableResultSetMetaData


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.resource.adapter.jdbc.remote;
23
24 import java.sql.ResultSetMetaData JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 /** A wrapper to marshall ResultSetMetaData remotely.
29  *
30  * @author Scott.Stark@jboss.org
31  * @version $Revision: 37459 $
32  */

33 public class SerializableResultSetMetaData
34    implements ResultSetMetaData JavaDoc, Serializable JavaDoc
35 {
36    /** @since 1.3 */
37    static final long serialVersionUID = -6663485432752348789L;
38
39    private ColumnData[] columnData;
40
41    private static class ColumnData implements Serializable JavaDoc
42    {
43       static final long serialVersionUID = 5060626133767712300L;
44       String JavaDoc className;
45       String JavaDoc label;
46       String JavaDoc name;
47       int type;
48       String JavaDoc typeName;
49    }
50
51    SerializableResultSetMetaData(ResultSetMetaData JavaDoc metaData) throws SQLException JavaDoc
52    {
53       int count = metaData.getColumnCount();
54       columnData = new ColumnData[count+1];
55       for(int c = 1; c <= count; c ++)
56       {
57          ColumnData data = new ColumnData();
58          columnData[c] = data;
59          data.label = metaData.getColumnLabel(c);
60          data.name = metaData.getColumnName(c);
61          data.type = metaData.getColumnType(c);
62
63       }
64    }
65
66    public int getColumnCount() throws SQLException JavaDoc
67    {
68       // Adjust the usable count by 1 for the 1 base index
69
return columnData.length - 1;
70    }
71
72    public boolean isAutoIncrement(int column) throws SQLException JavaDoc
73    {
74       return false;
75    }
76
77    public boolean isCaseSensitive(int column) throws SQLException JavaDoc
78    {
79       return false;
80    }
81
82    public boolean isSearchable(int column) throws SQLException JavaDoc
83    {
84       return false;
85    }
86
87    public boolean isCurrency(int column) throws SQLException JavaDoc
88    {
89       return false;
90    }
91
92    public int isNullable(int column) throws SQLException JavaDoc
93    {
94       return 0;
95    }
96
97    public boolean isSigned(int column) throws SQLException JavaDoc
98    {
99       return false;
100    }
101
102    public int getColumnDisplaySize(int column) throws SQLException JavaDoc
103    {
104       return 0;
105    }
106
107    public String JavaDoc getColumnLabel(int column) throws SQLException JavaDoc
108    {
109       return columnData[column].label;
110    }
111
112    public String JavaDoc getColumnName(int column) throws SQLException JavaDoc
113    {
114       return columnData[column].name;
115    }
116
117    public String JavaDoc getSchemaName(int column) throws SQLException JavaDoc
118    {
119       return null;
120    }
121
122    public int getPrecision(int column) throws SQLException JavaDoc
123    {
124       return 0;
125    }
126
127    public int getScale(int column) throws SQLException JavaDoc
128    {
129       return 0;
130    }
131
132    public String JavaDoc getTableName(int column) throws SQLException JavaDoc
133    {
134       return "";
135    }
136
137    public String JavaDoc getCatalogName(int column) throws SQLException JavaDoc
138    {
139       return "";
140    }
141
142    public int getColumnType(int column) throws SQLException JavaDoc
143    {
144       return columnData[column].type;
145    }
146
147    public String JavaDoc getColumnTypeName(int column) throws SQLException JavaDoc
148    {
149       return columnData[column].typeName;
150    }
151
152    public boolean isReadOnly(int column) throws SQLException JavaDoc
153    {
154       return false;
155    }
156
157    public boolean isWritable(int column) throws SQLException JavaDoc
158    {
159       return false;
160    }
161
162    public boolean isDefinitelyWritable(int column) throws SQLException JavaDoc
163    {
164       return false;
165    }
166
167    public String JavaDoc getColumnClassName(int column) throws SQLException JavaDoc
168    {
169       return columnData[column].className;
170    }
171 }
172
Popular Tags