Code example for ByteBuffer

Methods: duplicate, limit, position, remaining

0
        return new NodeId(id);
    } 
 
    public static NodeId wrap(ByteBuffer bb, int offset)
    { 
        ByteBuffer dup = bb.duplicate();
        dup.position(offset);
        dup.limit(dup.position() + LENGTH);
        return wrap(dup);
    } 
 
    private NodeId(ByteBuffer id)
    { 
        if (id.remaining() != LENGTH)
            throw new IllegalArgumentException("A NodeId representation is exactly " + LENGTH + " bytes");
 
        this.id = id;
    } 
 
    public static NodeId generate() 
    {