KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jofti > btree > KeyValueObject


1 package com.jofti.btree;
2
3 import java.io.Externalizable JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.ObjectInput JavaDoc;
6 import java.io.ObjectOutput JavaDoc;
7 import java.util.Map JavaDoc;
8
9 /**
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 Externalizable JavaDoc{
17
18
19     private static final long serialVersionUID = -4721473999348297006L;
20     protected Map JavaDoc attributes;
21     
22     public KeyValueObject() {
23         }
24     
25     public KeyValueObject(int dimension, Comparable JavaDoc value, Map JavaDoc attributes) {
26        super(dimension,value);
27        this.attributes = attributes;
28     }
29
30     public Map JavaDoc getAttributes() {
31         return attributes;
32     }
33
34     public void setAttributes(Map JavaDoc attributes) {
35         this.attributes = attributes;
36     }
37     
38      public String JavaDoc toString(){
39             StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
40             buf.append("dimension:" + dimension);
41             buf.append(", real Value:" + realValue);
42             buf.append(", dimension:" + attributes);
43             return buf.toString();
44         }
45      
46      public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
47             dimension = in.readInt();
48             realValue = (Comparable JavaDoc)in.readObject();
49             attributes = (Map JavaDoc)in.readObject();
50             
51         }
52
53         public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
54             out.writeInt(dimension);
55             out.writeObject(realValue);
56             out.writeObject(attributes);
57             
58         }
59 }
60
Popular Tags