List of utility methods to do ByteBuffer Decode
Double | decodeDouble(ByteBuffer bb) decode Double return bb.getDouble();
|
int | decodeInt(ByteBuffer buffer, int start) decode Int return buffer.getInt(start);
|
String | decodeIO(String encoding, ByteBuffer bbuf) decode IO if (bbuf.hasArray()) return new String(bbuf.array(), encoding); throw new IllegalArgumentException(); |
int | decodeLength(ByteBuffer buf) Decode octets and extract the length information from a DER-encoded message. if (buf == null || buf.remaining() == 0) { throw new IllegalArgumentException("Null or empty buffer"); int len = 0; byte first = buf.get(); if (first >> 7 == 0) { len = first & 0x7f; } else { ... |
long | decodeLong(ByteBuffer buffer, int start) decode Long return buffer.getLong(start);
|
String | decodeNIO(String encoding, ByteBuffer bbuf) decode NIO Charset cset = Charset.forName(encoding); CharsetDecoder csetdecoder = cset.newDecoder(); csetdecoder.onMalformedInput(CodingErrorAction.REPLACE); csetdecoder.onUnmappableCharacter(CodingErrorAction.REPLACE); try { CharBuffer cbuf = csetdecoder.decode(bbuf); return cbuf.toString(); } catch (CharacterCodingException e) { ... |
long | decodeNumber(byte firstByte, ByteBuffer buffer) decode Number boolean isNeg = testBit(firstByte, OB_INT_SIGN_BIT_POS); byte lenOrValue = (byte) (firstByte & OB_INT_VALUE_MASK); if (lenOrValue <= OB_MAX_INT_1B) { return isNeg ? -lenOrValue : lenOrValue; } else { long value = 0; long len = lenOrValue - OB_MAX_INT_1B; if (len == 5 || len == 7) { ... |
int | decodeStoredBits(ByteBuffer bb) decode Stored Bits return bb.getInt();
|
List | decodeStringSequence(ByteBuffer bb) decode String Sequence List<String> names = new ArrayList<String>(); bb.mark(); while (bb.hasRemaining()) { if (bb.get() == 0) { ByteBuffer nameBuffer = (ByteBuffer) bb.duplicate().limit(bb.position() - 1).reset(); if (nameBuffer.hasRemaining()) { names.add(decodeString(nameBuffer)); bb.mark(); return names; |
CharBuffer | decodeThrowing(Charset charset, ByteBuffer in) Decodes in using charset , ensuring that a CharacterCodingException is thrown on invalid input. return charset.newDecoder().onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT).decode(in);
|