1 5 package org.h2.util; 6 7 import java.util.Comparator ; 8 9 import org.h2.engine.Constants; 10 import org.h2.message.Message; 11 12 public abstract class CacheObject { 13 private boolean changed; 14 public CacheObject previous, next, chained; 15 public int cacheQueue; 16 private int blockCount; 17 private int pos; 18 19 public static void sort(ObjectArray recordList) { 20 recordList.sort(new Comparator () { 21 public int compare(Object a, Object b) { 22 int pa = ((CacheObject) a).getPos(); 23 int pb = ((CacheObject) b).getPos(); 24 return pa==pb ? 0 : (pa<pb ? -1 : 1); 25 } 26 }); 27 } 28 29 public void setBlockCount(int size) { 30 this.blockCount = size; 31 } 32 33 public int getBlockCount() { 34 return blockCount; 35 } 36 37 public void setPos(int pos) { 38 if(Constants.CHECK && (previous!=null || next!=null || chained!=null)) { 39 throw Message.getInternalError("setPos too late"); 40 } 41 this.pos = pos; 42 } 43 44 public int getPos() { 45 return pos; 46 } 47 48 public boolean isChanged() { 49 return changed; 50 } 51 52 public void setChanged(boolean b) { 53 changed = b; 54 } 55 56 public boolean isPinned() { 57 return false; 58 } 59 60 public boolean canRemove() { 61 return true; 62 } 63 64 } 65 | Popular Tags |