in core/src/main/java/org/apache/calcite/avatica/SqlType.java [405:489]
static {
SET_LIST = new HashMap<>();
GET_LIST = new HashMap<>();
EnumSet<SqlType> numericTypes = EnumSet.of(TINYINT, SMALLINT, INTEGER,
BIGINT, REAL, FLOAT, DOUBLE, DECIMAL, NUMERIC, BIT, BOOLEAN);
Class[] numericClasses = {
BigDecimal.class, Boolean.class, Byte.class, Short.class, Integer.class,
Long.class, Float.class, Double.class
};
EnumSet<SqlType> charTypes = EnumSet.of(CHAR, VARCHAR, LONGVARCHAR);
EnumSet<SqlType> ncharTypes = EnumSet.of(NCHAR, NVARCHAR, LONGNVARCHAR);
EnumSet<SqlType> binaryTypes = EnumSet.of(BINARY, VARBINARY, LONGVARBINARY);
EnumSet<SqlType> dateTimeTypes = EnumSet.of(DATE, TIME, TIMESTAMP);
final EnumSet<SqlType> numericCharTypes = concat(numericTypes, charTypes);
SET_LIST.put(String.class,
concat(numericCharTypes, binaryTypes, dateTimeTypes, ncharTypes));
for (Class clazz : numericClasses) {
SET_LIST.put(clazz, numericCharTypes);
}
SET_LIST.put(byte[].class, binaryTypes);
SET_LIST.put(BigInteger.class,
EnumSet.of(BIGINT, CHAR, VARCHAR, LONGVARCHAR));
SET_LIST.put(java.sql.Date.class,
concat(charTypes, EnumSet.of(DATE, TIMESTAMP)));
SET_LIST.put(Time.class,
concat(charTypes, EnumSet.of(TIME, TIMESTAMP)));
SET_LIST.put(Timestamp.class,
concat(charTypes, EnumSet.of(DATE, TIME, TIMESTAMP)));
SET_LIST.put(Array.class, EnumSet.of(ARRAY));
SET_LIST.put(Blob.class, EnumSet.of(BLOB));
SET_LIST.put(Clob.class, EnumSet.of(CLOB));
SET_LIST.put(Struct.class, EnumSet.of(STRUCT));
SET_LIST.put(Ref.class, EnumSet.of(REF));
SET_LIST.put(URL.class, EnumSet.of(DATALINK));
SET_LIST.put(Class.class, EnumSet.of(JAVA_OBJECT));
SET_LIST.put(RowId.class, EnumSet.of(ROWID));
SET_LIST.put(NClob.class, EnumSet.of(NCLOB));
SET_LIST.put(java.sql.SQLXML.class, EnumSet.of(SQLXML));
SET_LIST.put(Calendar.class,
concat(charTypes, EnumSet.of(DATE, TIME, TIMESTAMP)));
SET_LIST.put(java.util.Date.class,
concat(charTypes, EnumSet.of(DATE, TIME, TIMESTAMP)));
EnumSet<Method> numericMethods =
EnumSet.of(Method.GET_BYTE, Method.GET_SHORT, Method.GET_INT,
Method.GET_LONG, Method.GET_FLOAT, Method.GET_DOUBLE,
Method.GET_BIG_DECIMAL, Method.GET_BOOLEAN);
for (Method method : numericMethods) {
GET_LIST.put(method, numericCharTypes);
}
GET_LIST.put(Method.GET_BYTE, EnumSet.of(ROWID));
for (Method method : EnumSet.of(Method.GET_STRING, Method.GET_N_STRING)) {
GET_LIST.put(method,
concat(numericCharTypes, binaryTypes, dateTimeTypes,
EnumSet.of(DATALINK), ncharTypes));
}
GET_LIST.put(Method.GET_BYTES, binaryTypes);
GET_LIST.put(Method.GET_DATE,
concat(charTypes, EnumSet.of(DATE, TIMESTAMP)));
GET_LIST.put(Method.GET_TIME,
concat(charTypes, EnumSet.of(TIME, TIMESTAMP)));
GET_LIST.put(Method.GET_TIMESTAMP,
concat(charTypes, EnumSet.of(DATE, TIME, TIMESTAMP)));
GET_LIST.put(Method.GET_ASCII_STREAM,
concat(charTypes, binaryTypes, EnumSet.of(CLOB, NCLOB)));
GET_LIST.put(Method.GET_BINARY_STREAM,
concat(binaryTypes, EnumSet.of(BLOB, SQLXML)));
GET_LIST.put(Method.GET_CHARACTER_STREAM,
concat(charTypes, binaryTypes, ncharTypes,
EnumSet.of(CLOB, NCLOB, SQLXML)));
GET_LIST.put(Method.GET_N_CHARACTER_STREAM,
concat(
charTypes, binaryTypes, ncharTypes, EnumSet.of(CLOB, NCLOB, SQLXML)));
GET_LIST.put(Method.GET_CLOB, EnumSet.of(CLOB, NCLOB));
GET_LIST.put(Method.GET_N_CLOB, EnumSet.of(CLOB, NCLOB));
GET_LIST.put(Method.GET_BLOB, EnumSet.of(BLOB));
GET_LIST.put(Method.GET_ARRAY, EnumSet.of(ARRAY));
GET_LIST.put(Method.GET_REF, EnumSet.of(REF));
GET_LIST.put(Method.GET_BLOB, EnumSet.of(BLOB));
GET_LIST.put(Method.GET_URL, EnumSet.of(DATALINK));
GET_LIST.put(Method.GET_OBJECT, EnumSet.allOf(SqlType.class));
GET_LIST.put(Method.GET_ROW_ID, EnumSet.of(ROWID));
GET_LIST.put(Method.GET_SQLXML, EnumSet.of(SQLXML));
}