3 * KeyValue entry for Slot.
4 * @author Brian Demsky <bdemsky@uci.edu>
8 class KeyValue { /*extends Entry */
10 private IoTString value;
12 public KeyValue(IoTString _key, IoTString _value) {
17 public IoTString getKey() {
21 public IoTString getValue() {
25 static KeyValue decode(ByteBuffer bb) {
26 int keylength = bb.getInt();
27 int valuelength = bb.getInt();
28 char[] key = new char[keylength];
31 if (valuelength != 0) {
32 char[] value = new char[valuelength];
34 return new KeyValue(IoTString.shallow(key), IoTString.shallow(value));
37 return new KeyValue(IoTString.shallow(key), NULL);
40 public void encode(ByteBuffer bb) {
41 bb.putInt(key.length());
44 bb.putInt(value.length());
49 bb.put(key.internalBytes());
52 bb.put(value.internalBytes());
56 public int getSize() {
58 return 2 * sizeof(int32_t) + key.length() + value.length();
61 return 2 * sizeof(int32_t) + key.length();
64 public String toString() {
68 return value.toString();
71 public KeyValue getCopy() {
72 return new KeyValue(key, value);