--- /dev/null
+class KeyValue extends Entry{
+ constructor(slot,_key,_value){
+ if(!(slot instanceof Slot && _key instanceof IoTString && _value instanceof IoTString)){
+ throw new Error('Argument error ');
+ }
+ super(slot);
+ this.key = _key;
+ this.value = _value;
+ }
+ getKey(){
+ return this.key;
+ }
+ getValue(){
+ return this.value;
+ }
+ decode(slot,bb){
+ if(!(slot instanceof Slot && bb instanceof ByteBuffer)){
+ throw new Error('Argument error');
+ }
+ var keylength = bb.getByte();
+ var valuelength = bb.getByte();
+ var key = new Uint8Array(keylength);
+ var value = new Uint8Array(valuelength);
+ var keystring = '';
+ for(var i =0 ;i<keylength ; i++){
+ keystring += bb.readByte();
+ }
+ var valuestring= '';
+ for(var j =0 ;j<keylength ; j++){
+ valuestring += bb.readByte();
+ }
+ for(var k = 0; k< keystring.length; k++){
+ key[k] = keystring.charCodeAt(k);
+ }
+ for(var l = 0; l< valuestring.length; l++){
+ value[l] = valuestring.charCodeAt(l);
+ }
+ return new KeyValue(slot,IoTString.shallow(key),IoTString.shallow(value));
+ }
+
+ encode(bb){
+ if(!(bb instanceof ByteBuffer)){
+ throw new Error('argument error');
+ }
+ bb.writeByte(Entry.TypeKeyValue);
+ bb.writeByte(this.key.length());
+ bb.writeByte(this.value.length());
+ bb.concat(this.key.internalBytes());
+ bb.concat(this.value.internalBytes());
+ }
+ getSize(){
+ return 2*4+this.jey.length()+this.value.length()+1;
+ }
+
+ getType(){
+ return Entry.TypeKeyValue;
+ }
+
+ toString(){
+ return this.value.toString();
+ }
+ getCopy(s){
+ return new KeyValue(s,this.key,this.value);
+ }
+}