src/java.base/share/classes/java/nio/X-Buffer.java.template
changeset 53959 1542e63eb537
parent 53855 7c362992527a
child 54151 d2f8b7b33013
equal deleted inserted replaced
53958:196ab0abc685 53959:1542e63eb537
   545      */
   545      */
   546     @Override
   546     @Override
   547     public abstract $Type$Buffer slice();
   547     public abstract $Type$Buffer slice();
   548 
   548 
   549     /**
   549     /**
       
   550      * Creates a new $type$ buffer whose content is a shared subsequence of
       
   551      * this buffer's content.
       
   552      *
       
   553      * <p> The content of the new buffer will start at position {@code index}
       
   554      * in this buffer, and will contain {@code length} elements. Changes to
       
   555      * this buffer's content will be visible in the new buffer, and vice versa;
       
   556      * the two buffers' position, limit, and mark values will be independent.
       
   557      *
       
   558      * <p> The new buffer's position will be zero, its capacity and its limit
       
   559      * will be {@code length}, its mark will be undefined, and its byte order
       
   560      * will be
       
   561 #if[byte]
       
   562      * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
       
   563 #else[byte]
       
   564      * identical to that of this buffer.
       
   565 #end[byte]
       
   566      * The new buffer will be direct if, and only if, this buffer is direct,
       
   567      * and it will be read-only if, and only if, this buffer is read-only. </p>
       
   568      *
       
   569      * @param   index
       
   570      *          The position in this buffer at which the content of the new
       
   571      *          buffer will start; must be non-negative and no larger than
       
   572      *          {@link #limit() limit()}
       
   573      *
       
   574      * @param   length
       
   575      *          The number of elements the new buffer will contain; must be
       
   576      *          non-negative and no larger than {@code limit() - index}
       
   577      *
       
   578      * @return  The new buffer
       
   579      *
       
   580      * @throws  IndexOutOfBoundsException
       
   581      *          If {@code index} is negative or greater than {@code limit()},
       
   582      *          {@code length} is negative, or {@code length > limit() - index}
       
   583      *
       
   584      * @since 13
       
   585      */
       
   586     @Override
       
   587     public abstract $Type$Buffer slice(int index, int length);
       
   588 
       
   589     /**
   550      * Creates a new $type$ buffer that shares this buffer's content.
   590      * Creates a new $type$ buffer that shares this buffer's content.
   551      *
   591      *
   552      * <p> The content of the new buffer will be that of this buffer.  Changes
   592      * <p> The content of the new buffer will be that of this buffer.  Changes
   553      * to this buffer's content will be visible in the new buffer, and vice
   593      * to this buffer's content will be visible in the new buffer, and vice
   554      * versa; the two buffers' position, limit, and mark values will be
   594      * versa; the two buffers' position, limit, and mark values will be
  1948 
  1988 
  1949         if (aligned_pos > lim || aligned_lim < pos) {
  1989         if (aligned_pos > lim || aligned_lim < pos) {
  1950             aligned_pos = aligned_lim = pos;
  1990             aligned_pos = aligned_lim = pos;
  1951         }
  1991         }
  1952 
  1992 
  1953         return slice(aligned_pos, aligned_lim);
  1993         return slice(aligned_pos, aligned_lim - aligned_pos);
  1954     }
  1994     }
  1955 
       
  1956     abstract ByteBuffer slice(int pos, int lim);
       
  1957 
  1995 
  1958     // #BIN
  1996     // #BIN
  1959     //
  1997     //
  1960     // Binary-data access methods  for short, char, int, long, float,
  1998     // Binary-data access methods  for short, char, int, long, float,
  1961     // and double will be inserted here
  1999     // and double will be inserted here