FileDocCategorySizeDatePackage
MapType.javaAPI DocHibernate 3.2.52792Wed Jul 05 13:17:28 BST 2006org.hibernate.type

MapType

public class MapType extends CollectionType

Fields Summary
Constructors Summary
public MapType(String role, String propertyRef, boolean isEmbeddedInXML)

		super(role, propertyRef, isEmbeddedInXML);
	
Methods Summary
public java.util.IteratorgetElementsIterator(java.lang.Object collection)

		return ( (java.util.Map) collection ).values().iterator();
	
public java.lang.ClassgetReturnedClass()

		return Map.class;
	
public java.lang.ObjectindexOf(java.lang.Object collection, java.lang.Object element)

		Iterator iter = ( (Map) collection ).entrySet().iterator();
		while ( iter.hasNext() ) {
			Map.Entry me = (Map.Entry) iter.next();
			//TODO: proxies!
			if ( me.getValue()==element ) return me.getKey();
		}
		return null;
	
public org.hibernate.collection.PersistentCollectioninstantiate(org.hibernate.engine.SessionImplementor session, org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable key)

		if ( session.getEntityMode()==EntityMode.DOM4J ) {
			return new PersistentMapElementHolder(session, persister, key);
		}
		else {
			return new PersistentMap(session);
		}
	
public java.lang.Objectinstantiate(int anticipatedSize)

		return anticipatedSize <= 0 
		       ? new HashMap()
		       : new HashMap( anticipatedSize + (int)( anticipatedSize * .75f ), .75f );
	
public java.lang.ObjectreplaceElements(java.lang.Object original, java.lang.Object target, java.lang.Object owner, java.util.Map copyCache, org.hibernate.engine.SessionImplementor session)


		CollectionPersister cp = session.getFactory().getCollectionPersister( getRole() );
		
		java.util.Map result = (java.util.Map) target;
		result.clear();
		
		Iterator iter = ( (java.util.Map) original ).entrySet().iterator();
		while ( iter.hasNext() ) {
			java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
			Object key = cp.getIndexType().replace( me.getKey(), null, session, owner, copyCache );
			Object value = cp.getElementType().replace( me.getValue(), null, session, owner, copyCache );
			result.put(key, value);
		}
		
		return result;
		
	
public org.hibernate.collection.PersistentCollectionwrap(org.hibernate.engine.SessionImplementor session, java.lang.Object collection)

		if ( session.getEntityMode()==EntityMode.DOM4J ) {
			return new PersistentMapElementHolder( session, (Element) collection );
		}
		else {
			return new PersistentMap( session, (java.util.Map) collection );
		}