KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > memorydatastore > message > TCByteArrayKeyValuePair


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc;
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 JavaDoc deserializeFrom(TCByteBufferInputStream serialInput) throws IOException JavaDoc {
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