KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > element > ListStore


1 package jfun.yan.element;
2
3 import java.util.List JavaDoc;
4
5 import jfun.util.Misc;
6
7 /**
8  * This implementation stores component instances into a java.util.List.
9  * <p>
10  * @author Ben Yu
11  * Nov 12, 2005 2:29:12 PM
12  */

13 public class ListStore<T> implements ElementStore<T> {
14   private final List JavaDoc<T> list;
15   
16   /**
17    * Get the list object storing the component instances.
18    */

19   public List JavaDoc<T> getList() {
20     return list;
21   }
22
23   /**
24    * Create a ListStore object.
25    * @param list the list to store component instances.
26    */

27   public ListStore(List JavaDoc<T> list) {
28     this.list = list;
29   }
30
31   public void storeElement(int ind, T obj) {
32     list.add(obj);
33   }
34
35   public boolean equals(Object JavaDoc obj) {
36     if(obj instanceof ListStore){
37       final ListStore other = (ListStore)obj;
38       return list==other.list;
39     }
40     else return false;
41   }
42
43   public int hashCode() {
44     return System.identityHashCode(list);
45   }
46
47   public String JavaDoc toString() {
48     return Misc.getTypeName(list.getClass());
49   }
50
51 }
52
Popular Tags