src/share/classes/java/nio/X-Buffer.java.template

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #warn This file is preprocessed before being compiled
  27 
  28 package java.nio;
  29 
  30 #if[char]
  31 import java.io.IOException;
  32 #end[char]





  33 
  34 /**
  35  * $A$ $type$ buffer.
  36  *
  37  * <p> This class defines {#if[byte]?six:four} categories of operations upon
  38  * $type$ buffers:
  39  *
  40  * <ul>
  41  *
  42  *   <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
  43  *   {@link #put($type$) </code><i>put</i><code>} methods that read and write
  44  *   single $type$s; </p></li>
  45  *
  46  *   <li><p> Relative {@link #get($type$[]) </code><i>bulk get</i><code>}
  47  *   methods that transfer contiguous sequences of $type$s from this buffer
  48  *   into an array; {#if[!byte]?and}</p></li>
  49  *
  50  *   <li><p> Relative {@link #put($type$[]) </code><i>bulk put</i><code>}
  51  *   methods that transfer contiguous sequences of $type$s from $a$
  52  *   $type$ array{#if[char]?,&#32;a&#32;string,} or some other $type$


 572      * @throws  ReadOnlyBufferException
 573      *          If this buffer is read-only
 574      */
 575     public abstract $Type$Buffer put($type$ $x$);
 576 
 577     /**
 578      * Absolute <i>get</i> method.  Reads the $type$ at the given
 579      * index. </p>
 580      *
 581      * @param  index
 582      *         The index from which the $type$ will be read
 583      *
 584      * @return  The $type$ at the given index
 585      *
 586      * @throws  IndexOutOfBoundsException
 587      *          If <tt>index</tt> is negative
 588      *          or not smaller than the buffer's limit
 589      */
 590     public abstract $type$ get(int index);
 591 













 592     /**
 593      * Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
 594      *
 595      * <p> Writes the given $type$ into this buffer at the given
 596      * index. </p>
 597      *
 598      * @param  index
 599      *         The index at which the $type$ will be written
 600      *
 601      * @param  $x$
 602      *         The $type$ value to be written
 603      *
 604      * @return  This buffer
 605      *
 606      * @throws  IndexOutOfBoundsException
 607      *          If <tt>index</tt> is negative
 608      *          or not smaller than the buffer's limit
 609      *
 610      * @throws  ReadOnlyBufferException
 611      *          If this buffer is read-only


1440      * @return  This buffer
1441      */
1442     public final $Type$Buffer order(ByteOrder bo) {
1443         bigEndian = (bo == ByteOrder.BIG_ENDIAN);
1444         nativeByteOrder =
1445             (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
1446         return this;
1447     }
1448 
1449     // Unchecked accessors, for use by ByteBufferAs-X-Buffer classes
1450     //
1451     abstract byte _get(int i);                          // package-private
1452     abstract void _put(int i, byte b);                  // package-private
1453 
1454     // #BIN
1455     //
1456     // Binary-data access methods  for short, char, int, long, float,
1457     // and double will be inserted here
1458 
1459 #end[byte]












1460 
1461 }


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #warn This file is preprocessed before being compiled
  27 
  28 package java.nio;
  29 
  30 #if[char]
  31 import java.io.IOException;
  32 #end[char]
  33 #if[streamableType]
  34 import java.util.Spliterator;
  35 import java.util.stream.StreamSupport;
  36 import java.util.stream.$Streamtype$Stream;
  37 #end[streamableType]
  38 
  39 /**
  40  * $A$ $type$ buffer.
  41  *
  42  * <p> This class defines {#if[byte]?six:four} categories of operations upon
  43  * $type$ buffers:
  44  *
  45  * <ul>
  46  *
  47  *   <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
  48  *   {@link #put($type$) </code><i>put</i><code>} methods that read and write
  49  *   single $type$s; </p></li>
  50  *
  51  *   <li><p> Relative {@link #get($type$[]) </code><i>bulk get</i><code>}
  52  *   methods that transfer contiguous sequences of $type$s from this buffer
  53  *   into an array; {#if[!byte]?and}</p></li>
  54  *
  55  *   <li><p> Relative {@link #put($type$[]) </code><i>bulk put</i><code>}
  56  *   methods that transfer contiguous sequences of $type$s from $a$
  57  *   $type$ array{#if[char]?,&#32;a&#32;string,} or some other $type$


 577      * @throws  ReadOnlyBufferException
 578      *          If this buffer is read-only
 579      */
 580     public abstract $Type$Buffer put($type$ $x$);
 581 
 582     /**
 583      * Absolute <i>get</i> method.  Reads the $type$ at the given
 584      * index. </p>
 585      *
 586      * @param  index
 587      *         The index from which the $type$ will be read
 588      *
 589      * @return  The $type$ at the given index
 590      *
 591      * @throws  IndexOutOfBoundsException
 592      *          If <tt>index</tt> is negative
 593      *          or not smaller than the buffer's limit
 594      */
 595     public abstract $type$ get(int index);
 596 
 597 #if[streamableType]
 598     /**
 599      * Absolute <i>get</i> method.  Reads the $type$ at the given
 600      * index without any validation of the index.
 601      *
 602      * @param  index
 603      *         The index from which the $type$ will be read
 604      *
 605      * @return  The $type$ at the given index
 606      */
 607     abstract $type$ getUnchecked(int index);   // package-private
 608 #end[streamableType]
 609 
 610     /**
 611      * Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
 612      *
 613      * <p> Writes the given $type$ into this buffer at the given
 614      * index. </p>
 615      *
 616      * @param  index
 617      *         The index at which the $type$ will be written
 618      *
 619      * @param  $x$
 620      *         The $type$ value to be written
 621      *
 622      * @return  This buffer
 623      *
 624      * @throws  IndexOutOfBoundsException
 625      *          If <tt>index</tt> is negative
 626      *          or not smaller than the buffer's limit
 627      *
 628      * @throws  ReadOnlyBufferException
 629      *          If this buffer is read-only


1458      * @return  This buffer
1459      */
1460     public final $Type$Buffer order(ByteOrder bo) {
1461         bigEndian = (bo == ByteOrder.BIG_ENDIAN);
1462         nativeByteOrder =
1463             (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
1464         return this;
1465     }
1466 
1467     // Unchecked accessors, for use by ByteBufferAs-X-Buffer classes
1468     //
1469     abstract byte _get(int i);                          // package-private
1470     abstract void _put(int i, byte b);                  // package-private
1471 
1472     // #BIN
1473     //
1474     // Binary-data access methods  for short, char, int, long, float,
1475     // and double will be inserted here
1476 
1477 #end[byte]
1478 
1479 #if[streamableType]
1480 
1481 #if[char]
1482     @Override
1483 #end[char]
1484     public $Streamtype$Stream $type$s() {
1485         return StreamSupport.$streamtype$Stream(() -> new $Type$BufferSpliterator(this),
1486             Buffer.SPLITERATOR_CHARACTERISTICS);
1487     }
1488 
1489 #end[streamableType]
1490 
1491 }