1 package mir.storage.store;
4 * Title: StoreContainer
6 * Description: This is the bucket object for one type of StorableObjects,
7 * mainy a linked list of StoreIdenfiers. On use or creation
8 * an object stored in StoreIdentifier is put to head of the
9 * list. if maximum size of the list is reached, the
10 * StoreIdentifier at the end of the list is released.
12 * Copyright: Copyright (c) 2002
19 import mir.misc.Logfile;
21 public class StoreContainer {
23 private final static int DEFAULT_SIZE=10;
25 private LinkedList container;
26 private StoreContainerType stocType;
27 private int maxSize=DEFAULT_SIZE;
28 private static Logfile storeLog;
30 private StoreContainer() {};
32 public StoreContainer(StoreContainerType stoc_type) {
33 this.stocType=stoc_type;
34 this.container=new LinkedList();
37 public StoreContainer(StoreContainerType stoc_type, int maxSize) {
42 /** @todo methods: release+propagation */
44 public StorableObject use(StoreIdentifier sid) {
45 // find sid in LinkedList or die
46 // move sid to head of linked list
47 // return reference on object
51 public boolean has(StoreIdentifier sid) {
52 return true; // yes yes
55 public void add(StoreIdentifier sid) {
56 // add to head of linkedlist, if size is exeded throw away tail until
62 * Description: readjusts StoreContainer size to value.
65 public void setSize(int size) {
66 /** @todo check size, if size too big, shrink */
72 * Description: gives out statistical Information, viewable via
73 * @see ServletStoreInfo.
77 public String toString() {
78 StringBuffer sb = new StringBuffer("StoreContainer for ");
79 sb.append(stocType.toString()).append("\nCurrent size: ");
80 sb.append(container.size()).append("\nMaximum size:");
81 sb.append(maxSize).append("\n");