⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscolumnsrowfactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*   Derby - Class org.apache.derby.impl.sql.catalog.SYSCOLUMNSRowFactory   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.*/package org.apache.derby.impl.sql.catalog;import org.apache.derby.iapi.reference.Property;import org.apache.derby.iapi.types.DataTypeDescriptor;import org.apache.derby.iapi.types.TypeId;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.store.raw.RawStoreFactory;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.sql.dictionary.SystemColumn;import org.apache.derby.catalog.TypeDescriptor;import org.apache.derby.catalog.types.BaseTypeIdImpl;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.types.TypeId;import org.apache.derby.iapi.types.DataTypeDescriptor;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;import org.apache.derby.iapi.sql.dictionary.DataDictionary;import org.apache.derby.iapi.sql.dictionary.TableDescriptor;import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;import org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor;import org.apache.derby.iapi.sql.execute.ExecutionContext;import org.apache.derby.iapi.sql.execute.ExecutionFactory;import org.apache.derby.iapi.sql.execute.ExecIndexRow;import org.apache.derby.iapi.sql.execute.ExecRow;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.monitor.Monitor;import org.apache.derby.catalog.types.TypeDescriptorImpl;import org.apache.derby.catalog.DefaultInfo;import org.apache.derby.iapi.services.uuid.UUIDFactory;import org.apache.derby.catalog.UUID;import org.apache.derby.catalog.types.DefaultInfoImpl;import org.apache.derby.iapi.types.*;import java.io.Serializable;import java.util.Properties;/** * Factory for creating a SYSCOLUMNS row. * * * @version 0.1 * @author Rick Hillegas (extracted from DataDictionaryImpl). */public class SYSCOLUMNSRowFactory extends CatalogRowFactory{	static final String		TABLENAME_STRING = "SYSCOLUMNS";	/**	 * Old name for REFERENCEID, used by upgrade	 */	public static final String		OLD_REFERENCEID_NAME = "TABLEID";	protected static final int		SYSCOLUMNS_COLUMN_COUNT = 9;	/* Column #s for syscolumns (1 based) */	//TABLEID is an obsolete name, it is better to use 	//REFERENCEID, but to make life easier you can use either	protected static final int		SYSCOLUMNS_TABLEID = 1;	protected static final int		SYSCOLUMNS_REFERENCEID = 1;	protected static final int		SYSCOLUMNS_COLUMNNAME = 2;	protected static final int		SYSCOLUMNS_COLUMNNUMBER = 3;	protected static final int		SYSCOLUMNS_COLUMNDATATYPE = 4;	protected static final int		SYSCOLUMNS_COLUMNDEFAULT = 5;	protected static final int		SYSCOLUMNS_COLUMNDEFAULTID = 6;	protected static final int 		SYSCOLUMNS_AUTOINCREMENTVALUE = 7;	protected static final int 		SYSCOLUMNS_AUTOINCREMENTSTART = 8;	protected static final int		SYSCOLUMNS_AUTOINCREMENTINC = 9;	//private static final String	SYSCOLUMNS_INDEX1_NAME = "SYSCOLUMNS_INDEX1";	protected static final int		SYSCOLUMNS_INDEX1_ID = 0;	//private static final String	SYSCOLUMNS_INDEX2_NAME = "SYSCOLUMNS_INDEX2";	protected static final int		SYSCOLUMNS_INDEX2_ID = 1;	protected	static	final	String	REFERENCEDID_STRING = "REFERENCEID";	protected	static	final	String	COLUMNNAME_STRING = "COLUMNNAME";	protected	static	final	String	COLUMNDEFAULTID_STRING = "COLUMNDEFAULTID";    private	static	final	boolean[]	uniqueness = {		                                               true,													   false	                                                 };	private	static	final	String[]	uuids =	{		 "8000001e-00d0-fd77-3ed8-000a0a0b1900"	// catalog UUID		,"80000029-00d0-fd77-3ed8-000a0a0b1900"	// heap UUID		,"80000020-00d0-fd77-3ed8-000a0a0b1900"	// SYSCOLUMNS_INDEX1 UUID		,"6839c016-00d9-2829-dfcd-000a0a411400"	// SYSCOLUMNS_INDEX2 UUID	};	private static final int[][] indexColumnPositions = 	{		{SYSCOLUMNS_REFERENCEID, SYSCOLUMNS_COLUMNNAME},		{SYSCOLUMNS_COLUMNDEFAULTID}	};	private static final String[][] indexColumnNames =	{		{REFERENCEDID_STRING, COLUMNNAME_STRING},		{COLUMNDEFAULTID_STRING}	};	/////////////////////////////////////////////////////////////////////////////	//	//	STATE	//	/////////////////////////////////////////////////////////////////////////////	private	SystemColumn[]		columnList;	/////////////////////////////////////////////////////////////////////////////	//	//	CONSTRUCTORS	//	/////////////////////////////////////////////////////////////////////////////    public	SYSCOLUMNSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf,                                 boolean convertIdToLower)	{		this(uuidf, ef, dvf, convertIdToLower, TABLENAME_STRING);	}    public	SYSCOLUMNSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf,                                 boolean convertIdToLower, String myName )	{		super(uuidf,ef,dvf,convertIdToLower);		initInfo(SYSCOLUMNS_COLUMN_COUNT, myName, indexColumnPositions, indexColumnNames, uniqueness, uuids);	}	/////////////////////////////////////////////////////////////////////////////	//	//	METHODS	//	/////////////////////////////////////////////////////////////////////////////  /**	 * Make a SYSCOLUMNS row	 *	 * @param emptyRow	Make an empty row if this parameter is true	 * @param tableID	Table that the column is in	 * @param column	Column descriptor	 *	 * @return	Row suitable for inserting into SYSCOLUMNS.	 *	 * @exception   StandardException thrown on failure	 */	public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)					throws StandardException	{		ExecRow    				row;		DataValueDescriptor		col;		String					colName = null;		String					defaultID = null;		String					tabID = null;		Integer					colID = null;		TypeDescriptorImpl		typeDesc = null;		Object					defaultSerializable = null;		long					autoincStart = 0;		long					autoincInc = 0;		if (td != null)		{			ColumnDescriptor  column = (ColumnDescriptor)td;					/* Lots of info in the column's type descriptor */			typeDesc = column.getType().getCatalogType();			tabID = column.getReferencingUUID().toString();			colName = column.getColumnName();			colID = new Integer(column.getPosition() );			autoincStart = column.getAutoincStart();			autoincInc   = column.getAutoincInc();			if (column.getDefaultInfo() != null)			{				defaultSerializable = column.getDefaultInfo();			}			else			{				defaultSerializable = column.getDefaultValue();			}			if  (column.getDefaultUUID() != null)			{				defaultID = column.getDefaultUUID().toString();			}		}		/* Insert info into syscolumns */		/* RESOLVE - It would be nice to require less knowledge about syscolumns		 * and have this be more table driven.		 * RESOLVE - We'd like to store the DataTypeDescriptor in a column.		 */		/* Build the row to insert  */		row = getExecutionFactory().getValueRow(SYSCOLUMNS_COLUMN_COUNT);		/* 1st column is REFERENCEID (UUID - char(36)) */		row.setColumn(SYSCOLUMNS_REFERENCEID, dvf.getCharDataValue(tabID));		/* 2nd column is COLUMNNAME (varchar(128)) */		row.setColumn(SYSCOLUMNS_COLUMNNAME, dvf.getVarcharDataValue(colName));		/* 3rd column is COLUMNNUMBER (int) */		row.setColumn(SYSCOLUMNS_COLUMNNUMBER, dvf.getDataValue(colID));		/* 4th column is COLUMNDATATYPE */		row.setColumn(SYSCOLUMNS_COLUMNDATATYPE,				dvf.getDataValue(typeDesc));		/* 5th column is COLUMNDEFAULT */		row.setColumn(SYSCOLUMNS_COLUMNDEFAULT,					  dvf.getDataValue(defaultSerializable));		/* 6th column is DEFAULTID (UUID - char(36)) */		row.setColumn(SYSCOLUMNS_COLUMNDEFAULTID, dvf.getCharDataValue(defaultID));		if (autoincInc != 0)		{			row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, 						  new SQLLongint(autoincStart));			row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, 						  new SQLLongint(autoincStart));			row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC, 						  new SQLLongint(autoincInc));		}		else		{			row.setColumn(SYSCOLUMNS_AUTOINCREMENTVALUE, 						  new SQLLongint());			row.setColumn(SYSCOLUMNS_AUTOINCREMENTSTART, 						  new SQLLongint());			row.setColumn(SYSCOLUMNS_AUTOINCREMENTINC,						  new SQLLongint());		}		return row;	}	/**	 * Get the Properties associated with creating the heap.	 *	 * @return The Properties associated with creating the heap.	 */	public Properties getCreateHeapProperties()	{		Properties properties = new Properties();		// keep page size at 4K since its a big table		properties.put(Property.PAGE_SIZE_PARAMETER,"4096");		// default properties for system tables:		properties.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER,"0");		properties.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER,"1");		return properties;	}	/**	 * Get the Properties associated with creating the specified index.	 *	 * @param indexNumber	The specified index number.	 *	 * @return The Properties associated with creating the specified index.	 */	public Properties getCreateIndexProperties(int indexNumber)	{		Properties properties = new Properties();		// keep page size for all indexes at 4K since its a big table		properties.put(Property.PAGE_SIZE_PARAMETER,"4096");		return properties;	}	///////////////////////////////////////////////////////////////////////////	//	//	ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory	//	///////////////////////////////////////////////////////////////////////////	/**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -