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

📄 indexedcollection.java

📁 用Java实现的23个常用设计模式源代码
💻 JAVA
字号:
//$Id: IndexedCollection.java,v 1.6.2.4 2003/11/12 02:43:48 oneovthafew Exp $package net.sf.hibernate.mapping;import java.util.Iterator;import net.sf.hibernate.MappingException;import net.sf.hibernate.engine.Mapping;/** * Indexed collections include Lists, Maps, arrays and * primitive arrays. * @author Gavin King */public abstract class IndexedCollection extends Collection {		public static final String DEFAULT_INDEX_COLUMN_NAME = "idx";		private SimpleValue index;		/**	 * Constructor for IndexedCollection.	 * @param owner	 */	public IndexedCollection(PersistentClass owner) {		super(owner);	}	public SimpleValue getIndex() {		return index;	}	public void setIndex(SimpleValue index) {		this.index = index;	}	public final boolean isIndexed() {		return true;	}	public void createPrimaryKey() {		PrimaryKey pk = new PrimaryKey();		Iterator iter = getKey().getColumnIterator();		while ( iter.hasNext() ) {			pk.addColumn( (Column) iter.next() );		}		iter =  index.getColumnIterator();		while ( iter.hasNext() ) {			pk.addColumn( (Column)  iter.next() ); // index should be last column listed		}		getCollectionTable().setPrimaryKey(pk);	}		public void validate(Mapping mapping) throws MappingException {		super.validate(mapping);		if ( !getIndex().isValid(mapping) ) {			throw new MappingException( 				"collection index mapping has wrong number of columns: " + 				getRole() +				" type: " + 				getIndex().getType().getName()			);		}	}}

⌨️ 快捷键说明

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