KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > storage > gammaStore > Storage


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@, Leo Mekenkamp. All rights reserved.
6
//
7
// $Id: Storage.java,v 1.1 2004/01/02 09:24:38 leomekenkamp Exp $
8

9 package org.ozoneDB.core.storage.gammaStore;
10
11 import java.io.IOException JavaDoc;
12
13 /**
14  * <p>A meganism for storing and retrieving data to a permament back-end.
15  * While implementing classes are typically backed by file-based structures,
16  * this is in no way a _must_. Inheriting classes must must simply support
17  * read/write actions from a 'random' location.</p>
18  * <p>As the <code>IndexManager</code> also uses instances of this type to
19  * write index nodes as a whole (no seek needed) there are also implementations
20  * that not support seek functionality.</p>
21  *
22  * @author <a HREF="mailto:ozoneATmekenkampD0Tcom">Leo Mekenkamp (mind the anti-sp@m)</a>
23  */

24 public interface Storage {
25     
26     /**
27      * <p>Introduced because some implementing classes (based on <code>FileOutputStream</code>
28      * and <code>FileInputStream</code> for instance) might not support seek
29      * operations. They may throw an <code>UnsupportedOperationException</code>
30      * here, but still support writing and reading.</p>
31      * <p>Implementations of this interface are used in 2 different ways: the
32      * <code>IndexManager</code> does not perform any seek actions, and thus the
33      * storage implementation it uses can include stream based ones; the
34      * <code>ClusterManager</code> however does perform seek actions and thus
35      * cannot have a storage implementation with streams in it.</p>
36      *
37      * @throws UnsupportedOperationException
38      */

39     public void seek(long pos) throws IOException JavaDoc;
40     
41     /**
42      * Write <code>lenght</code> bytes from <code>b</code>, starting at <code>
43      * offset</code>.
44      */

45     public void write(byte[] b, int offset, int length) throws IOException JavaDoc;
46
47     public void write(byte[] b) throws IOException JavaDoc;
48
49     public void writeLong(long value) throws IOException JavaDoc;
50     
51     public void writeInt(int value) throws IOException JavaDoc;
52     
53     /**
54      * Read <code>lenght</code> bytes from <code>b</code>, starting at <code>
55      * offset</code>.
56      */

57     public void readFully(byte[] b, int offset, int length) throws IOException JavaDoc;
58
59     public void readFully(byte[] b) throws IOException JavaDoc;
60     
61     public long readLong() throws IOException JavaDoc;
62
63     public int readInt() throws IOException JavaDoc;
64
65     /**
66      * Sets the maximum length.
67      */

68     public void setLength(long length) throws IOException JavaDoc;
69     
70     public void close() throws IOException JavaDoc;
71     
72     public long length() throws IOException JavaDoc;
73
74 }
75
Popular Tags