Java Utililty Methods ByteBuffer to Short Array

List of utility methods to do ByteBuffer to Short Array

  1. HOME
  2. Java
  3. B
  4. 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;
int getShort(ByteBuffer bb)
Get an unsigned short from the byte buffer.
return (bb.getShort() & 0xffff);
short getShort(ByteBuffer buffer)
get Short
return getShort(buffer, DEFAULT_BYTE_ORDER);
int getShort(ByteBuffer byteBuffer)
get Short
return (byteBuffer.getShort() & SHORT_PADDING);
short getShortB(ByteBuffer bb, int bi)
get Short B
return makeShort(bb.get(bi), bb.get(bi + 1));
short getShortBE(ByteBuffer b, int start, int end)
get Short BE
return (short) getIntBE(b, start, end);
short getShortBE(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);
int getShortLength(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;
int getShortLength(ByteBuffer bb, int position)
get Short Length
int length = (bb.get(position) & 0xFF) << 8;
return length | (bb.get(position + 1) & 0xFF);
short getShortNumeric(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));


AltStyle によって変換されたページ (->オリジナル) /