blob: 20dbd95b819a388b5d4d665cb8ad7948685872c7 (
plain)
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
|
package dslog;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
public class PdplogReader implements Versioned, Closeable {
/*============================================================*\
|| Primitive IO ||
\*============================================================*/
private final InputStream reader;
public PdplogReader(InputStream reader) throws IOException {
if (!reader.markSupported()) {
reader = new BufferedInputStream(reader);
}
this.reader = reader;
}
private boolean atEOF() throws IOException {
reader.mark(2);
boolean eof = (reader.read() < 0);
reader.reset();
return eof;
}
/*============================================================* \
|| Parsing ||
\*============================================================*/
private int m_version;
private boolean m_haveVersion = false;
public int version() throws IOException {
if (!m_haveVersion) {
m_version = Read.i32(reader);
m_haveVersion = true;
}
return m_version;
}
public void read() throws IOException {
switch (version()) {
case 0: // ????-????
throw new UnsupportedVersionException("PDPLOG (TODO)", 0);
case 1: // ????-2015
throw new UnsupportedVersionException("PDPLOG (TODO)", 1);
default:
throw new UnsupportedVersionException("PDPLOG", version(), 1);
}
}
public void close() throws IOException {
reader.close();
}
}
|