Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.lib / src / main / java / org / gvsig / fmap / dal / store / simplereader / virtualrows / RecordsFile.java @ 47655

History | View | Annotate | Download (3.41 KB)

1
package org.gvsig.fmap.dal.store.simplereader.virtualrows;
2

    
3
import java.io.Closeable;
4
import java.io.File;
5
import java.io.IOException;
6
import java.io.RandomAccessFile;
7
import java.nio.ByteBuffer;
8
import java.sql.Timestamp;
9
import java.util.List;
10
import org.gvsig.fmap.dal.store.simplereader.virtualrows.RecordsFile.Record;
11
import org.gvsig.tools.util.GetItem;
12
import org.gvsig.tools.util.GetItem64;
13
import org.gvsig.tools.util.Size;
14
import org.gvsig.tools.util.Size64;
15

    
16
/**
17
 *
18
 * @author gvSIG Team
19
 */
20
public interface RecordsFile extends List<Record>, Size, Size64, GetItem<Record>, GetItem64<Record>, Closeable {
21
    
22
    public static final byte TYPE_BYTE = 0;
23
    public static final byte TYPE_SHORT = 1;
24
    public static final byte TYPE_INTEGER = 2;
25
    public static final byte TYPE_LONG = 3;
26
    public static final byte TYPE_DOUBLE = 4;
27
    public static final byte TYPE_TIMESTAMP = 5;
28
    public static final byte TYPE_STRING = 6;
29
    public static final byte TYPE_BYTES = 7;
30

    
31
    public interface Record {
32
        public RecordType getType();
33
        public byte[] getBytes();
34
        public void setBytes(byte[] bytes);
35
        public ByteBuffer getBuffer();
36
        
37
        public int getByte(int n);
38
        public int getShort(int n);
39
        public int getInt(int n);
40
        public long getLong(int n);
41
        public double getDouble(int n);
42
        public Timestamp getTimestamp(int n);
43
        public String getString(int n);        
44
        public byte[] getBytes(int n);        
45

    
46
        public void setByte(int n, byte v);
47
        public void setShort(int n, short v);
48
        public void setInt(int n, int v);
49
        public void setLong(int n, long v);
50
        public void setDouble(int n, double v);
51
        public void setTimestamp(int n, Timestamp v);
52
        public void setString(int n, String v);        
53
        public void setBytes(int n, byte[] v);        
54
    }
55
    
56
    public interface RecordType {
57
        public int getSize();
58
        public int getFieldCount();
59
        public int getFieldType(int n);
60
        public int getFieldSize(int n);
61
        public int getFieldOffset(int n);
62
        public Record createRecord();
63
        public byte[] toBytes();
64
        
65
        public static RecordType from(byte[] bytes) {
66
            return RecordsFileImpl.RecordTypeImpl.from(bytes);
67
        }
68
        
69
        public static RecordType from(ByteBuffer bytes) {
70
            return RecordsFileImpl.RecordTypeImpl.from(bytes);
71
        }
72
    }
73
    
74
    public interface RecordTypeBuilder {
75
        public RecordTypeBuilder addbyte();
76
        public RecordTypeBuilder addShort();
77
        public RecordTypeBuilder addInteger();
78
        public RecordTypeBuilder addLong();
79
        public RecordTypeBuilder addDouble();
80
        public RecordTypeBuilder addTimestamp();
81
        public RecordTypeBuilder addString(int size);
82
        public RecordTypeBuilder addBytes(int size);
83
        public RecordType build();
84
        
85
        public static RecordTypeBuilder recordTypeBuilder() {
86
            return RecordsFileImpl.RecordTypeBuilderImpl.recordTypeBuilder();
87
        }
88
    }
89
    
90
    
91
    public RecordType getRecordType();
92

    
93
    public void open(File f) throws IOException;
94
    
95
    public void open(RandomAccessFile raf) throws IOException;
96

    
97
    public void create(File f, RecordType recordType) throws IOException;
98
    
99
    public void create(RandomAccessFile raf, RecordType recordType) throws IOException ;
100
    
101
    public boolean isOpen();
102
      
103
    
104
}