635
636 /**
637 * Relative bulk <i>get</i> method.
638 *
639 * <p> This method transfers $type$s from this buffer into the given
640 * destination array. If there are fewer $type$s remaining in the
641 * buffer than are required to satisfy the request, that is, if
642 * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
643 * $type$s are transferred and a {@link BufferUnderflowException} is
644 * thrown.
645 *
646 * <p> Otherwise, this method copies <tt>length</tt> $type$s from this
647 * buffer into the given array, starting at the current position of this
648 * buffer and at the given offset in the array. The position of this
649 * buffer is then incremented by <tt>length</tt>.
650 *
651 * <p> In other words, an invocation of this method of the form
652 * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
653 * the loop
654 *
655 * <pre>
656 * for (int i = off; i < off + len; i++)
657 * dst[i] = src.get(); </pre>
658 *
659 * except that it first checks that there are sufficient $type$s in
660 * this buffer and it is potentially much more efficient. </p>
661 *
662 * @param dst
663 * The array into which $type$s are to be written
664 *
665 * @param offset
666 * The offset within the array of the first $type$ to be
667 * written; must be non-negative and no larger than
668 * <tt>dst.length</tt>
669 *
670 * @param length
671 * The maximum number of $type$s to be written to the given
672 * array; must be non-negative and no larger than
673 * <tt>dst.length - offset</tt>
674 *
675 * @return This buffer
676 *
677 * @throws BufferUnderflowException
771
772 /**
773 * Relative bulk <i>put</i> method <i>(optional operation)</i>.
774 *
775 * <p> This method transfers $type$s into this buffer from the given
776 * source array. If there are more $type$s to be copied from the array
777 * than remain in this buffer, that is, if
778 * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
779 * $type$s are transferred and a {@link BufferOverflowException} is
780 * thrown.
781 *
782 * <p> Otherwise, this method copies <tt>length</tt> $type$s from the
783 * given array into this buffer, starting at the given offset in the array
784 * and at the current position of this buffer. The position of this buffer
785 * is then incremented by <tt>length</tt>.
786 *
787 * <p> In other words, an invocation of this method of the form
788 * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
789 * the loop
790 *
791 * <pre>
792 * for (int i = off; i < off + len; i++)
793 * dst.put(a[i]); </pre>
794 *
795 * except that it first checks that there is sufficient space in this
796 * buffer and it is potentially much more efficient. </p>
797 *
798 * @param src
799 * The array from which $type$s are to be read
800 *
801 * @param offset
802 * The offset within the array of the first $type$ to be read;
803 * must be non-negative and no larger than <tt>array.length</tt>
804 *
805 * @param length
806 * The number of $type$s to be read from the given array;
807 * must be non-negative and no larger than
808 * <tt>array.length - offset</tt>
809 *
810 * @return This buffer
811 *
812 * @throws BufferOverflowException
813 * If there is insufficient space in this buffer
857 /**
858 * Relative bulk <i>put</i> method <i>(optional operation)</i>.
859 *
860 * <p> This method transfers $type$s from the given string into this
861 * buffer. If there are more $type$s to be copied from the string than
862 * remain in this buffer, that is, if
863 * <tt>end - start</tt> <tt>></tt> <tt>remaining()</tt>,
864 * then no $type$s are transferred and a {@link
865 * BufferOverflowException} is thrown.
866 *
867 * <p> Otherwise, this method copies
868 * <i>n</i> = <tt>end</tt> - <tt>start</tt> $type$s
869 * from the given string into this buffer, starting at the given
870 * <tt>start</tt> index and at the current position of this buffer. The
871 * position of this buffer is then incremented by <i>n</i>.
872 *
873 * <p> In other words, an invocation of this method of the form
874 * <tt>dst.put(src, start, end)</tt> has exactly the same effect
875 * as the loop
876 *
877 * <pre>
878 * for (int i = start; i < end; i++)
879 * dst.put(src.charAt(i)); </pre>
880 *
881 * except that it first checks that there is sufficient space in this
882 * buffer and it is potentially much more efficient. </p>
883 *
884 * @param src
885 * The string from which $type$s are to be read
886 *
887 * @param start
888 * The offset within the string of the first $type$ to be read;
889 * must be non-negative and no larger than
890 * <tt>string.length()</tt>
891 *
892 * @param end
893 * The offset within the string of the last $type$ to be read,
894 * plus one; must be non-negative and no larger than
895 * <tt>string.length()</tt>
896 *
897 * @return This buffer
898 *
899 * @throws BufferOverflowException
1021 * if any, are copied to the beginning of the buffer. That is, the
1022 * $type$ at index <i>p</i> = <tt>position()</tt> is copied
1023 * to index zero, the $type$ at index <i>p</i> + 1 is copied
1024 * to index one, and so forth until the $type$ at index
1025 * <tt>limit()</tt> - 1 is copied to index
1026 * <i>n</i> = <tt>limit()</tt> - <tt>1</tt> - <i>p</i>.
1027 * The buffer's position is then set to <i>n+1</i> and its limit is set to
1028 * its capacity. The mark, if defined, is discarded.
1029 *
1030 * <p> The buffer's position is set to the number of $type$s copied,
1031 * rather than to zero, so that an invocation of this method can be
1032 * followed immediately by an invocation of another relative <i>put</i>
1033 * method. </p>
1034 *
1035 #if[byte]
1036 *
1037 * <p> Invoke this method after writing data from a buffer in case the
1038 * write was incomplete. The following loop, for example, copies bytes
1039 * from one channel to another via the buffer <tt>buf</tt>:
1040 *
1041 * <blockquote><pre>
1042 * buf.clear(); // Prepare buffer for use
1043 * while (in.read(buf) >= 0 || buf.position != 0) {
1044 * buf.flip();
1045 * out.write(buf);
1046 * buf.compact(); // In case of partial write
1047 * }</pre></blockquote>
1048 *
1049 #end[byte]
1050 *
1051 * @return This buffer
1052 *
1053 * @throws ReadOnlyBufferException
1054 * If this buffer is read-only
1055 */
1056 public abstract $Type$Buffer compact();
1057
1058 /**
1059 * Tells whether or not this $type$ buffer is direct. </p>
1060 *
1061 * @return <tt>true</tt> if, and only if, this buffer is direct
1062 */
1063 public abstract boolean isDirect();
1064
1065 #if[!char]
1066
|
635
636 /**
637 * Relative bulk <i>get</i> method.
638 *
639 * <p> This method transfers $type$s from this buffer into the given
640 * destination array. If there are fewer $type$s remaining in the
641 * buffer than are required to satisfy the request, that is, if
642 * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
643 * $type$s are transferred and a {@link BufferUnderflowException} is
644 * thrown.
645 *
646 * <p> Otherwise, this method copies <tt>length</tt> $type$s from this
647 * buffer into the given array, starting at the current position of this
648 * buffer and at the given offset in the array. The position of this
649 * buffer is then incremented by <tt>length</tt>.
650 *
651 * <p> In other words, an invocation of this method of the form
652 * <tt>src.get(dst, off, len)</tt> has exactly the same effect as
653 * the loop
654 *
655 * <pre>{@code
656 * for (int i = off; i < off + len; i++)
657 * dst[i] = src.get():
658 * }</pre>
659 *
660 * except that it first checks that there are sufficient $type$s in
661 * this buffer and it is potentially much more efficient. </p>
662 *
663 * @param dst
664 * The array into which $type$s are to be written
665 *
666 * @param offset
667 * The offset within the array of the first $type$ to be
668 * written; must be non-negative and no larger than
669 * <tt>dst.length</tt>
670 *
671 * @param length
672 * The maximum number of $type$s to be written to the given
673 * array; must be non-negative and no larger than
674 * <tt>dst.length - offset</tt>
675 *
676 * @return This buffer
677 *
678 * @throws BufferUnderflowException
772
773 /**
774 * Relative bulk <i>put</i> method <i>(optional operation)</i>.
775 *
776 * <p> This method transfers $type$s into this buffer from the given
777 * source array. If there are more $type$s to be copied from the array
778 * than remain in this buffer, that is, if
779 * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
780 * $type$s are transferred and a {@link BufferOverflowException} is
781 * thrown.
782 *
783 * <p> Otherwise, this method copies <tt>length</tt> $type$s from the
784 * given array into this buffer, starting at the given offset in the array
785 * and at the current position of this buffer. The position of this buffer
786 * is then incremented by <tt>length</tt>.
787 *
788 * <p> In other words, an invocation of this method of the form
789 * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
790 * the loop
791 *
792 * <pre>{@code
793 * for (int i = off; i < off + len; i++)
794 * dst.put(a[i]);
795 * }</pre>
796 *
797 * except that it first checks that there is sufficient space in this
798 * buffer and it is potentially much more efficient. </p>
799 *
800 * @param src
801 * The array from which $type$s are to be read
802 *
803 * @param offset
804 * The offset within the array of the first $type$ to be read;
805 * must be non-negative and no larger than <tt>array.length</tt>
806 *
807 * @param length
808 * The number of $type$s to be read from the given array;
809 * must be non-negative and no larger than
810 * <tt>array.length - offset</tt>
811 *
812 * @return This buffer
813 *
814 * @throws BufferOverflowException
815 * If there is insufficient space in this buffer
859 /**
860 * Relative bulk <i>put</i> method <i>(optional operation)</i>.
861 *
862 * <p> This method transfers $type$s from the given string into this
863 * buffer. If there are more $type$s to be copied from the string than
864 * remain in this buffer, that is, if
865 * <tt>end - start</tt> <tt>></tt> <tt>remaining()</tt>,
866 * then no $type$s are transferred and a {@link
867 * BufferOverflowException} is thrown.
868 *
869 * <p> Otherwise, this method copies
870 * <i>n</i> = <tt>end</tt> - <tt>start</tt> $type$s
871 * from the given string into this buffer, starting at the given
872 * <tt>start</tt> index and at the current position of this buffer. The
873 * position of this buffer is then incremented by <i>n</i>.
874 *
875 * <p> In other words, an invocation of this method of the form
876 * <tt>dst.put(src, start, end)</tt> has exactly the same effect
877 * as the loop
878 *
879 * <pre>{@code
880 * for (int i = start; i < end; i++)
881 * dst.put(src.charAt(i));
882 * }</pre>
883 *
884 * except that it first checks that there is sufficient space in this
885 * buffer and it is potentially much more efficient. </p>
886 *
887 * @param src
888 * The string from which $type$s are to be read
889 *
890 * @param start
891 * The offset within the string of the first $type$ to be read;
892 * must be non-negative and no larger than
893 * <tt>string.length()</tt>
894 *
895 * @param end
896 * The offset within the string of the last $type$ to be read,
897 * plus one; must be non-negative and no larger than
898 * <tt>string.length()</tt>
899 *
900 * @return This buffer
901 *
902 * @throws BufferOverflowException
1024 * if any, are copied to the beginning of the buffer. That is, the
1025 * $type$ at index <i>p</i> = <tt>position()</tt> is copied
1026 * to index zero, the $type$ at index <i>p</i> + 1 is copied
1027 * to index one, and so forth until the $type$ at index
1028 * <tt>limit()</tt> - 1 is copied to index
1029 * <i>n</i> = <tt>limit()</tt> - <tt>1</tt> - <i>p</i>.
1030 * The buffer's position is then set to <i>n+1</i> and its limit is set to
1031 * its capacity. The mark, if defined, is discarded.
1032 *
1033 * <p> The buffer's position is set to the number of $type$s copied,
1034 * rather than to zero, so that an invocation of this method can be
1035 * followed immediately by an invocation of another relative <i>put</i>
1036 * method. </p>
1037 *
1038 #if[byte]
1039 *
1040 * <p> Invoke this method after writing data from a buffer in case the
1041 * write was incomplete. The following loop, for example, copies bytes
1042 * from one channel to another via the buffer <tt>buf</tt>:
1043 *
1044 * <blockquote><pre>{@code
1045 * buf.clear(); // Prepare buffer for use
1046 * while (in.read(buf) >= 0 || buf.position != 0) {
1047 * buf.flip();
1048 * out.write(buf);
1049 * buf.compact(); // In case of partial write
1050 * }
1051 * }</pre></blockquote>
1052 *
1053 #end[byte]
1054 *
1055 * @return This buffer
1056 *
1057 * @throws ReadOnlyBufferException
1058 * If this buffer is read-only
1059 */
1060 public abstract $Type$Buffer compact();
1061
1062 /**
1063 * Tells whether or not this $type$ buffer is direct. </p>
1064 *
1065 * @return <tt>true</tt> if, and only if, this buffer is direct
1066 */
1067 public abstract boolean isDirect();
1068
1069 #if[!char]
1070
|