KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > functionTests > tests > lang > WiscMetaData


1 /*
2
3    Derby - Class org.apache.derbyTesting.functionTests.tests.lang.WiscMetaData
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derbyTesting.functionTests.tests.lang;
23
24 import org.apache.derby.vti.VTIMetaDataTemplate;
25
26 import java.sql.Types JavaDoc;
27 import java.sql.SQLException JavaDoc;
28 import java.sql.ResultSetMetaData JavaDoc;
29
30 /**
31  * This class gives the metadata for the VTI for loading the Wisconsin
32  * benchmark schema.
33  */

34 class WiscMetaData extends VTIMetaDataTemplate {
35  
36     public int getColumnCount() {
37         return 16;
38     }
39
40     public int getColumnType(int column) throws SQLException JavaDoc {
41         switch (column) {
42           case 1:
43           case 2:
44           case 3:
45           case 4:
46           case 5:
47           case 6:
48           case 7:
49           case 8:
50           case 9:
51           case 10:
52           case 11:
53           case 12:
54           case 13:
55             return Types.INTEGER;
56
57           case 14:
58           case 15:
59           case 16:
60             return Types.CHAR;
61
62           default:
63             throw new SQLException JavaDoc("Invalid column number " + column);
64         }
65     }
66
67     public int isNullable(int column) throws SQLException JavaDoc {
68         if (column < 1 || column > 16) {
69             throw new SQLException JavaDoc(
70                     "isNullable: column number " + column + " out of range.");
71         }
72
73         return ResultSetMetaData.columnNoNulls;
74     }
75
76     public String JavaDoc getColumnName(int column) throws SQLException JavaDoc {
77         switch (column) {
78           case 1:
79             return "unique1";
80
81           case 2:
82             return "unique2";
83
84           case 3:
85             return "two";
86
87           case 4:
88             return "four";
89
90           case 5:
91             return "ten";
92
93           case 6:
94             return "twenty";
95
96           case 7:
97             return "onePercent";
98
99           case 8:
100             return "tenPercent";
101
102           case 9:
103             return "twentyPercent";
104
105           case 10:
106             return "fiftyPercent";
107
108           case 11:
109             return "unique3";
110
111           case 12:
112             return "evenOnePercent";
113
114           case 13:
115             return "oddOnePercent";
116
117           case 14:
118             return "stringu1";
119
120           case 15:
121             return "stringu2";
122
123           case 16:
124             return "string4";
125         }
126
127         throw new SQLException JavaDoc(
128                 "getColumnName: column number " + column + " out of range.");
129     }
130
131     public int getColumnDisplaySize(int column) throws SQLException JavaDoc {
132         if (column < 1 || column > 16) {
133             throw new SQLException JavaDoc(
134                     "getColumnDisplaySize: column number " + column + " out of range.");
135         }
136
137         /* All columns up to 14 are ints, all columns after 14 are char(52) */
138         if (column < 14)
139             return 10;
140         else
141             return 52;
142     }
143 }
144
Popular Tags