1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.magicproject.token;
22
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26
27 /***
28 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
29 */
30 public enum IdMessageBox {
31
32 /***
33 */
34 ok,
35 /***
36 */
37 confirm,
38
39 /***
40 */
41 yesno;
42
43 /***
44 * Wrtite this enum to the given outputstream.
45 *
46 * @param out
47 * the stream ths enum would be written.
48 * @throws IOException
49 * If some other I/O error occurs
50 */
51 public void serialize(OutputStream out) throws IOException {
52 out.write(ordinal());
53 }
54
55 /***
56 * Read and return the enum from the given inputstream.
57 *
58 * @param input
59 * the stream containing the enum to read.
60 * @return the enum from the given inputstream.
61 * @throws IOException
62 * If some other I/O error occurs
63 */
64 public static IdMessageBox deserialize(InputStream input) throws IOException {
65 return values()[input.read()];
66 }
67 }