56380
|
1 |
/*
|
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package jdk.incubator.sql2;
|
|
27 |
|
56797
|
28 |
import java.math.BigDecimal;
|
|
29 |
import java.time.LocalDate;
|
|
30 |
import java.time.LocalDateTime;
|
|
31 |
import java.time.LocalTime;
|
|
32 |
import java.time.OffsetDateTime;
|
|
33 |
import java.time.OffsetTime;
|
|
34 |
|
56380
|
35 |
/**
|
56397
|
36 |
* <P>Defines the constants that are used to identify generic
|
|
37 |
* SQL types, called JDBC types.
|
|
38 |
*
|
|
39 |
* @see SqlType
|
|
40 |
* @since 1.8
|
56380
|
41 |
*/
|
|
42 |
public enum AdbaType implements SqlType {
|
56397
|
43 |
|
|
44 |
/**
|
|
45 |
* Identifies the generic SQL type {@code BIT}.
|
|
46 |
*/
|
56797
|
47 |
BIT(Boolean.class),
|
56397
|
48 |
/**
|
|
49 |
* Identifies the generic SQL type {@code TINYINT}.
|
|
50 |
*/
|
56797
|
51 |
TINYINT(Byte.class),
|
56397
|
52 |
/**
|
|
53 |
* Identifies the generic SQL type {@code SMALLINT}.
|
|
54 |
*/
|
56797
|
55 |
SMALLINT(Short.class),
|
56397
|
56 |
/**
|
|
57 |
* Identifies the generic SQL type {@code INTEGER}.
|
|
58 |
*/
|
56797
|
59 |
INTEGER(Integer.class),
|
56397
|
60 |
/**
|
|
61 |
* Identifies the generic SQL type {@code BIGINT}.
|
|
62 |
*/
|
56797
|
63 |
BIGINT(Long.class),
|
56397
|
64 |
/**
|
|
65 |
* Identifies the generic SQL type {@code FLOAT}.
|
|
66 |
*/
|
56797
|
67 |
FLOAT(Double.class),
|
56397
|
68 |
/**
|
|
69 |
* Identifies the generic SQL type {@code REAL}.
|
|
70 |
*/
|
56797
|
71 |
REAL(Float.class),
|
56397
|
72 |
/**
|
|
73 |
* Identifies the generic SQL type {@code DOUBLE}.
|
|
74 |
*/
|
56797
|
75 |
DOUBLE(Double.class),
|
56397
|
76 |
/**
|
|
77 |
* Identifies the generic SQL type {@code NUMERIC}.
|
|
78 |
*/
|
56797
|
79 |
NUMERIC(BigDecimal.class),
|
56397
|
80 |
/**
|
|
81 |
* Identifies the generic SQL type {@code DECIMAL}.
|
|
82 |
*/
|
56797
|
83 |
DECIMAL(BigDecimal.class),
|
56397
|
84 |
/**
|
|
85 |
* Identifies the generic SQL type {@code CHAR}.
|
|
86 |
*/
|
56797
|
87 |
CHAR(String.class),
|
56397
|
88 |
/**
|
|
89 |
* Identifies the generic SQL type {@code VARCHAR}.
|
|
90 |
*/
|
56797
|
91 |
VARCHAR(String.class),
|
56397
|
92 |
/**
|
56475
|
93 |
* Identifies the generic SQL type {@code LONG VARCHAR}.
|
56397
|
94 |
*/
|
56797
|
95 |
LONG_VARCHAR(String.class),
|
56397
|
96 |
/**
|
|
97 |
* Identifies the generic SQL type {@code DATE}.
|
|
98 |
*/
|
56797
|
99 |
DATE(LocalDate.class),
|
56397
|
100 |
/**
|
|
101 |
* Identifies the generic SQL type {@code TIME}.
|
|
102 |
*/
|
56797
|
103 |
TIME(LocalTime.class),
|
56397
|
104 |
/**
|
|
105 |
* Identifies the generic SQL type {@code TIMESTAMP}.
|
|
106 |
*/
|
56797
|
107 |
TIMESTAMP(LocalDateTime.class),
|
56397
|
108 |
/**
|
|
109 |
* Identifies the generic SQL type {@code BINARY}.
|
|
110 |
*/
|
56797
|
111 |
BINARY(byte[].class),
|
56397
|
112 |
/**
|
|
113 |
* Identifies the generic SQL type {@code VARBINARY}.
|
|
114 |
*/
|
56797
|
115 |
VARBINARY(byte[].class),
|
56397
|
116 |
/**
|
56475
|
117 |
* Identifies the generic SQL type {@code LONG VARBINARY}.
|
56397
|
118 |
*/
|
56797
|
119 |
LONG_VARBINARY(byte[].class),
|
56397
|
120 |
/**
|
|
121 |
* Identifies the generic SQL value {@code NULL}.
|
|
122 |
*/
|
56797
|
123 |
NULL(Void.class),
|
56397
|
124 |
/**
|
|
125 |
* Indicates that the SQL type
|
|
126 |
* is database-specific and gets mapped to a Java object that can be
|
|
127 |
* accessed via the methods getObject and setObject.
|
|
128 |
*/
|
56797
|
129 |
OTHER(Object.class),
|
56397
|
130 |
/**
|
|
131 |
* Indicates that the SQL type
|
|
132 |
* is database-specific and gets mapped to a Java object that can be
|
|
133 |
* accessed via the methods getObject and setObject.
|
|
134 |
*/
|
56797
|
135 |
JAVA_OBJECT(Object.class),
|
56397
|
136 |
/**
|
|
137 |
* Identifies the generic SQL type {@code DISTINCT}.
|
|
138 |
*/
|
56797
|
139 |
DISTINCT(Object.class),
|
56397
|
140 |
/**
|
|
141 |
* Identifies the generic SQL type {@code STRUCT}.
|
|
142 |
*/
|
56797
|
143 |
STRUCT(SqlStruct.class),
|
56397
|
144 |
/**
|
|
145 |
* Identifies the generic SQL type {@code ARRAY}.
|
|
146 |
*/
|
56797
|
147 |
ARRAY(Object[].class), //TODO questionable. really want <?>[]
|
56397
|
148 |
/**
|
|
149 |
* Identifies the generic SQL type {@code BLOB}.
|
|
150 |
*/
|
56797
|
151 |
BLOB(SqlBlob.class),
|
56397
|
152 |
/**
|
|
153 |
* Identifies the generic SQL type {@code CLOB}.
|
|
154 |
*/
|
56797
|
155 |
CLOB(SqlClob.class),
|
56397
|
156 |
/**
|
|
157 |
* Identifies the generic SQL type {@code REF}.
|
|
158 |
*/
|
56797
|
159 |
REF(SqlRef.class),
|
56397
|
160 |
/**
|
|
161 |
* Identifies the generic SQL type {@code DATALINK}.
|
|
162 |
*/
|
56797
|
163 |
DATALINK(Void.class), //TODO
|
56397
|
164 |
/**
|
|
165 |
* Identifies the generic SQL type {@code BOOLEAN}.
|
|
166 |
*/
|
56797
|
167 |
BOOLEAN(Boolean.class),
|
56397
|
168 |
/**
|
|
169 |
* Identifies the SQL type {@code ROWID}.
|
|
170 |
*/
|
56797
|
171 |
ROWID(Void.class), //TODO
|
56397
|
172 |
/**
|
|
173 |
* Identifies the generic SQL type {@code NCHAR}.
|
|
174 |
*/
|
56797
|
175 |
NCHAR(String.class),
|
56397
|
176 |
/**
|
|
177 |
* Identifies the generic SQL type {@code NVARCHAR}.
|
|
178 |
*/
|
56797
|
179 |
NVARCHAR(String.class),
|
56397
|
180 |
/**
|
56475
|
181 |
* Identifies the generic SQL type {@code LONG NVARCHAR}.
|
56397
|
182 |
*/
|
56797
|
183 |
LONG_NVARCHAR(String.class),
|
56397
|
184 |
/**
|
|
185 |
* Identifies the generic SQL type {@code NCLOB}.
|
|
186 |
*/
|
56797
|
187 |
NCLOB(SqlClob.class),
|
56397
|
188 |
/**
|
|
189 |
* Identifies the generic SQL type {@code SQLXML}.
|
|
190 |
*/
|
56797
|
191 |
SQLXML(Void.class), //TODO
|
56380
|
192 |
|
56397
|
193 |
/**
|
56419
|
194 |
* Identifies the generic SQL type {@code REF CURSOR}.
|
56397
|
195 |
*/
|
56797
|
196 |
REF_CURSOR(Void.class), //TODO
|
56380
|
197 |
|
56397
|
198 |
/**
|
56419
|
199 |
* Identifies the generic SQL type {@code TIME WITH TIME ZONE}.
|
56397
|
200 |
*/
|
56797
|
201 |
TIME_WITH_TIME_ZONE(OffsetTime.class),
|
56380
|
202 |
|
56397
|
203 |
/**
|
56419
|
204 |
* Identifies the generic SQL type {@code TIMESTAMP WITH TIME ZONE}.
|
56397
|
205 |
*/
|
56797
|
206 |
TIMESTAMP_WITH_TIME_ZONE(OffsetDateTime.class);
|
56824
|
207 |
|
|
208 |
private static final String STANDARD_VENDOR = "jdk.incubator.sql2";
|
56380
|
209 |
|
56797
|
210 |
protected final Class javaType;
|
|
211 |
|
|
212 |
AdbaType(Class type) {
|
|
213 |
javaType = type;
|
|
214 |
}
|
56397
|
215 |
|
|
216 |
/**
|
|
217 |
*{@inheritDoc }
|
|
218 |
* @return The name of this {@code SQLType}.
|
|
219 |
*/
|
56380
|
220 |
@Override
|
|
221 |
public String getName() {
|
|
222 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
223 |
}
|
|
224 |
|
56397
|
225 |
/**
|
|
226 |
* Returns the name of the vendor that supports this data type.
|
|
227 |
* @return The name of the vendor for this data type which is
|
56824
|
228 |
* the package name containing this type.
|
56397
|
229 |
*/
|
56380
|
230 |
@Override
|
|
231 |
public String getVendor() {
|
56824
|
232 |
return STANDARD_VENDOR;
|
56380
|
233 |
}
|
|
234 |
|
56397
|
235 |
/**
|
|
236 |
* Returns the vendor specific type number for the data type.
|
|
237 |
* @return An Integer representing the data type. For {@code ABDAType},
|
|
238 |
* the value will be the same value as in {@code Types} for the data type.
|
|
239 |
*/
|
56380
|
240 |
@Override
|
56797
|
241 |
public <T> Class<T> getJavaType() {
|
|
242 |
return javaType;
|
|
243 |
}
|
|
244 |
|
56380
|
245 |
}
|