src/java.base/share/classes/java/nio/X-Buffer.java.template
changeset 54151 d2f8b7b33013
parent 53959 1542e63eb537
equal deleted inserted replaced
54150:5529640c5f67 54151:d2f8b7b33013
   770      * @throws  IndexOutOfBoundsException
   770      * @throws  IndexOutOfBoundsException
   771      *          If the preconditions on the {@code offset} and {@code length}
   771      *          If the preconditions on the {@code offset} and {@code length}
   772      *          parameters do not hold
   772      *          parameters do not hold
   773      */
   773      */
   774     public $Type$Buffer get($type$[] dst, int offset, int length) {
   774     public $Type$Buffer get($type$[] dst, int offset, int length) {
   775         checkBounds(offset, length, dst.length);
   775         Objects.checkFromIndexSize(offset, length, dst.length);
   776         if (length > remaining())
   776         if (length > remaining())
   777             throw new BufferUnderflowException();
   777             throw new BufferUnderflowException();
   778         int end = offset + length;
   778         int end = offset + length;
   779         for (int i = offset; i < end; i++)
   779         for (int i = offset; i < end; i++)
   780             dst[i] = get();
   780             dst[i] = get();
   994      *
   994      *
   995      * @throws  ReadOnlyBufferException
   995      * @throws  ReadOnlyBufferException
   996      *          If this buffer is read-only
   996      *          If this buffer is read-only
   997      */
   997      */
   998     public $Type$Buffer put($type$[] src, int offset, int length) {
   998     public $Type$Buffer put($type$[] src, int offset, int length) {
   999         checkBounds(offset, length, src.length);
   999         Objects.checkFromIndexSize(offset, length, src.length);
  1000         if (length > remaining())
  1000         if (length > remaining())
  1001             throw new BufferOverflowException();
  1001             throw new BufferOverflowException();
  1002         int end = offset + length;
  1002         int end = offset + length;
  1003         for (int i = offset; i < end; i++)
  1003         for (int i = offset; i < end; i++)
  1004             this.put(src[i]);
  1004             this.put(src[i]);
  1174      *
  1174      *
  1175      * @throws  ReadOnlyBufferException
  1175      * @throws  ReadOnlyBufferException
  1176      *          If this buffer is read-only
  1176      *          If this buffer is read-only
  1177      */
  1177      */
  1178     public $Type$Buffer put(String src, int start, int end) {
  1178     public $Type$Buffer put(String src, int start, int end) {
  1179         checkBounds(start, end - start, src.length());
  1179         Objects.checkFromIndexSize(start, end - start, src.length());
  1180         if (isReadOnly())
  1180         if (isReadOnly())
  1181             throw new ReadOnlyBufferException();
  1181             throw new ReadOnlyBufferException();
  1182         if (end - start > remaining())
  1182         if (end - start > remaining())
  1183             throw new BufferOverflowException();
  1183             throw new BufferOverflowException();
  1184         for (int i = start; i < end; i++)
  1184         for (int i = start; i < end; i++)