From: joelbandi Date: Wed, 3 Aug 2016 00:07:38 +0000 (-0700) Subject: Keyvalue.js X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=commitdiff_plain;h=1a72099970502a63bd06d1b6870f3b40bd580a33 Keyvalue.js --- diff --git a/src/js/iotjs/orig/keyvalue.js b/src/js/iotjs/orig/keyvalue.js new file mode 100644 index 0000000..375b29d --- /dev/null +++ b/src/js/iotjs/orig/keyvalue.js @@ -0,0 +1,65 @@ +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