KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > index > BtreeHead


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.index;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.store.DataPage;
10 import org.h2.store.Record;
11
12 public class BtreeHead extends Record {
13
14     private int rootPosition;
15     private boolean consistent;
16
17     public BtreeHead() {
18         // nothing to do
19
}
20
21     public BtreeHead(DataPage s) throws SQLException JavaDoc {
22         rootPosition = s.readInt();
23         consistent = s.readInt() == 1;
24     }
25     
26     public boolean getConsistent() {
27         return consistent;
28     }
29     
30     public void setConsistent(boolean b) {
31         this.consistent = b;
32     }
33
34     public int getByteCount(DataPage dummy) throws SQLException JavaDoc {
35         return 1 + dummy.getIntLen();
36     }
37
38     public void write(DataPage buff) throws SQLException JavaDoc {
39         buff.writeByte((byte) 'H');
40         buff.writeInt(rootPosition);
41         buff.writeInt(consistent ? 1 : 0);
42     }
43
44     void setRootPosition(int rootPosition) {
45         this.rootPosition = rootPosition;
46     }
47
48     int getRootPosition() {
49         return rootPosition;
50     }
51     
52     public boolean isPinned() {
53         return true;
54     }
55
56 }
57
Popular Tags