Java Utililty Methods ByteBuffer to Short Array

List of utility methods to do ByteBuffer to Short Array

Description

The list of methods to do ByteBuffer to Short Array are organized into topic(s).

Method

short[]getShort(ByteBuffer b, int n)
get Short
short s[] = new short[n];
for (int k = 0; k < s.length; k++) {
    s[k] = b.getShort();
return s;
intgetShort(ByteBuffer bb)
Get an unsigned short from the byte buffer.
return (bb.getShort() & 0xffff);
shortgetShort(ByteBuffer buffer)
get Short
return getShort(buffer, DEFAULT_BYTE_ORDER);
intgetShort(ByteBuffer byteBuffer)
get Short
return (byteBuffer.getShort() & SHORT_PADDING);
shortgetShortB(ByteBuffer bb, int bi)
get Short B
return makeShort(bb.get(bi), bb.get(bi + 1));
shortgetShortBE(ByteBuffer b, int start, int end)
get Short BE
return (short) getIntBE(b, start, end);
shortgetShortBE(final ByteBuffer b, final int start, final int end)
Computes a number whereby the 1st byte is the most significant and the last byte is the least significant.
return (short) getIntBE(b, start, end);
intgetShortLength(ByteBuffer bb)
Below functions borrowed from Astyanax until the schema is re-written to be more CQL friendly
int length = (bb.get() & 255) << 8;
return length | bb.get() & 255;
intgetShortLength(ByteBuffer bb, int position)
get Short Length
int length = (bb.get(position) & 0xFF) << 8;
return length | (bb.get(position + 1) & 0xFF);
shortgetShortNumeric(java.nio.ByteBuffer buffer, int len)
get Short Numeric
String s = "";
if (null != buffer && buffer.remaining() >= len) {
    byte[] dest = new byte[len];
    buffer.get(dest, 0, len);
    s = new String(dest);
return (short) (0xFFFF & Integer.parseInt(s));