1 package com.jofti.btree; 2 3 import java.io.Externalizable ; 4 import java.io.IOException ; 5 import java.io.ObjectInput ; 6 import java.io.ObjectOutput ; 7 import java.util.Map ; 8 9 16 final public class KeyValueObject extends ValueObject implements Externalizable { 17 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, Map attributes) { 26 super(dimension,value); 27 this.attributes = attributes; 28 } 29 30 public Map getAttributes() { 31 return attributes; 32 } 33 34 public void setAttributes(Map attributes) { 35 this.attributes = attributes; 36 } 37 38 public String toString(){ 39 StringBuffer buf = new StringBuffer (); 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 in) throws IOException , ClassNotFoundException { 47 dimension = in.readInt(); 48 realValue = (Comparable )in.readObject(); 49 attributes = (Map )in.readObject(); 50 51 } 52 53 public void writeExternal(ObjectOutput out) throws IOException { 54 out.writeInt(dimension); 55 out.writeObject(realValue); 56 out.writeObject(attributes); 57 58 } 59 } 60 | Popular Tags |