Code example for ByteBuffer

Methods: remaininggetgetShort

0
        return data;
    } 
 
    public LLDPTLV deserialize(ByteBuffer bb) {
        short sscratch;
        sscratch = bb.getShort();
        this.type = (byte) ((sscratch >> 9) & 0x7f);
        this.length = (short) (sscratch & 0x1ff);
        if (this.length > 0) {
            this.value = new byte[this.length];
 
            // if there is an underrun just toss the TLV 
            if (bb.remaining() < this.length)
                return null; 
            bb.get(this.value);
        } 
        return this;
    } 
 
    /* (non-Javadoc) 
     * @see java.lang.Object#hashCode()