List of utility methods to do ByteBuffer Get
int | getTruncatedInt(ByteBuffer bytes, int numBytes) get Truncated Int if (numBytes <= 0) throw new IOException("too few bytes specified for truncated int value!"); else if (numBytes >= 4) { if (bytes.remaining() < 4) throw new IOException("too few bytes specified for truncated int value!"); return bytes.getInt(); if (bytes.remaining() < numBytes) ... |
int | getTsStartSyncByte(ByteBuffer packet, boolean synced) Get the index of the sync byte of the first detected start packet. int returnByte = -1; int firstSyncByte = packet.position(); if (!synced) { firstSyncByte = getTsSyncByte(packet); if (firstSyncByte < 0) { return returnByte; int limit = packet.remaining(); for (int i = firstSyncByte; i < limit; i += MTS_PACKET_LEN) { if (i + 1 > packet.remaining()) { break; int tsPayloadUnitStartIndicator = packet.get(i + 1) & 0x40; if (tsPayloadUnitStartIndicator != 0) { returnByte = i; break; return returnByte; |
int | getTsSyncByte(ByteBuffer packet) Returns the index of the first a TS sync byte. int returnValue = -1; if (packet.remaining() < 752) { return returnValue; int limit = packet.limit(); for (int i = packet.position(); i < limit; i++) { if (packet.get(i) == MTS_SYNC_BYTE) { if (i + (MTS_PACKET_LEN * 2) < limit) { ... |
int | getUByte(ByteBuffer b) get U Byte return unsign(b.get());
|
int | getUleb128(ByteBuffer buffer) get Uleb int ret = 0; int c; do { ret <<= 7; c = buffer.get(); ret |= c & 0x7f; } while ((c & 0x80) > 0); return ret; ... |
byte[] | getUsedBytes(ByteBuffer bb) get Used Bytes byte[] data = bb.array(); byte[] remain = new byte[bb.position()]; System.arraycopy(data, 0, remain, 0, remain.length); return remain; |
String | getUTF8FromByteBuffer(ByteBuffer bb) get UTF From Byte Buffer Charset charset = Charset.forName("UTF-8"); CharsetDecoder decoder = charset.newDecoder(); try { return decoder.decode(bb).toString(); } catch (Exception e) { e.printStackTrace(); return null; ... |
UUID | getUUID(ByteBuffer bytes) get UUID if (bytes.remaining() < 16) throw new IOException("too few bytes specified for UUID value!"); long msb = bytes.getLong(); long lsb = bytes.getLong(); UUID value = new UUID(msb, lsb); return value; |
double | getVariance(ByteBuffer simulationResults) get Variance double mean = getMean(simulationResults); double temp = 0.0; int size = simulationResults.capacity() / 8; simulationResults.rewind(); for (int i = 0; i < size; i++) { double f = simulationResults.getDouble(); temp += (mean - f) * (mean - f); return (temp / size); |
int | getVInt(ByteBuffer bf, int index) get V Int byte b = bf.get(index++); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = bf.get(index++); i |= (b & 0x7F) << shift; return i; |