KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > store > Record


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.store;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.util.CacheObject;
10
11 /**
12  * @author Thomas
13  */

14 public abstract class Record extends CacheObject {
15     private boolean deleted;
16     private int storageId;
17     private int lastLog = LogSystem.LOG_WRITTEN;
18     private int lastPos = LogSystem.LOG_WRITTEN;
19
20     public abstract int getByteCount(DataPage dummy) throws SQLException JavaDoc;
21
22     /**
23      * This method is called just before the page is written.
24      * If a read operation is required before writing, this needs to be done here.
25      * Because the data page buffer is shared for read and write operations.
26      * The method may read data and change the file pointer.
27      */

28     public void prepareWrite() throws SQLException JavaDoc {
29     }
30
31     public abstract void write(DataPage buff) throws SQLException JavaDoc;
32
33     public boolean isEmpty() {
34         return false;
35     }
36
37     public void setDeleted(boolean deleted) {
38         this.deleted = deleted;
39     }
40
41     public boolean getDeleted() {
42         return deleted;
43     }
44
45     public void setStorageId(int storageId) {
46         this.storageId = storageId;
47     }
48
49     public int getStorageId() {
50         return storageId;
51     }
52
53     public void setLastLog(int log, int pos) {
54         lastLog = log;
55         lastPos = pos;
56     }
57
58     public void setLogWritten(int log, int pos) {
59         if(log < lastLog) {
60             return;
61         }
62         if(log > lastLog || pos >= lastPos) {
63             lastLog = LogSystem.LOG_WRITTEN;
64             lastPos = LogSystem.LOG_WRITTEN;
65         }
66     }
67
68     public boolean canRemove() {
69         if((isChanged() && !isLogWritten()) || isPinned()) {
70             return false;
71         }
72         return true;
73     }
74
75     public boolean isLogWritten() {
76         return lastLog == LogSystem.LOG_WRITTEN;
77     }
78
79 }
80
Popular Tags