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

📄 constraintdescriptor.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*   Derby - Class org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor   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.iapi.sql.dictionary;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.sql.depend.Provider;import org.apache.derby.iapi.sql.depend.Dependent;import org.apache.derby.catalog.UUID;import org.apache.derby.iapi.reference.SQLState;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.sql.StatementType;import org.apache.derby.catalog.DependableFinder;import org.apache.derby.catalog.Dependable;import org.apache.derby.iapi.services.io.StoredFormatIds;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.sql.depend.DependencyManager;import org.apache.derby.iapi.sql.depend.Dependent;import org.apache.derby.iapi.sql.depend.Dependency;import org.apache.derby.iapi.sql.depend.Provider;import	org.apache.derby.iapi.sql.conn.LanguageConnectionContext;/** * This class is used to get information from a ConstraintDescriptor. * A ConstraintDescriptor can represent a constraint on a table or on a * column. * * @version 0.1 * @author Jeff Lichtman */public abstract class ConstraintDescriptor 	extends TupleDescriptor	implements UniqueTupleDescriptor, Provider, Dependent{	// used to indicate what type of constraints we 	// are interested in	public static final int ENABLED		= 1;	public static final int DISABLED	= 2;	public static final int ALL			= 3;	// field that we want users to be able to know about	public static final int SYSCONSTRAINTS_STATE_FIELD = 6;	TableDescriptor		table;	String				constraintName;	boolean				deferrable;	boolean				initiallyDeferred;	boolean				isEnabled;	int[]				referencedColumns;	UUID					constraintId;	SchemaDescriptor	schemaDesc;	ColumnDescriptorList	colDL;	/**	 * Constructor for a ConstraintDescriptor	 *	 * @param dataDictionary		The data dictionary that this descriptor lives in	 * @param table		The descriptor of the table the constraint is on	 * @param constraintName	The name of the constraint.	 * @param deferrable		If the constraint can be deferred.	 * @param initiallyDeferred If the constraint starts life deferred.	 * @param referencedColumns columns that the constraint references	 * @param checkConstraint	the expression for a check constraint.	 * @param constraintId		UUID of constraint	 * @param schemaDesc		SchemaDescriptor	 */	ConstraintDescriptor(		    DataDictionary dataDictionary,			TableDescriptor table,			String constraintName,			boolean deferrable,			boolean initiallyDeferred,			int[] referencedColumns,			UUID constraintId,			SchemaDescriptor schemaDesc,			boolean isEnabled			)	{		super( dataDictionary );		this.table = table;		this.constraintName = constraintName;		this.deferrable = deferrable;		this.initiallyDeferred = initiallyDeferred;		this.referencedColumns = referencedColumns;		this.constraintId = constraintId;		this.schemaDesc = schemaDesc;		this.isEnabled = isEnabled;	}	/**	 * Gets the UUID of the table the constraint is on.	 *	 * @return	The UUID of the table the constraint is on.	 */	public UUID	getTableId()	{		return table.getUUID();	}	/**	 * Sets the UUID of the constraint.	 *	 * @param constraintId	The constraint Id.	 * @return	Nothing.	 */	public void	setConstraintId(UUID constraintId)	{		this.constraintId = constraintId;	}	/**	 * Gets the UUID of the constraint.	 *	 * @return	The UUID of the constraint.	 */	public UUID	getUUID()	{		return constraintId;	}	/**	 * Gets the name of the constraint.	 *	 * @return	A String containing the name of the constraint.	 */	public String	getConstraintName()	{		return constraintName;	}	/**	 * Gets an identifier telling what type of descriptor it is	 * (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).	 *	 * @return	An identifier telling what type of descriptor it is	 *		(UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).	 */	public abstract int	getConstraintType();	public abstract UUID getConglomerateId();	/**	 * Get the text of the constraint. (Only non-null/meaningful for check	 * constraints.)	 * @return	The constraint text.	 */	public String getConstraintText()	{		return null;	}	/**	 * Returns TRUE if the constraint is deferrable	 * (we will probably not do deferrable constraints in the	 * initial release, but I want this to be part of the interface).	 *	 * @return	TRUE if the constraint is deferrable, FALSE if not	 */	public boolean	deferrable()	{		return deferrable;	}	/**	 * Returns TRUE if the constraint is initially deferred	 * (we will probably not do initially deferred constraints	 * in the initial release, but I want this to be part of the interface).	 *	 * @return	TRUE if the constraint is initially deferred,	 *		FALSE if not	 */	public boolean	initiallyDeferred()	{		return initiallyDeferred;	}	/**	 * Returns an array of column ids (i.e. ordinal positions) for	 * the columns referenced in this table for a primary key, unique	 * key, referential, or check constraint.	 *	 * @return	An array of column ids for those constraints that can	 *		be on columns (primary, unique key, referential	 *		constraints, and check constraints).  For check and	 *		unique constraints, it returns an array of columns ids	 *		that are referenced in the constraint.  For primary key	 *		and referential constraints, it returns an array of	 *		column ids for the columns in this table (i.e. the	 *		primary key columns for a primary key constraint,	 *		and the foreign key columns for a foreign key	 *		constraint.	 */	public int[]	getReferencedColumns()	{		return referencedColumns;	}	/**	 * Does this constraint have a backing index?	 *	 * @return boolean	Whether or not there is a backing index for this constraint.	 */	public abstract boolean hasBackingIndex();	/**	 * Get the SchemaDescriptor for the schema that this constraint	 * belongs to.	 *	 * @return SchemaDescriptor The SchemaDescriptor for this constraint.	 */	public SchemaDescriptor getSchemaDescriptor()	{		return schemaDesc;	}	/**	  RESOLVE: For now the ConstraintDescriptor code stores the array of key	  columns in the field 'otherColumns'. Jerry plans to re-organize things.	  For now to minimize his rototill I've implemented this function on the	  old structures. All new code should use getKeyColumns to get a constraint's	  key columns.	  	  @see org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor#getKeyColumns	  */	public int[]	getKeyColumns()	{		return getReferencedColumns();	}	/**	 * Is this constraint active?	 *	 * @return true/false	 */	public boolean isEnabled()	{		return isEnabled;	}	/**	 * Set the constraint to enabled.	 * Does not update the data dictionary	 */	public void setEnabled()	{		isEnabled = true;	}	/**	 * Set the constraint to disabled.	 * Does not update the data dictionary	 */	public void setDisabled()	{		isEnabled = false;	}	/**	 * Is this constraint referenced?  Return	 * false.  Overridden by ReferencedKeyConstraints.	 *	 * @return false	 */	public boolean isReferenced()	{		return false;	}	/**	 * Get the number of enabled fks that	 * reference this key.  Overriden by	 * ReferencedKeyConstraints.	 *	 * @return the number of fks	 */	public int getReferenceCount()	{		return 0;	}	/**	 * Does this constraint need to fire on this type of	 * DML?	 *	 * @param dmlType	the type of DML 	 * (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)	 * @param modifiedCols	the columns modified, or null for all	 *	 * @return true/false	 */	public abstract boolean needsToFire(int stmtType, int[] modifiedCols);	/**	 * Get the table descriptor upon which this constraint

⌨️ 快捷键说明

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