01: package de.regnis.q.sequence.line;
02:
03: import java.io.*;
04:
05: /**
06: * @author Marc Strapetz
07: */
08: public final class QSequenceLineRAFileData implements
09: QSequenceLineRAData {
10:
11: // Fields =================================================================
12:
13: private final RandomAccessFile randomAccessFile;
14:
15: private QSequenceLineRAFileDataStream stream;
16:
17: // Setup ==================================================================
18:
19: public QSequenceLineRAFileData(RandomAccessFile randomAccessFile) {
20: this .randomAccessFile = randomAccessFile;
21: }
22:
23: // Implemented ============================================================
24:
25: public long length() throws IOException {
26: return randomAccessFile.length();
27: }
28:
29: public void get(byte[] bytes, long offset, long length)
30: throws IOException {
31: randomAccessFile.seek(offset);
32: randomAccessFile.read(bytes, 0, (int) length);
33: }
34:
35: public InputStream read(long offset, long length) {
36: if (stream != null) {
37: stream.reset(offset, (int) length);
38: } else {
39: stream = new QSequenceLineRAFileDataStream(
40: randomAccessFile, offset, (int) length);
41: }
42: return stream;
43: }
44: }
|