protected long checkSlice ( long offset , long length ) { checkOffset ( offset ) ; if ( limit == - 1 ) { if ( offset + length > capacity ) { if ( capacity < maxCapacity ) { capacity ( calculateCapacity ( offset + length ) ) ; } else { throw new BufferUnderflowException ( ) ; } } } else { if ( offset + length > limit ) throw new BufferUnderflowException ( ) ; } return offset ( offset ) ; }
Checks bounds for a slice .