docomentataion
[mir.git] / source / mir / storage / store / StoreContainer.java
1 package mir.storage.store;
2
3 /**
4  * Title:         StoreContainer
5  *
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.
11  *
12  * Copyright:     Copyright (c) 2002
13  * Company:       indy
14  * @author        //rk
15  * @version 1.0
16  */
17
18 import java.util.*;
19 import mir.misc.Logfile;
20
21 public class StoreContainer {
22
23   private final static int DEFAULT_SIZE=10;
24
25   private LinkedList          container;
26   private StoreContainerType  stocType;
27   private int                 maxSize=DEFAULT_SIZE;
28   private static Logfile      storeLog;
29
30   private StoreContainer() {};
31
32   public StoreContainer(StoreContainerType stoc_type) {
33     this.stocType=stoc_type;
34     this.container=new LinkedList();
35   }
36
37   public StoreContainer(StoreContainerType stoc_type, int maxSize) {
38     this();
39     this.maxSize=maxSize;
40   }
41
42   /** @todo methods: release+propagation */
43
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
48     return null;
49   }
50
51   public boolean has(StoreIdentifier sid) {
52     return true; // yes yes
53   }
54
55   public void add(StoreIdentifier sid) {
56     // add to head of linkedlist, if size is exeded throw away tail until
57     // size ok.
58   }
59
60   /**
61    *  Method:       setSize
62    *  Description:  readjusts StoreContainer size to value.
63    *
64    */
65   public void setSize(int size) {
66     /** @todo  check size, if size too big, shrink  */
67     this.maxSize=size;
68   }
69
70   /**
71    *  Method:       toString()
72    *  Description:  gives out statistical Information, viewable via
73    *                @see ServletStoreInfo.
74    *
75    *  @return       String
76    */
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");
82     return sb.toString();
83   }
84
85 }