01: package Schmortopf.Utility;
02:
03: import java.util.Vector;
04:
05: public class BooleanInteger implements Vectorizable {
06: private static int VersionNumber = 1; // for stored vector representations
07:
08: public boolean booleanValue;
09: public int intValue;
10:
11: /**
12: * Explicit constructor
13: */
14: public BooleanInteger(boolean booleanValue, int intValue) {
15: this .booleanValue = booleanValue;
16: this .intValue = intValue;
17: }
18:
19: /**
20: * Constructor for use, when you want to recreate this
21: * object from a Vector representation.
22: */
23: public BooleanInteger(Vector representation) {
24: this .createFromVectorRepresentation(representation);
25: }
26:
27: /**
28: * returns the VectorRepresentation of the object's datacontent
29: */
30: public Vector getVectorRepresentation() throws Exception {
31: Vector rep = new Vector();
32: rep.addElement(new Integer(VersionNumber));
33: rep.addElement(new Boolean(this .booleanValue));
34: rep.addElement(new Integer(this .intValue));
35: return rep;
36: }
37:
38: /**
39: * sets the object's content to the passed vectorRepresentation.
40: */
41: public void createFromVectorRepresentation(
42: Vector vectorRepresentation) {
43: int versionNumber = ((Integer) vectorRepresentation
44: .elementAt(0)).intValue();
45: // here workarounds can be added, if versionNumber != VersionNumber.
46: this .booleanValue = ((Boolean) vectorRepresentation
47: .elementAt(1)).booleanValue();
48: this .intValue = ((Integer) vectorRepresentation.elementAt(2))
49: .intValue();
50: }
51:
52: }
|