01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.memorydatastore.message;
05:
06: import com.tc.io.TCByteBufferInput;
07: import com.tc.io.TCByteBufferOutput;
08: import com.tc.io.TCSerializable;
09:
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(TCByteBufferInput serialInput)
41: throws IOException {
42: int length = serialInput.readInt();
43: this .key = new byte[length];
44: serialInput.read(this .key);
45:
46: length = serialInput.readInt();
47: this .value = new byte[length];
48: serialInput.read(this.value);
49:
50: return this;
51: }
52: }
|