KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > util > CacheObject


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.util;
6
7 import java.util.Comparator JavaDoc;
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 JavaDoc() {
21             public int compare(Object JavaDoc a, Object JavaDoc 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