01: /**
02: * com.mckoi.store.JournalledResource 11 Jun 2003
03: *
04: * Mckoi SQL Database ( http://www.mckoi.com/database )
05: * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * Version 2 as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License Version 2 for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * Version 2 along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: * Change Log:
21: *
22: *
23: */package com.mckoi.store;
24:
25: import java.io.IOException;
26:
27: /**
28: * An interface that allows for the reading and writing of pages to/from a
29: * journalled.
30: *
31: * @author Tobias Downer
32: */
33:
34: interface JournalledResource {
35:
36: /**
37: * Returns the page size.
38: */
39: int getPageSize();
40:
41: /**
42: * Returns a unique id for this resource.
43: */
44: long getID();
45:
46: /**
47: * Reads a page of some previously specified size into the byte array.
48: */
49: void read(long page_number, byte[] buf, int off) throws IOException;
50:
51: /**
52: * Writes a page of some previously specified size to the top log. This will
53: * add a single entry to the log and any 'read' operations after will contain
54: * the written data.
55: */
56: void write(long page_number, byte[] buf, int off, int len)
57: throws IOException;
58:
59: /**
60: * Sets the new size of the resource. This will add a single entry to the
61: * log.
62: */
63: void setSize(long size) throws IOException;
64:
65: /**
66: * Returns the current size of this resource.
67: */
68: long getSize() throws IOException;
69:
70: /**
71: * Opens the resource.
72: */
73: void open(boolean read_only) throws IOException;
74:
75: /**
76: * Closes the resource. This will actually simply log that the resource has
77: * been closed.
78: */
79: void close() throws IOException;
80:
81: /**
82: * Deletes the resource. This will actually simply log that the resource has
83: * been deleted.
84: */
85: void delete() throws IOException;
86:
87: /**
88: * Returns true if the resource currently exists.
89: */
90: boolean exists();
91:
92: }
|