1 package com.quadcap.util.collections; 2 3 40 41 import java.io.IOException ; 42 43 import com.quadcap.util.DListItem; 44 45 53 public abstract class Cacheable extends Object { 54 55 boolean dirty = false; 56 57 63 int refCount = 0; 64 65 66 DListItem me; 67 68 72 protected Object key; 73 74 protected Object store; 75 76 79 public void init(Object store, Object key) throws IOException { 80 this.store = store; 81 this.key = key; 82 dirty = false; 83 } 84 85 88 public boolean isDirty() { return dirty; } 89 90 93 public void setDirty(boolean d) { dirty = d; } 94 95 98 public int getRefCount() { return refCount; } 99 100 103 public synchronized void setRefCount(int x) { refCount = x; } 104 105 108 public synchronized void incrRefCount() { refCount++; } 109 110 113 public synchronized void decrRefCount() { refCount--; } 114 115 118 public void setDListItem(DListItem d) { me = d; } 119 120 123 public DListItem getDListItem() { return me; } 124 125 128 public Object getKey() { return key; } 129 130 133 public void setKey(Object key) { this.key = key; } 134 135 138 abstract public Object getData(); 139 140 143 abstract public void setData(Object data); 144 145 148 public void flush() throws IOException { 149 dirty = false; 150 } 151 } 152 | Popular Tags |