KickJava   Java API By Example, From Geeks To Geeks.

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


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.FileUtils;
10 import org.h2.util.MemoryFile;
11
12 public class MemoryFileStore extends FileStore {
13
14     private MemoryFile memFile;
15
16     public MemoryFileStore(DataHandler handler, String JavaDoc name, byte[] magic) throws SQLException JavaDoc {
17         super(handler, magic);
18         this.name = name;
19         memFile = FileUtils.getMemoryFile(name);
20         memFile.setMagic(magic);
21     }
22
23     public void close() {
24         // nothing to do
25
}
26     
27     public long getFilePointer() {
28         return memFile.getFilePointer();
29     }
30     
31     public long length() {
32         return memFile.length();
33     }
34     
35     public void readFully(byte[] b, int off, int len) throws SQLException JavaDoc {
36         checkPowerOff();
37         memFile.readFully(b, off, len);
38     }
39     
40     public void seek(long pos) {
41         memFile.seek(pos);
42     }
43     
44     public void setLength(long newLength) throws SQLException JavaDoc {
45         checkPowerOff();
46         memFile.setLength(newLength);
47     }
48     
49     public void write(byte[] b, int off, int len) throws SQLException JavaDoc {
50         checkPowerOff();
51         memFile.write(b, off, len);
52     }
53
54 }
55
Popular Tags