--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.catalog.SystemColumnImpl\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.impl.sql.catalog;\r
+\r
+import java.sql.Types;\r
+\r
+import org.apache.derby.iapi.sql.dictionary.SystemColumn;\r
+import org.apache.derby.iapi.types.DataTypeDescriptor;\r
+import org.apache.derby.iapi.types.TypeId;\r
+\r
+/**\r
+ * Implements the description of a column in a system table.\r
+ *\r
+ *\r
+ * @version 0.1\r
+ */\r
+\r
+class SystemColumnImpl implements SystemColumn\r
+{\r
+ private final String name;\r
+ \r
+ /**\r
+ * Fully described type of the column.\r
+ */\r
+ private final DataTypeDescriptor type;\r
+ \r
+ /**\r
+ * Create a system column for a builtin type.\r
+ * \r
+ * @param name\r
+ * name of column\r
+ * @param jdbcTypeId\r
+ * JDBC type id from java.sql.Types\r
+ * @param nullability\r
+ * Whether or not column accepts nulls.\r
+ */\r
+ static SystemColumn getColumn(String name, int jdbcTypeId,\r
+ boolean nullability) {\r
+ return new SystemColumnImpl(name, DataTypeDescriptor\r
+ .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability));\r
+ }\r
+ \r
+ /**\r
+ * Create a system column for a builtin type.\r
+ * \r
+ * @param name\r
+ * name of column\r
+ * @param jdbcTypeId\r
+ * JDBC type id from java.sql.Types\r
+ * @param nullability\r
+ * Whether or not column accepts nulls.\r
+ */\r
+ static SystemColumn getColumn(String name, int jdbcTypeId,\r
+ boolean nullability,int maxLength) {\r
+ return new SystemColumnImpl(name, DataTypeDescriptor\r
+ .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability, maxLength));\r
+ }\r
+ \r
+ /**\r
+ * Create a system column for an identifer with consistent type of\r
+ * VARCHAR(128)\r
+ * \r
+ * @param name\r
+ * Name of the column.\r
+ * @param nullability\r
+ * Nullability of the column.\r
+ * @return Object representing the column.\r
+ */\r
+ static SystemColumn getIdentifierColumn(String name, boolean nullability) {\r
+ return new SystemColumnImpl(name, DataTypeDescriptor\r
+ .getBuiltInDataTypeDescriptor(Types.VARCHAR, nullability, 128));\r
+ }\r
+\r
+ /**\r
+ * Create a system column for a character representation of a UUID with\r
+ * consistent type of CHAR(36)\r
+ * \r
+ * @param name\r
+ * Name of the column.\r
+ * @param nullability\r
+ * Nullability of the column.\r
+ * @return Object representing the column.\r
+ */\r
+ static SystemColumn getUUIDColumn(String name, boolean nullability) {\r
+ return new SystemColumnImpl(name, DataTypeDescriptor\r
+ .getBuiltInDataTypeDescriptor(Types.CHAR, nullability, 36));\r
+ }\r
+\r
+ /**\r
+ * Create a system column for a character representation of an indicator\r
+ * column with consistent type of CHAR(1) NOT NULL\r
+ * \r
+ * @param name\r
+ * Name of the column.\r
+ * @return Object representing the column.\r
+ */\r
+ static SystemColumn getIndicatorColumn(String name) {\r
+ return new SystemColumnImpl(name, DataTypeDescriptor\r
+ .getBuiltInDataTypeDescriptor(Types.CHAR, false, 1));\r
+ }\r
+\r
+ /**\r
+ * Create a system column for a java column.\r
+ * \r
+ * @param name\r
+ * Name of the column.\r
+ * @param javaClassName\r
+ * @param nullability\r
+ * Nullability of the column.\r
+ * @return Object representing the column.\r
+ */\r
+ static SystemColumn getJavaColumn(String name, String javaClassName,\r
+ boolean nullability) {\r
+\r
+ TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName, false);\r
+\r
+ DataTypeDescriptor dtd = new DataTypeDescriptor(typeId, nullability);\r
+ return new SystemColumnImpl(name, dtd);\r
+ }\r
+\r
+ /**\r
+ * Create a SystemColumnImpl representing the given name and type.\r
+ */\r
+ private SystemColumnImpl(String name, DataTypeDescriptor type) {\r
+ this.name = name;\r
+ this.type = type;\r
+ }\r
+\r
+ /**\r
+ * Gets the name of this column.\r
+ *\r
+ * @return The column name.\r
+ */\r
+ public String getName()\r
+ {\r
+ return name;\r
+ }\r
+\r
+ /**\r
+ * Return the type of this column.\r
+ */\r
+ public DataTypeDescriptor getType() {\r
+ return type;\r
+ }\r
+}\r
+\r