KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > cache > entry > CollectionCacheEntry


1 //$Id: CollectionCacheEntry.java,v 1.2 2005/05/20 19:50:06 oneovthafew Exp $
2
package org.hibernate.cache.entry;
3
4 import java.io.Serializable JavaDoc;
5
6 import org.hibernate.collection.PersistentCollection;
7 import org.hibernate.persister.collection.CollectionPersister;
8 import org.hibernate.util.ArrayHelper;
9
10 /**
11  * @author Gavin King
12  */

13 public class CollectionCacheEntry implements Serializable JavaDoc {
14
15     private final Serializable JavaDoc state;
16     
17     public Serializable JavaDoc[] getState() {
18         //TODO: assumes all collections disassemble to an array!
19
return (Serializable JavaDoc[]) state;
20     }
21
22     public CollectionCacheEntry(PersistentCollection collection, CollectionPersister persister) {
23         this.state = collection.disassemble(persister);
24     }
25     
26     CollectionCacheEntry(Serializable JavaDoc state) {
27         this.state = state;
28     }
29     
30     public void assemble(
31         final PersistentCollection collection,
32         final CollectionPersister persister,
33         final Object JavaDoc owner
34     ) {
35         collection.initializeFromCache(persister, state, owner);
36         collection.afterInitialize();
37     }
38     
39     public String JavaDoc toString() {
40         return "CollectionCacheEntry" + ArrayHelper.toString( getState() );
41     }
42
43 }
44
Popular Tags