| 1 package com.quadcap.sql.file; 2 3 40 41 import java.io.IOException ; 42 43 import com.quadcap.util.DListItem; 44 45 51 public abstract class Cacheable extends Object { 52 53 boolean dirty = false; 54 55 56 boolean readOnly = false; 57 58 64 int refCount = 0; 65 66 67 DListItem me; 68 69 73 protected long key; 74 75 protected Object store; 76 77 80 public void init(Object store, long key) throws IOException { 81 this.store = store; 82 this.key = key; 83 dirty = false; 84 } 85 86 89 public Object getStore() { return store; } 90 91 94 public boolean isReadOnly() { return readOnly; } 95 96 99 public void setReadOnly(boolean v) { this.readOnly = v; } 100 101 104 public final boolean isDirty() { return dirty; } 105 106 109 public void setDirty(boolean d) { 110 if (readOnly) { 111 throw new RuntimeException ("Attempt to modify read-only item"); 112 } 113 dirty = d; 114 } 115 116 119 public final int getRefCount() { return refCount; } 120 121 124 public final void setRefCount(int x) { refCount = x; } 125 126 129 public final void incrRefCount() { 130 refCount++; 131 } 132 133 136 public final void decrRefCount() { refCount--; } 137 138 141 public final void setDListItem(DListItem d) { me = d; } 142 143 146 public final DListItem getDListItem() { return me; } 147 148 151 public long getKey() { return key; } 152 153 156 public void setKey(long key) { this.key = key; } 157 158 161 abstract public Object getData(); 162 163 166 abstract public void setData(Object data); 167 168 171 public void flush() throws IOException { 172 dirty = false; 173 } 174 } 175 | Popular Tags |