1 4 package com.tc.memorydatastore.message; 5 6 import com.tc.io.TCByteBufferInputStream; 7 import com.tc.io.TCByteBufferOutput; 8 import com.tc.io.TCSerializable; 9 10 import java.io.IOException ; 11 12 public class TCByteArrayKeyValuePair implements TCSerializable { 13 private byte[] key; 14 private byte[] value; 15 16 public TCByteArrayKeyValuePair() { 17 super(); 18 } 19 20 public TCByteArrayKeyValuePair(byte[] key, byte[] value) { 21 this.key = key; 22 this.value = value; 23 } 24 25 public byte[] getKey() { 26 return key; 27 } 28 29 public byte[] getValue() { 30 return value; 31 } 32 33 public void serializeTo(TCByteBufferOutput serialOutput) { 34 serialOutput.writeInt(key.length); 35 serialOutput.write(key); 36 serialOutput.writeInt(value.length); 37 serialOutput.write(value); 38 } 39 40 public Object deserializeFrom(TCByteBufferInputStream serialInput) throws IOException { 41 int length = serialInput.readInt(); 42 this.key = new byte[length]; 43 serialInput.read(this.key); 44 45 length = serialInput.readInt(); 46 this.value = new byte[length]; 47 serialInput.read(this.value); 48 49 return this; 50 } 51 } | Popular Tags |