1 package org.metricshub.jawk.intermediate;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.io.IOException;
26 import java.io.InvalidClassException;
27 import java.io.ObjectInputStream;
28 import java.io.ObjectOutputStream;
29 import java.io.Serializable;
30
31 class VersionManager implements Serializable {
32
33 private static final long serialVersionUID = -2015316238483923915L;
34
35 private static final int CLASS_VERSION = 2;
36
37 private int instanceVersion = CLASS_VERSION;
38
39 private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
40 instanceVersion = ois.readInt();
41 if (instanceVersion != CLASS_VERSION) {
42 throw new InvalidClassException(
43 "Invalid intermeidate file format (instance version " + instanceVersion
44 + " != class version " + CLASS_VERSION + ")");
45 }
46 }
47
48 private void writeObject(ObjectOutputStream oos) throws IOException {
49 oos.writeInt(instanceVersion);
50 }
51
52 @Override
53 public String toString() {
54 return "intermediate file format version = " + instanceVersion;
55 }
56 }