-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStorage.java
108 lines (75 loc) · 3.79 KB
/
Storage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.util.ArrayList;
import javafx.util.Pair;
// Abstract Layer for Accessing Physical Storage of Data
//
public abstract class Storage {
// Root for Storage: Hardcoded for demo purposes only (can be further abstracted)
protected final String storageRoot = "/tmp/";
protected String collection = null; // name of the collection (file) in storage
public Storage( String collection ) throws IllegalArgumentException
{
if ( null == collection )
throw new IllegalArgumentException( "collection is null" );
this.collection = collection;
}
// Method for opening (connecting) to storage
public abstract void Open() throws StorageException;
// Method for closing (disconnecting) from storage
public abstract void Close() throws StorageException;
// Method to seek to the begin of the storage
public abstract void Begin() throws StorageException;
// Method to seek to the end of the storage
public abstract void End() throws StorageException;
// Method to return the current location in storage
public abstract long Pos() throws StorageException;
// Method to move to a location in storage
public abstract void Move( long pos ) throws StorageException;
// Method to check for at end of file in storage
public abstract boolean Eof() throws StorageException;
// Method to write a padded string to the storage
public abstract void Write( String value, int length ) throws StorageException;
// Method to write a string to the storage
public abstract void Write( String value ) throws StorageException;
// Method to write a byte to the storage
public abstract void Write( byte value ) throws StorageException;
// Method to write a short to the storage
public abstract void Write( Short value ) throws StorageException;
// Method to write an integer to the storage
public abstract void Write( Integer value ) throws StorageException;
// Method to write a long to the storage
public abstract void Write( Long value ) throws StorageException;
// Method to write a float to the storage
public abstract void Write( Float value ) throws StorageException;
// Method to write a double to the storage
public abstract void Write( Double value ) throws StorageException;
// Method to write a boolean to the storage
public abstract void Write( Boolean value ) throws StorageException;
// Method to write a line to storage
public abstract void WriteLine( String value ) throws StorageException;
// Method to Read a String from storage
public abstract String Read( int length ) throws StorageException;
// Method to Read a byte from storage
public abstract byte ReadByte() throws StorageException;
// Method to Read a short from storage
public abstract Short ReadShort() throws StorageException;
// Method to Read an Integer from storage
public abstract Integer ReadInt() throws StorageException;
// Method to Read a Long from storage
public abstract Long ReadLong() throws StorageException;
// Method to Read a float from storage
public abstract float ReadFloat() throws StorageException;
// Method to Read a double from storage
public abstract double ReadDouble() throws StorageException;
// Method to Read a boolean from storage
public abstract Boolean ReadBoolean() throws StorageException;
// Method to Read a line from storage
public abstract String ReadLine() throws StorageException;
// Method to Write out index to storage
public abstract void Write( Index index ) throws StorageException;
// Method to Read in index from storage
public abstract ArrayList<long[]> ReadIndex( Index index ) throws StorageException;
// Method to Write out schema to storage
public abstract void Write( Schema schema ) throws StorageException;
// Method to Read in schema from storage
public abstract ArrayList<Pair<String,String>> ReadSchema() throws StorageException;
}