compilable snapshot of ObjectStore / day two
[mir.git] / source / mir / storage / store / StoreIdentifier.java
1 package mir.storage.store;
2
3 /**
4  * Title:        Class StoreIdentifier
5  * Description:
6  * Copyright:    Copyright (c) 2002
7  * Company:       indy
8  * @author        rk
9  * @version 1.0
10  */
11 import java.util.*;
12 import mir.misc.Logfile;
13
14 public class StoreIdentifier {
15
16   /** @todo move main stuff to storecontainertype */
17
18   private static Logfile      storeLog;
19
20   private StoreContainerType  stocType=null;
21   private StorableObject      reference=null;
22   private String              uniqueIdentifier=null; // id for Entity & sql for EntityList
23   private long                timesUsed;
24
25   /** @todo initialize logfile  */
26
27   private StoreIdentifier() {}
28
29   public StoreIdentifier(StorableObject reference, int storeType, String uniqueIdentifier) {
30     this.reference=reference;
31     this.uniqueIdentifier=uniqueIdentifier;
32     this.stocType = StoreContainerType.valueOf(reference.getClass(), storeType);
33   }
34
35   public void invalidate() {
36     Set set = reference.notifyOnReleaseSet();
37     /** @todo here we should propagate the invalidation all members of Set
38      *    @see StoreContainer */
39
40     this.reference=null;
41     this.uniqueIdentifier=null;
42     this.stocType=null;
43   }
44
45   public Object use() {
46     timesUsed++;
47     return reference;
48   }
49
50   /**
51    *  Method equals for comparison between two identifier
52    *
53    *  @return true if yes otherwise false
54    *
55    */
56   public boolean equals(StoreIdentifier sid) {
57     // compare al relevant fields, most likely difference first
58     /** @todo doubecheck with book */
59
60     return false;
61   }
62
63   public StoreContainerType getStoreContainerType() { return stocType; }
64   public boolean hasReference() { return (reference==null) ? false:true; }
65
66   public String toString() {
67     return reference.getClass()+"@storetype"+stocType.toString()+"."
68                 +uniqueIdentifier+" ("+timesUsed+") times used )";
69   }
70
71
72 }