1 24 package org.objectweb.jalisto.se.impl.cache; 25 26 import java.lang.ref.ReferenceQueue ; 27 import java.lang.ref.WeakReference ; 28 29 public class WeakCacheCell extends WeakReference { 30 31 private WeakCacheCell(Object id, Object object, ReferenceQueue referenceQueue) { 32 super(object, referenceQueue); 33 this.id = id; 34 } 35 36 public void setId(Object id) { 37 this.id = id; 38 } 39 40 public Object 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 id, Object object, ReferenceQueue queue) { 76 return new WeakCacheCell(id, object, queue); 77 } 78 79 public String toString() { 80 return "WCC(" + String.valueOf(get()) + ")"; 81 } 82 83 84 private WeakCacheCell precedingCell; 85 private WeakCacheCell nextCell; 86 private Object id; 87 } | Popular Tags |