public MsgPackWriter writeMapHeader(int size) { ensurePositive(size); if (size < (1 << 4)) { buffer.putByte(offset, (byte) (FIXMAP_PREFIX | size)); ++offset; } else if (size < (1 << 16)) { buffer.putByte(offset, MAP16); ++offset; buffer.putShort(offset, (short) size, MsgPackCodes.BYTE_ORDER); offset += SIZE_OF_SHORT; } else { offset = writeMap32Header(offset, size); } return this; }
public MsgPackWriter writeMapHeader(int size) { ensurePositive(size); if (size < (1 << 4)) { buffer.putByte(offset, (byte) (FIXMAP_PREFIX | size)); ++offset; } else if (size < (1 << 16)) { buffer.putByte(offset, MAP16); ++offset; buffer.putShort(offset, (short) size, MsgPackCodes.BYTE_ORDER); offset += SIZE_OF_SHORT; } else { offset = writeMap32Header(offset, size); } return this; }
public MsgPackWriter writeArrayHeader(int size) { ensurePositive(size); if (size < (1 << 4)) { buffer.putByte(offset, (byte) (FIXARRAY_PREFIX | size)); ++offset; } else if (size < (1 << 16)) { buffer.putByte(offset, ARRAY16); ++offset; buffer.putShort(offset, (short) size, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, ARRAY32); ++offset; buffer.putInt(offset, size, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
public MsgPackWriter writeArrayHeader(int size) { ensurePositive(size); if (size < (1 << 4)) { buffer.putByte(offset, (byte) (FIXARRAY_PREFIX | size)); ++offset; } else if (size < (1 << 16)) { buffer.putByte(offset, ARRAY16); ++offset; buffer.putShort(offset, (short) size, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, ARRAY32); ++offset; buffer.putInt(offset, size, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
public int readMapHeader() { final byte headerByte = buffer.getByte(offset); ++offset; final int mapSize; if (isFixedMap(headerByte)) { mapSize = headerByte & (byte) 0x0F; } else { switch (headerByte) { case MAP16: mapSize = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case MAP32: mapSize = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("map", headerByte); } } return mapSize; }
public int readArrayHeader() { final byte headerByte = buffer.getByte(offset); ++offset; final int mapSize; if (isFixedArray(headerByte)) { mapSize = headerByte & (byte) 0x0F; } else { switch (headerByte) { case ARRAY16: mapSize = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case ARRAY32: mapSize = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("array", headerByte); } } return mapSize; }
public int readArrayHeader() { final byte headerByte = buffer.getByte(offset); ++offset; final int mapSize; if (isFixedArray(headerByte)) { mapSize = headerByte & (byte) 0x0F; } else { switch (headerByte) { case ARRAY16: mapSize = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case ARRAY32: mapSize = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("array", headerByte); } } return mapSize; }
public int readBinaryLength() { final int length; final byte headerByte = buffer.getByte(offset); ++offset; switch (headerByte) { case BIN8: length = buffer.getByte(offset) & 0xff; ++offset; break; case BIN16: length = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case BIN32: length = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("binary", headerByte); } return length; }
public int readBinaryLength() { final int length; final byte headerByte = buffer.getByte(offset); ++offset; switch (headerByte) { case BIN8: length = buffer.getByte(offset) & 0xff; ++offset; break; case BIN16: length = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case BIN32: length = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("binary", headerByte); } return length; }
public int readMapHeader() { final byte headerByte = buffer.getByte(offset); ++offset; final int mapSize; if (isFixedMap(headerByte)) { mapSize = headerByte & (byte) 0x0F; } else { switch (headerByte) { case MAP16: mapSize = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case MAP32: mapSize = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("map", headerByte); } } return mapSize; }
public MsgPackWriter writeBinaryHeader(int len) { ensurePositive(len); if (len < (1 << 8)) { buffer.putByte(offset, BIN8); ++offset; buffer.putByte(offset, (byte) len); ++offset; } else if (len < (1 << 16)) { buffer.putByte(offset, BIN16); ++offset; buffer.putShort(offset, (short) len, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, BIN32); ++offset; buffer.putInt(offset, len, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
public MsgPackWriter writeBinaryHeader(int len) { ensurePositive(len); if (len < (1 << 8)) { buffer.putByte(offset, BIN8); ++offset; buffer.putByte(offset, (byte) len); ++offset; } else if (len < (1 << 16)) { buffer.putByte(offset, BIN16); ++offset; buffer.putShort(offset, (short) len, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, BIN32); ++offset; buffer.putInt(offset, len, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
public int readStringLength() { final byte headerByte = buffer.getByte(offset); ++offset; final int stringLength; if (isFixStr(headerByte)) { stringLength = headerByte & (byte) 0x1F; } else { switch (headerByte) { case STR8: stringLength = buffer.getByte(offset) & 0xff; ++offset; break; case STR16: stringLength = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case STR32: stringLength = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("string", headerByte); } } return stringLength; }
public int readStringLength() { final byte headerByte = buffer.getByte(offset); ++offset; final int stringLength; if (isFixStr(headerByte)) { stringLength = headerByte & (byte) 0x1F; } else { switch (headerByte) { case STR8: stringLength = buffer.getByte(offset) & 0xff; ++offset; break; case STR16: stringLength = buffer.getShort(offset, BYTE_ORDER) & 0xffff; offset += SIZE_OF_SHORT; break; case STR32: stringLength = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += SIZE_OF_INT; break; default: throw exceptionOnUnknownHeader("string", headerByte); } } return stringLength; }
public MsgPackWriter writeStringHeader(int len) { ensurePositive(len); if (len < (1 << 5)) { buffer.putByte(offset, (byte) (FIXSTR_PREFIX | len)); ++offset; } else if (len < (1 << 8)) { buffer.putByte(offset, STR8); ++offset; buffer.putByte(offset, (byte) len); ++offset; } else if (len < (1 << 16)) { buffer.putByte(offset, STR16); ++offset; buffer.putShort(offset, (short) len, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, STR32); ++offset; buffer.putInt(offset, len, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
public MsgPackWriter writeStringHeader(int len) { ensurePositive(len); if (len < (1 << 5)) { buffer.putByte(offset, (byte) (FIXSTR_PREFIX | len)); ++offset; } else if (len < (1 << 8)) { buffer.putByte(offset, STR8); ++offset; buffer.putByte(offset, (byte) len); ++offset; } else if (len < (1 << 16)) { buffer.putByte(offset, STR16); ++offset; buffer.putShort(offset, (short) len, BYTE_ORDER); offset += SIZE_OF_SHORT; } else { buffer.putByte(offset, STR32); ++offset; buffer.putInt(offset, len, BYTE_ORDER); offset += SIZE_OF_INT; } return this; }
case BIN32: case STR32: final int length = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += 4 + length; break;
case BIN32: case STR32: final int length = (int) ensurePositive(buffer.getInt(offset, BYTE_ORDER)); offset += 4 + length; break;