--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.catalog.TypeDescriptor\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.catalog;\r
+\r
+import org.apache.derby.iapi.types.StringDataValue;\r
+\r
+/**\r
+ *\r
+ * An interface for describing types in Derby systems.\r
+ * \r
+ * \r
+ * <p>The values in system catalog DATATYPE columns are of type\r
+ * TypeDescriptor.\r
+ */\r
+\r
+public interface TypeDescriptor\r
+{\r
+ ///////////////////////////////////////////////////////////////////////\r
+ //\r
+ // CONSTANTS\r
+ //\r
+ ///////////////////////////////////////////////////////////////////////\r
+\r
+ /**\r
+ The return value from getMaximumWidth() for types where the maximum\r
+ width is unknown.\r
+ */\r
+\r
+ public static int MAXIMUM_WIDTH_UNKNOWN = -1;\r
+\r
+\r
+ ///////////////////////////////////////////////////////////////////////\r
+ //\r
+ // METHODS\r
+ //\r
+ ///////////////////////////////////////////////////////////////////////\r
+\r
+ /**\r
+ * Get the jdbc type id for this type. JDBC type can be\r
+ * found in java.sql.Types. \r
+ *\r
+ * @return a jdbc type, e.g. java.sql.Types.DECIMAL \r
+ *\r
+ * @see java.sql.Types\r
+ */\r
+ public int getJDBCTypeId();\r
+\r
+ /**\r
+ Returns the maximum width of the type. This may have\r
+ different meanings for different types. For example, with char,\r
+ it means the maximum number of characters, while with int, it\r
+ is the number of bytes (i.e. 4).\r
+\r
+ @return the maximum length of this Type; -1 means "unknown/no max length"\r
+ */\r
+ public int getMaximumWidth();\r
+\r
+\r
+ /**\r
+ Returns the maximum width of the type IN BYTES. This is the\r
+ maximum number of bytes that could be returned for this type\r
+ if the corresponding getXXX() method is used. For example,\r
+ if we have a CHAR type, then we want the number of bytes\r
+ that would be returned by a ResultSet.getString() call.\r
+\r
+ @return the maximum length of this Type IN BYTES;\r
+ -1 means "unknown/no max length"\r
+ */\r
+ public int getMaximumWidthInBytes();\r
+\r
+\r
+ /**\r
+ Returns the number of decimal digits for the type, if applicable.\r
+ \r
+ @return The number of decimal digits for the type. Returns\r
+ zero for non-numeric types.\r
+ */\r
+ public int getPrecision();\r
+\r
+\r
+ /**\r
+ Returns the number of digits to the right of the decimal for\r
+ the type, if applicable.\r
+ \r
+ @return The number of digits to the right of the decimal for\r
+ the type. Returns zero for non-numeric types.\r
+ */\r
+ public int getScale();\r
+\r
+\r
+ /**\r
+ Gets the nullability that values of this type have.\r
+ \r
+\r
+ @return true if values of this type may be null. false otherwise\r
+ */\r
+ public boolean isNullable();\r
+\r
+ /**\r
+ Gets the name of this type.\r
+ \r
+\r
+ @return the name of this type\r
+ */\r
+ public String getTypeName();\r
+\r
+\r
+ /**\r
+ Converts this type descriptor (including length/precision)\r
+ to a string suitable for appearing in a SQL type specifier. E.g.\r
+ \r
+ VARCHAR(30)\r
+\r
+ or\r
+\r
+ java.util.Hashtable \r
+ \r
+ \r
+ @return String version of type, suitable for running through\r
+ a SQL Parser.\r
+ \r
+ */\r
+ public String getSQLstring();\r
+\r
+ /**\r
+ * Get the collation type for this type. This api applies only to character\r
+ * string types. And its return value is valid only if the collation \r
+ * derivation of this type is "implicit" or "explicit". (In Derby 10.3,\r
+ * collation derivation can't be "explicit". Hence in Derby 10.3, this api\r
+ * should be used only if the collation derivation is "implicit". \r
+ *\r
+ * @return collation type which applies to character string types with\r
+ * collation derivation of "implicit" or "explicit". The possible return\r
+ * values in Derby 10.3 will be COLLATION_TYPE_UCS_BASIC\r
+ * and COLLATION_TYPE_TERRITORY_BASED.\r
+ * \r
+ * @see StringDataValue#COLLATION_TYPE_UCS_BASIC\r
+ * @see StringDataValue#COLLATION_TYPE_TERRITORY_BASED\r
+ * \r
+ */\r
+ public int getCollationType();\r
+\r
+ /**\r
+ * Get the collation derivation for this type. This applies only for\r
+ * character string types. For the other types, this api should be\r
+ * ignored.\r
+ * \r
+ * SQL spec talks about character string types having collation type and \r
+ * collation derivation associated with them (SQL spec Section 4.2.2 \r
+ * Comparison of character strings). If collation derivation says explicit \r
+ * or implicit, then it means that there is a valid collation type \r
+ * associated with the charcter string type. If the collation derivation is \r
+ * none, then it means that collation type can't be established for the \r
+ * character string type.\r
+ * \r
+ * 1)Collation derivation will be explicit if SQL COLLATE clause has been \r
+ * used for character string type (this is not a possibility for Derby 10.3 \r
+ * because we are not planning to support SQL COLLATE clause in the 10.3\r
+ * release). \r
+ * \r
+ * 2)Collation derivation will be implicit if the collation can be \r
+ * determined w/o the COLLATE clause eg CREATE TABLE t1(c11 char(4)) then \r
+ * c11 will have collation of USER character set. Another eg, TRIM(c11) \r
+ * then the result character string of TRIM operation will have collation \r
+ * of the operand, c11.\r
+ * \r
+ * 3)Collation derivation will be none if the aggregate methods are dealing \r
+ * with character strings with different collations (Section 9.3 Data types \r
+ * of results of aggregations Syntax Rule 3aii).\r
+ * \r
+ * Collation derivation will be initialized to COLLATION_DERIVATION_NONE.\r
+ * \r
+ * @return Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT\r
+ * \r
+ * @see StringDataValue#COLLATION_DERIVATION_NONE\r
+ * @see StringDataValue#COLLATION_DERIVATION_IMPLICIT\r
+ * @see StringDataValue#COLLATION_DERIVATION_EXPLICIT\r
+ */\r
+ public int getCollationDerivation();\r
+\r
+ /**\r
+ * Gets the name of the collation type in this descriptor.\r
+ * <p>\r
+ * Used to generate strings decribing collation type for error messages.\r
+ * \r
+ *\r
+ * @return the name of the collation being used in this type.\r
+ */\r
+ public String getCollationName();\r
+}\r
+\r