Code example for ByteBuffer

Methods: duplicate, get, remaining

0
  @Override 
  public BigInteger fromByteBuffer(ByteBuffer byteBuffer) {
    if (byteBuffer == null) {
      return null; 
    } 
    int length = byteBuffer.remaining();
    byte[] bytes = new byte[length];
    byteBuffer.duplicate().get(bytes);
    return new BigInteger(bytes);
  } 
 
  @Override 
  public ByteBuffer toByteBuffer(BigInteger obj) {
    if (obj == null) {
      return null; 
    } 
    return ByteBuffer.wrap(obj.toByteArray());
  } 
 
  @Override 
  public ComparatorType getComparatorType() {