01: package com.jofti.btree;
02:
03: import java.io.Externalizable;
04: import java.io.IOException;
05: import java.io.ObjectInput;
06: import java.io.ObjectOutput;
07: import java.util.Map;
08:
09: /**
10: * Represents a valueObject that stores a key in the cache. The definition also includes a Map of the attributes
11: * the object has in order to be able to identify which attributes an object has when it is entered into the cache.
12: *
13: * @author steve Woodcock
14: * @version 1.5
15: */
16: final public class KeyValueObject extends ValueObject implements
17: Externalizable {
18:
19: private static final long serialVersionUID = -4721473999348297006L;
20: protected Map attributes;
21:
22: public KeyValueObject() {
23: }
24:
25: public KeyValueObject(int dimension, Comparable value,
26: Map attributes) {
27: super (dimension, value);
28: this .attributes = attributes;
29: }
30:
31: public Map getAttributes() {
32: return attributes;
33: }
34:
35: public void setAttributes(Map attributes) {
36: this .attributes = attributes;
37: }
38:
39: public String toString() {
40: StringBuffer buf = new StringBuffer();
41: buf.append("dimension:" + dimension);
42: buf.append(", real Value:" + realValue);
43: buf.append(", dimension:" + attributes);
44: return buf.toString();
45: }
46:
47: public void readExternal(ObjectInput in) throws IOException,
48: ClassNotFoundException {
49: dimension = in.readInt();
50: realValue = (Comparable) in.readObject();
51: attributes = (Map) in.readObject();
52:
53: }
54:
55: public void writeExternal(ObjectOutput out) throws IOException {
56: out.writeInt(dimension);
57: out.writeObject(realValue);
58: out.writeObject(attributes);
59:
60: }
61: }
|