blob: a1efb1586b2b170cc416691a217b9bebea4c27ca (
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
|
package dslog;
import java.io.IOException;
import java.io.InputStream;
import java.lang.UnsupportedOperationException;
import java.time.Instant;
class DseventsReader {
private final InputStream reader;
public final int version;
public final Instant startTime;
public DseventsReader(InputStream reader) throws IOException {
this.reader = reader;
this.version = Read.i32(reader);
switch (this.version) {
case 0:
throw new UnsupportedOperationException("DSEVENTS version 0 not implemented yet");
case 1:
case 2:
case 3: // 2016-now
this.startTime = Read.LVTimestamp(reader);
break;
default:
throw new UnsupportedOperationException("DSEVENTS file version ("+this.version+") newer than log reader (3)");
}
}
public static class Event {
public Instant time;
public String message;
}
public Event readEvent() throws IOException{
switch (version) {
case 0:
throw new UnsupportedOperationException("DSEVENTS version 0 not implemented yet");
case 1:
case 2:
case 3:
return new Event() {{
time = Read.LVTimestamp(reader);
message = Read.LVString(reader);
}};
default:
throw new UnsupportedOperationException("DSEVENTS file version newer than log reader");
}
}
public void close() throws IOException {
reader.close();
}
}
|