KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > cache > WeakCacheCell


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.cache;
25
26 import java.lang.ref.ReferenceQueue JavaDoc;
27 import java.lang.ref.WeakReference JavaDoc;
28
29 public class WeakCacheCell extends WeakReference JavaDoc {
30
31     private WeakCacheCell(Object JavaDoc id, Object JavaDoc object, ReferenceQueue JavaDoc referenceQueue) {
32         super(object, referenceQueue);
33         this.id = id;
34     }
35
36     public void setId(Object JavaDoc id) {
37         this.id = id;
38     }
39
40     public Object JavaDoc getId() {
41         return id;
42     }
43
44     public void setPrecedingCell(WeakCacheCell cell) {
45         precedingCell = cell;
46     }
47
48     public WeakCacheCell getPrecedingCell() {
49         return precedingCell;
50     }
51
52     public void setNextCell(WeakCacheCell cell) {
53         nextCell = cell;
54     }
55
56     public WeakCacheCell getNextCell() {
57         return nextCell;
58     }
59
60     public void delink() {
61         if (nextCell != null) {
62             nextCell.setPrecedingCell(precedingCell);
63         }
64         if (precedingCell != null) {
65             precedingCell.setNextCell(nextCell);
66         }
67         nextCell = null;
68         precedingCell = null;
69     }
70
71     public int hashCode() {
72         return id.hashCode();
73     }
74
75     public static WeakCacheCell newInstance(Object JavaDoc id, Object JavaDoc object, ReferenceQueue JavaDoc queue) {
76         return new WeakCacheCell(id, object, queue);
77     }
78
79     public String JavaDoc toString() {
80         return "WCC(" + String.valueOf(get()) + ")";
81     }
82
83
84     private WeakCacheCell precedingCell;
85     private WeakCacheCell nextCell;
86     private Object JavaDoc id;
87 }
Popular Tags