KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > store > StoreDataAccessor


1 /**
2  * com.mckoi.store.StoreDataAccessor 10 Jun 2003
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * 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  */

24
25 package com.mckoi.store;
26
27 import java.io.IOException JavaDoc;
28
29 /**
30  * An interface for low level store data access methods. This is used to
31  * implement a variety of ways of accessing data from some resource, such as
32  * a file in a filesystem. For example, we might use this to access a file
33  * using the NIO API, or through the IO API. Alternatively we may use it to
34  * implement a scattering store that includes data across multiple files in the
35  * filesystem.
36  *
37  * @author Tobias Downer
38  */

39
40 interface StoreDataAccessor {
41
42   /**
43    * Returns true if the resource exists.
44    */

45   boolean exists();
46   
47   /**
48    * Deletes the data area resource. Returns true if the delete was successful.
49    */

50   boolean delete();
51
52   /**
53    * Opens the underlying data area representation. If the resource doesn't
54    * exist then it is created and the size is set to 0.
55    */

56   void open(boolean read_only) throws IOException JavaDoc;
57   
58   /**
59    * Closes the underlying data area representation.
60    */

61   void close() throws IOException JavaDoc;
62
63
64   /**
65    * Reads a block of data from the underlying data area at the given position
66    * into the byte array at the given offset.
67    */

68   void read(long position, byte[] buf, int off, int len) throws IOException JavaDoc;
69
70   /**
71    * Writes a block of data to the underlying data area from the byte array at
72    * the given offset.
73    */

74   void write(long position, byte[] buf, int off, int len) throws IOException JavaDoc;
75
76   /**
77    * Sets the size of the underlying data area to the given size. If the size
78    * of the data area is increased, the content between the old size and the
79    * new size is implementation defined.
80    */

81   void setSize(long new_size) throws IOException JavaDoc;
82
83   /**
84    * Returns the current size of the underlying data area.
85    */

86   long getSize() throws IOException JavaDoc;
87   
88   /**
89    * Synchronizes the data area by forcing any data out of the OS buffers onto
90    * the disk.
91    */

92   void synch() throws IOException JavaDoc;
93
94
95 }
96
97
Popular Tags