3 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
11 var KeyValue = function (_Entry) {
12 _inherits(KeyValue, _Entry);
14 function KeyValue(slot, _key, _value) {
15 _classCallCheck(this, KeyValue);
17 if (!(slot instanceof Slot && _key instanceof IoTString && _value instanceof IoTString)) {
18 throw new Error('Argument error ');
21 var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(KeyValue).call(this, slot));
28 _createClass(KeyValue, [{
30 value: function getKey() {
35 value: function getValue() {
40 value: function decode(slot, bb) {
41 if (!(slot instanceof Slot && bb instanceof ByteBuffer)) {
42 throw new Error('Argument error');
44 var keylength = bb.getByte();
45 var valuelength = bb.getByte();
46 var key = new Uint8Array(keylength);
47 var value = new Uint8Array(valuelength);
49 for (var i = 0; i < keylength; i++) {
50 keystring += bb.readByte();
53 for (var j = 0; j < keylength; j++) {
54 valuestring += bb.readByte();
56 for (var k = 0; k < keystring.length; k++) {
57 key[k] = keystring.charCodeAt(k);
59 for (var l = 0; l < valuestring.length; l++) {
60 value[l] = valuestring.charCodeAt(l);
62 return new KeyValue(slot, IoTString.shallow(key), IoTString.shallow(value));
66 value: function encode(bb) {
67 if (!(bb instanceof ByteBuffer)) {
68 throw new Error('argument error');
70 bb.writeByte(Entry.TypeKeyValue);
71 bb.writeByte(this.key.length());
72 bb.writeByte(this.value.length());
73 bb.concat(this.key.internalBytes());
74 bb.concat(this.value.internalBytes());
78 value: function getSize() {
79 return 2 * 4 + this.jey.length() + this.value.length() + 1;
83 value: function getType() {
84 return Entry.TypeKeyValue;
88 value: function toString() {
89 return this.value.toString();
93 value: function getCopy(s) {
94 return new KeyValue(s, this.key, this.value);