author | bpb |
Wed, 20 Feb 2019 10:57:22 -0800 | |
changeset 53855 | 7c362992527a |
parent 53832 | 842b45d8e25e |
child 53959 | 1542e63eb537 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
53855 | 2 |
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
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 |
* |
|
5506 | 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. |
|
2 | 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] |
|
17922
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
33 |
#if[streamableType] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
34 |
import java.util.Spliterator; |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
35 |
import java.util.stream.StreamSupport; |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
36 |
import java.util.stream.$Streamtype$Stream; |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
37 |
#end[streamableType] |
2 | 38 |
|
53855 | 39 |
import java.util.Objects; |
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
40 |
import jdk.internal.util.ArraysSupport; |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
41 |
|
2 | 42 |
/** |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
43 |
* $A$ $type$ buffer. |
2 | 44 |
* |
45 |
* <p> This class defines {#if[byte]?six:four} categories of operations upon |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
46 |
* $type$ buffers: |
2 | 47 |
* |
48 |
* <ul> |
|
49 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
50 |
* <li><p> Absolute and relative {@link #get() <i>get</i>} and |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
51 |
* {@link #put($type$) <i>put</i>} methods that read and write |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
52 |
* single $type$s; </p></li> |
2 | 53 |
* |
53855 | 54 |
* <li><p> Absolute and relative {@link #get($type$[]) <i>bulk get</i>} |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
55 |
* methods that transfer contiguous sequences of $type$s from this buffer |
2 | 56 |
* into an array; {#if[!byte]?and}</p></li> |
57 |
* |
|
53855 | 58 |
* <li><p> Absolute and relative {@link #put($type$[]) <i>bulk put</i>} |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
59 |
* methods that transfer contiguous sequences of $type$s from $a$ |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
60 |
* $type$ array{#if[char]?, a string,} or some other $type$ |
2 | 61 |
* buffer into this buffer;{#if[!byte]? and} </p></li> |
62 |
* |
|
63 |
#if[byte] |
|
64 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
65 |
* <li><p> Absolute and relative {@link #getChar() <i>get</i>} |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
66 |
* and {@link #putChar(char) <i>put</i>} methods that read and |
2 | 67 |
* write values of other primitive types, translating them to and from |
68 |
* sequences of bytes in a particular byte order; </p></li> |
|
69 |
* |
|
70 |
* <li><p> Methods for creating <i><a href="#views">view buffers</a></i>, |
|
71 |
* which allow a byte buffer to be viewed as a buffer containing values of |
|
72 |
* some other primitive type; and </p></li> |
|
73 |
* |
|
74 |
#end[byte] |
|
75 |
* |
|
38321
ff5b89346438
8150785: (bf) Hoist slice and duplicate methods up to java.nio.Buffer
prappo
parents:
36933
diff
changeset
|
76 |
* <li><p> A method for {@link #compact compacting} |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
77 |
* $a$ $type$ buffer. </p></li> |
2 | 78 |
* |
79 |
* </ul> |
|
80 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
81 |
* <p> $Type$ buffers can be created either by {@link #allocate |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
82 |
* <i>allocation</i>}, which allocates space for the buffer's |
2 | 83 |
* |
84 |
#if[byte] |
|
85 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
86 |
* content, or by {@link #wrap($type$[]) <i>wrapping</i>} an |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
87 |
* existing $type$ array {#if[char]?or string} into a buffer. |
2 | 88 |
* |
89 |
#else[byte] |
|
90 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
91 |
* content, by {@link #wrap($type$[]) <i>wrapping</i>} an existing |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
92 |
* $type$ array {#if[char]?or string} into a buffer, or by creating a |
2 | 93 |
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer. |
94 |
* |
|
95 |
#end[byte] |
|
96 |
* |
|
97 |
#if[byte] |
|
98 |
* |
|
44851
3439a92526a0
8179413: Fix remaining minor HTML5 issues in java.base module
jjg
parents:
44369
diff
changeset
|
99 |
* <a id="direct"></a> |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
100 |
* <h2> Direct <i>vs.</i> non-direct buffers </h2> |
2 | 101 |
* |
102 |
* <p> A byte buffer is either <i>direct</i> or <i>non-direct</i>. Given a |
|
103 |
* direct byte buffer, the Java virtual machine will make a best effort to |
|
104 |
* perform native I/O operations directly upon it. That is, it will attempt to |
|
105 |
* avoid copying the buffer's content to (or from) an intermediate buffer |
|
106 |
* before (or after) each invocation of one of the underlying operating |
|
107 |
* system's native I/O operations. |
|
108 |
* |
|
109 |
* <p> A direct byte buffer may be created by invoking the {@link |
|
110 |
* #allocateDirect(int) allocateDirect} factory method of this class. The |
|
111 |
* buffers returned by this method typically have somewhat higher allocation |
|
112 |
* and deallocation costs than non-direct buffers. The contents of direct |
|
113 |
* buffers may reside outside of the normal garbage-collected heap, and so |
|
114 |
* their impact upon the memory footprint of an application might not be |
|
115 |
* obvious. It is therefore recommended that direct buffers be allocated |
|
116 |
* primarily for large, long-lived buffers that are subject to the underlying |
|
117 |
* system's native I/O operations. In general it is best to allocate direct |
|
118 |
* buffers only when they yield a measureable gain in program performance. |
|
119 |
* |
|
120 |
* <p> A direct byte buffer may also be created by {@link |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
121 |
* java.nio.channels.FileChannel#map mapping} a region of a file |
2 | 122 |
* directly into memory. An implementation of the Java platform may optionally |
123 |
* support the creation of direct byte buffers from native code via JNI. If an |
|
124 |
* instance of one of these kinds of buffers refers to an inaccessible region |
|
125 |
* of memory then an attempt to access that region will not change the buffer's |
|
126 |
* content and will cause an unspecified exception to be thrown either at the |
|
127 |
* time of the access or at some later time. |
|
128 |
* |
|
129 |
* <p> Whether a byte buffer is direct or non-direct may be determined by |
|
130 |
* invoking its {@link #isDirect isDirect} method. This method is provided so |
|
131 |
* that explicit buffer management can be done in performance-critical code. |
|
132 |
* |
|
133 |
* |
|
44851
3439a92526a0
8179413: Fix remaining minor HTML5 issues in java.base module
jjg
parents:
44369
diff
changeset
|
134 |
* <a id="bin"></a> |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
135 |
* <h2> Access to binary data </h2> |
2 | 136 |
* |
137 |
* <p> This class defines methods for reading and writing values of all other |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
138 |
* primitive types, except {@code boolean}. Primitive values are translated |
2 | 139 |
* to (or from) sequences of bytes according to the buffer's current byte |
140 |
* order, which may be retrieved and modified via the {@link #order order} |
|
141 |
* methods. Specific byte orders are represented by instances of the {@link |
|
142 |
* ByteOrder} class. The initial order of a byte buffer is always {@link |
|
143 |
* ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
|
144 |
* |
|
145 |
* <p> For access to heterogeneous binary data, that is, sequences of values of |
|
146 |
* different types, this class defines a family of absolute and relative |
|
147 |
* <i>get</i> and <i>put</i> methods for each type. For 32-bit floating-point |
|
148 |
* values, for example, this class defines: |
|
149 |
* |
|
150 |
* <blockquote><pre> |
|
151 |
* float {@link #getFloat()} |
|
152 |
* float {@link #getFloat(int) getFloat(int index)} |
|
153 |
* void {@link #putFloat(float) putFloat(float f)} |
|
154 |
* void {@link #putFloat(int,float) putFloat(int index, float f)}</pre></blockquote> |
|
155 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
156 |
* <p> Corresponding methods are defined for the types {@code char, |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
157 |
* short, int, long}, and {@code double}. The index |
2 | 158 |
* parameters of the absolute <i>get</i> and <i>put</i> methods are in terms of |
159 |
* bytes rather than of the type being read or written. |
|
160 |
* |
|
44851
3439a92526a0
8179413: Fix remaining minor HTML5 issues in java.base module
jjg
parents:
44369
diff
changeset
|
161 |
* <a id="views"></a> |
2 | 162 |
* |
163 |
* <p> For access to homogeneous binary data, that is, sequences of values of |
|
164 |
* the same type, this class defines methods that can create <i>views</i> of a |
|
165 |
* given byte buffer. A <i>view buffer</i> is simply another buffer whose |
|
166 |
* content is backed by the byte buffer. Changes to the byte buffer's content |
|
167 |
* will be visible in the view buffer, and vice versa; the two buffers' |
|
168 |
* position, limit, and mark values are independent. The {@link |
|
169 |
* #asFloatBuffer() asFloatBuffer} method, for example, creates an instance of |
|
170 |
* the {@link FloatBuffer} class that is backed by the byte buffer upon which |
|
171 |
* the method is invoked. Corresponding view-creation methods are defined for |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
172 |
* the types {@code char, short, int, long}, and {@code double}. |
2 | 173 |
* |
174 |
* <p> View buffers have three important advantages over the families of |
|
175 |
* type-specific <i>get</i> and <i>put</i> methods described above: |
|
176 |
* |
|
177 |
* <ul> |
|
178 |
* |
|
179 |
* <li><p> A view buffer is indexed not in terms of bytes but rather in terms |
|
180 |
* of the type-specific size of its values; </p></li> |
|
181 |
* |
|
182 |
* <li><p> A view buffer provides relative bulk <i>get</i> and <i>put</i> |
|
183 |
* methods that can transfer contiguous sequences of values between a buffer |
|
184 |
* and an array or some other buffer of the same type; and </p></li> |
|
185 |
* |
|
186 |
* <li><p> A view buffer is potentially much more efficient because it will |
|
187 |
* be direct if, and only if, its backing byte buffer is direct. </p></li> |
|
188 |
* |
|
189 |
* </ul> |
|
190 |
* |
|
191 |
* <p> The byte order of a view buffer is fixed to be that of its byte buffer |
|
192 |
* at the time that the view is created. </p> |
|
193 |
* |
|
194 |
#end[byte] |
|
195 |
* |
|
196 |
#if[!byte] |
|
197 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
198 |
* <p> Like a byte buffer, $a$ $type$ buffer is either <a |
2 | 199 |
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
200 |
* $type$ buffer created via the {@code wrap} methods of this class will |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
201 |
* be non-direct. $A$ $type$ buffer created as a view of a byte buffer will |
2 | 202 |
* be direct if, and only if, the byte buffer itself is direct. Whether or not |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
203 |
* $a$ $type$ buffer is direct may be determined by invoking the {@link |
2 | 204 |
* #isDirect isDirect} method. </p> |
205 |
* |
|
206 |
#end[!byte] |
|
207 |
* |
|
208 |
#if[char] |
|
209 |
* |
|
210 |
* <p> This class implements the {@link CharSequence} interface so that |
|
211 |
* character buffers may be used wherever character sequences are accepted, for |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
212 |
* example in the regular-expression package {@link java.util.regex}. |
53832
842b45d8e25e
8065262: (bf spec) CharBuffer.chars() should make it clearer that the sequence starts from the buffer position
bpb
parents:
50596
diff
changeset
|
213 |
* The methods defined by {@code CharSequence} operate relative to the current |
842b45d8e25e
8065262: (bf spec) CharBuffer.chars() should make it clearer that the sequence starts from the buffer position
bpb
parents:
50596
diff
changeset
|
214 |
* position of the buffer when they are invoked. |
2 | 215 |
* </p> |
216 |
* |
|
217 |
#end[char] |
|
218 |
* |
|
219 |
#if[byte] |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
220 |
* <h2> Invocation chaining </h2> |
2 | 221 |
#end[byte] |
222 |
* |
|
223 |
* <p> Methods in this class that do not otherwise have a value to return are |
|
224 |
* specified to return the buffer upon which they are invoked. This allows |
|
225 |
* method invocations to be chained. |
|
226 |
* |
|
227 |
#if[byte] |
|
228 |
* |
|
229 |
* The sequence of statements |
|
230 |
* |
|
231 |
* <blockquote><pre> |
|
232 |
* bb.putInt(0xCAFEBABE); |
|
233 |
* bb.putShort(3); |
|
234 |
* bb.putShort(45);</pre></blockquote> |
|
235 |
* |
|
236 |
* can, for example, be replaced by the single statement |
|
237 |
* |
|
238 |
* <blockquote><pre> |
|
239 |
* bb.putInt(0xCAFEBABE).putShort(3).putShort(45);</pre></blockquote> |
|
240 |
* |
|
241 |
#end[byte] |
|
242 |
#if[char] |
|
243 |
* |
|
244 |
* The sequence of statements |
|
245 |
* |
|
246 |
* <blockquote><pre> |
|
247 |
* cb.put("text/"); |
|
248 |
* cb.put(subtype); |
|
249 |
* cb.put("; charset="); |
|
250 |
* cb.put(enc);</pre></blockquote> |
|
251 |
* |
|
252 |
* can, for example, be replaced by the single statement |
|
253 |
* |
|
254 |
* <blockquote><pre> |
|
255 |
* cb.put("text/").put(subtype).put("; charset=").put(enc);</pre></blockquote> |
|
256 |
* |
|
257 |
#end[char] |
|
258 |
* |
|
259 |
* |
|
260 |
* @author Mark Reinhold |
|
261 |
* @author JSR-51 Expert Group |
|
262 |
* @since 1.4 |
|
263 |
*/ |
|
264 |
||
265 |
public abstract class $Type$Buffer |
|
266 |
extends Buffer |
|
267 |
implements Comparable<$Type$Buffer>{#if[char]?, Appendable, CharSequence, Readable} |
|
268 |
{ |
|
269 |
||
270 |
// These fields are declared here rather than in Heap-X-Buffer in order to |
|
271 |
// reduce the number of virtual method invocations needed to access these |
|
272 |
// values, which is especially costly when coding small buffers. |
|
273 |
// |
|
274 |
final $type$[] hb; // Non-null only for heap buffers |
|
275 |
final int offset; |
|
36933
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
276 |
boolean isReadOnly; |
2 | 277 |
|
278 |
// Creates a new buffer with the given mark, position, limit, capacity, |
|
279 |
// backing array, and array offset |
|
280 |
// |
|
281 |
$Type$Buffer(int mark, int pos, int lim, int cap, // package-private |
|
282 |
$type$[] hb, int offset) |
|
283 |
{ |
|
284 |
super(mark, pos, lim, cap); |
|
285 |
this.hb = hb; |
|
286 |
this.offset = offset; |
|
287 |
} |
|
288 |
||
289 |
// Creates a new buffer with the given mark, position, limit, and capacity |
|
290 |
// |
|
291 |
$Type$Buffer(int mark, int pos, int lim, int cap) { // package-private |
|
292 |
this(mark, pos, lim, cap, null, 0); |
|
293 |
} |
|
294 |
||
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
295 |
@Override |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
296 |
Object base() { |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
297 |
return hb; |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
298 |
} |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
299 |
|
2 | 300 |
#if[byte] |
301 |
||
302 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
303 |
* Allocates a new direct $type$ buffer. |
2 | 304 |
* |
305 |
* <p> The new buffer's position will be zero, its limit will be its |
|
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
306 |
* capacity, its mark will be undefined, each of its elements will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
307 |
* initialized to zero, and its byte order will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
308 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. Whether or not it has a |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
309 |
* {@link #hasArray backing array} is unspecified. |
2 | 310 |
* |
311 |
* @param capacity |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
312 |
* The new buffer's capacity, in $type$s |
2 | 313 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
314 |
* @return The new $type$ buffer |
2 | 315 |
* |
316 |
* @throws IllegalArgumentException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
317 |
* If the {@code capacity} is a negative integer |
2 | 318 |
*/ |
319 |
public static $Type$Buffer allocateDirect(int capacity) { |
|
320 |
return new Direct$Type$Buffer(capacity); |
|
321 |
} |
|
322 |
||
323 |
#end[byte] |
|
324 |
||
325 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
326 |
* Allocates a new $type$ buffer. |
2 | 327 |
* |
328 |
* <p> The new buffer's position will be zero, its limit will be its |
|
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
329 |
* capacity, its mark will be undefined, each of its elements will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
330 |
* initialized to zero, and its byte order will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
331 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
332 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
333 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
334 |
* the {@link ByteOrder#nativeOrder native order} of the underlying |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
335 |
* hardware. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
336 |
#end[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
337 |
* It will have a {@link #array backing array}, and its |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
338 |
* {@link #arrayOffset array offset} will be zero. |
2 | 339 |
* |
340 |
* @param capacity |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
341 |
* The new buffer's capacity, in $type$s |
2 | 342 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
343 |
* @return The new $type$ buffer |
2 | 344 |
* |
345 |
* @throws IllegalArgumentException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
346 |
* If the {@code capacity} is a negative integer |
2 | 347 |
*/ |
348 |
public static $Type$Buffer allocate(int capacity) { |
|
349 |
if (capacity < 0) |
|
31873
87b015c2cd36
8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents:
31723
diff
changeset
|
350 |
throw createCapacityException(capacity); |
2 | 351 |
return new Heap$Type$Buffer(capacity, capacity); |
352 |
} |
|
353 |
||
354 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
355 |
* Wraps $a$ $type$ array into a buffer. |
2 | 356 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
357 |
* <p> The new buffer will be backed by the given $type$ array; |
2 | 358 |
* that is, modifications to the buffer will cause the array to be modified |
359 |
* and vice versa. The new buffer's capacity will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
360 |
* {@code array.length}, its position will be {@code offset}, its limit |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
361 |
* will be {@code offset + length}, its mark will be undefined, and its |
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
362 |
* byte order will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
363 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
364 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
365 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
366 |
* the {@link ByteOrder#nativeOrder native order} of the underlying |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
367 |
* hardware. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
368 |
#end[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
369 |
* Its {@link #array backing array} will be the given array, and |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
370 |
* its {@link #arrayOffset array offset} will be zero. </p> |
2 | 371 |
* |
372 |
* @param array |
|
373 |
* The array that will back the new buffer |
|
374 |
* |
|
375 |
* @param offset |
|
376 |
* The offset of the subarray to be used; must be non-negative and |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
377 |
* no larger than {@code array.length}. The new buffer's position |
2 | 378 |
* will be set to this value. |
379 |
* |
|
380 |
* @param length |
|
381 |
* The length of the subarray to be used; |
|
382 |
* must be non-negative and no larger than |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
383 |
* {@code array.length - offset}. |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
384 |
* The new buffer's limit will be set to {@code offset + length}. |
2 | 385 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
386 |
* @return The new $type$ buffer |
2 | 387 |
* |
388 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
389 |
* If the preconditions on the {@code offset} and {@code length} |
2 | 390 |
* parameters do not hold |
391 |
*/ |
|
392 |
public static $Type$Buffer wrap($type$[] array, |
|
393 |
int offset, int length) |
|
394 |
{ |
|
395 |
try { |
|
396 |
return new Heap$Type$Buffer(array, offset, length); |
|
397 |
} catch (IllegalArgumentException x) { |
|
398 |
throw new IndexOutOfBoundsException(); |
|
399 |
} |
|
400 |
} |
|
401 |
||
402 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
403 |
* Wraps $a$ $type$ array into a buffer. |
2 | 404 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
405 |
* <p> The new buffer will be backed by the given $type$ array; |
2 | 406 |
* that is, modifications to the buffer will cause the array to be modified |
407 |
* and vice versa. The new buffer's capacity and limit will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
408 |
* {@code array.length}, its position will be zero, its mark will be |
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
409 |
* undefined, and its byte order will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
410 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
411 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
412 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
413 |
* the {@link ByteOrder#nativeOrder native order} of the underlying |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
414 |
* hardware. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
415 |
#end[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
416 |
* Its {@link #array backing array} will be the given array, and its |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
417 |
* {@link #arrayOffset array offset} will be zero. </p> |
2 | 418 |
* |
419 |
* @param array |
|
420 |
* The array that will back this buffer |
|
421 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
422 |
* @return The new $type$ buffer |
2 | 423 |
*/ |
424 |
public static $Type$Buffer wrap($type$[] array) { |
|
425 |
return wrap(array, 0, array.length); |
|
426 |
} |
|
427 |
||
428 |
#if[char] |
|
429 |
||
430 |
/** |
|
431 |
* Attempts to read characters into the specified character buffer. |
|
432 |
* The buffer is used as a repository of characters as-is: the only |
|
433 |
* changes made are the results of a put operation. No flipping or |
|
434 |
* rewinding of the buffer is performed. |
|
435 |
* |
|
436 |
* @param target the buffer to read characters into |
|
437 |
* @return The number of characters added to the buffer, or |
|
438 |
* -1 if this source of characters is at its end |
|
439 |
* @throws IOException if an I/O error occurs |
|
440 |
* @throws ReadOnlyBufferException if target is a read only buffer |
|
441 |
* @since 1.5 |
|
442 |
*/ |
|
443 |
public int read(CharBuffer target) throws IOException { |
|
444 |
// Determine the number of bytes n that can be transferred |
|
445 |
int targetRemaining = target.remaining(); |
|
446 |
int remaining = remaining(); |
|
447 |
if (remaining == 0) |
|
448 |
return -1; |
|
449 |
int n = Math.min(remaining, targetRemaining); |
|
450 |
int limit = limit(); |
|
451 |
// Set source limit to prevent target overflow |
|
452 |
if (targetRemaining < remaining) |
|
453 |
limit(position() + n); |
|
454 |
try { |
|
455 |
if (n > 0) |
|
456 |
target.put(this); |
|
457 |
} finally { |
|
458 |
limit(limit); // restore real limit |
|
459 |
} |
|
460 |
return n; |
|
461 |
} |
|
462 |
||
463 |
/** |
|
464 |
* Wraps a character sequence into a buffer. |
|
465 |
* |
|
466 |
* <p> The content of the new, read-only buffer will be the content of the |
|
467 |
* given character sequence. The buffer's capacity will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
468 |
* {@code csq.length()}, its position will be {@code start}, its limit |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
469 |
* will be {@code end}, and its mark will be undefined. </p> |
2 | 470 |
* |
471 |
* @param csq |
|
472 |
* The character sequence from which the new character buffer is to |
|
473 |
* be created |
|
474 |
* |
|
475 |
* @param start |
|
476 |
* The index of the first character to be used; |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
477 |
* must be non-negative and no larger than {@code csq.length()}. |
2 | 478 |
* The new buffer's position will be set to this value. |
479 |
* |
|
480 |
* @param end |
|
481 |
* The index of the character following the last character to be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
482 |
* used; must be no smaller than {@code start} and no larger |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
483 |
* than {@code csq.length()}. |
2 | 484 |
* The new buffer's limit will be set to this value. |
485 |
* |
|
486 |
* @return The new character buffer |
|
487 |
* |
|
488 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
489 |
* If the preconditions on the {@code start} and {@code end} |
2 | 490 |
* parameters do not hold |
491 |
*/ |
|
492 |
public static CharBuffer wrap(CharSequence csq, int start, int end) { |
|
493 |
try { |
|
494 |
return new StringCharBuffer(csq, start, end); |
|
495 |
} catch (IllegalArgumentException x) { |
|
496 |
throw new IndexOutOfBoundsException(); |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
/** |
|
501 |
* Wraps a character sequence into a buffer. |
|
502 |
* |
|
503 |
* <p> The content of the new, read-only buffer will be the content of the |
|
504 |
* given character sequence. The new buffer's capacity and limit will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
505 |
* {@code csq.length()}, its position will be zero, and its mark will be |
2 | 506 |
* undefined. </p> |
507 |
* |
|
508 |
* @param csq |
|
509 |
* The character sequence from which the new character buffer is to |
|
510 |
* be created |
|
511 |
* |
|
512 |
* @return The new character buffer |
|
513 |
*/ |
|
514 |
public static CharBuffer wrap(CharSequence csq) { |
|
515 |
return wrap(csq, 0, csq.length()); |
|
516 |
} |
|
517 |
||
518 |
#end[char] |
|
519 |
||
520 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
521 |
* Creates a new $type$ buffer whose content is a shared subsequence of |
2 | 522 |
* this buffer's content. |
523 |
* |
|
524 |
* <p> The content of the new buffer will start at this buffer's current |
|
525 |
* position. Changes to this buffer's content will be visible in the new |
|
526 |
* buffer, and vice versa; the two buffers' position, limit, and mark |
|
527 |
* values will be independent. |
|
528 |
* |
|
529 |
* <p> The new buffer's position will be zero, its capacity and its limit |
|
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
530 |
* will be the number of $type$s remaining in this buffer, its mark will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
531 |
* undefined, and its byte order will be |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
532 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
533 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
534 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
535 |
* identical to that of this buffer. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
536 |
#end[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
537 |
* The new buffer will be direct if, and only if, this buffer is direct, and |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
538 |
* it will be read-only if, and only if, this buffer is read-only. </p> |
2 | 539 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
540 |
* @return The new $type$ buffer |
36933
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
541 |
#if[byte] |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
542 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
543 |
* @see #alignedSlice(int) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
544 |
#end[byte] |
2 | 545 |
*/ |
38321
ff5b89346438
8150785: (bf) Hoist slice and duplicate methods up to java.nio.Buffer
prappo
parents:
36933
diff
changeset
|
546 |
@Override |
2 | 547 |
public abstract $Type$Buffer slice(); |
548 |
||
549 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
550 |
* Creates a new $type$ buffer that shares this buffer's content. |
2 | 551 |
* |
552 |
* <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 |
|
554 |
* versa; the two buffers' position, limit, and mark values will be |
|
555 |
* independent. |
|
556 |
* |
|
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
557 |
* <p> The new buffer's capacity, limit, position, |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
558 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
559 |
* and mark values will be identical to those of this buffer, and its byte |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
560 |
* order will be {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
561 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
562 |
* mark values, and byte order will be identical to those of this buffer. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
563 |
#end[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
564 |
* The new buffer will be direct if, and only if, this buffer is direct, and |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
565 |
* it will be read-only if, and only if, this buffer is read-only. </p> |
2 | 566 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
567 |
* @return The new $type$ buffer |
2 | 568 |
*/ |
38321
ff5b89346438
8150785: (bf) Hoist slice and duplicate methods up to java.nio.Buffer
prappo
parents:
36933
diff
changeset
|
569 |
@Override |
2 | 570 |
public abstract $Type$Buffer duplicate(); |
571 |
||
572 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
573 |
* Creates a new, read-only $type$ buffer that shares this buffer's |
2 | 574 |
* content. |
575 |
* |
|
576 |
* <p> The content of the new buffer will be that of this buffer. Changes |
|
577 |
* to this buffer's content will be visible in the new buffer; the new |
|
578 |
* buffer itself, however, will be read-only and will not allow the shared |
|
579 |
* content to be modified. The two buffers' position, limit, and mark |
|
580 |
* values will be independent. |
|
581 |
* |
|
31723
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
582 |
* <p> The new buffer's capacity, limit, position, |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
583 |
#if[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
584 |
* and mark values will be identical to those of this buffer, and its byte |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
585 |
* order will be {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
586 |
#else[byte] |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
587 |
* mark values, and byte order will be identical to those of this buffer. |
2e16a59cc5cb
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
bpb
parents:
27292
diff
changeset
|
588 |
#end[byte] |
2 | 589 |
* |
590 |
* <p> If this buffer is itself read-only then this method behaves in |
|
591 |
* exactly the same way as the {@link #duplicate duplicate} method. </p> |
|
592 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
593 |
* @return The new, read-only $type$ buffer |
2 | 594 |
*/ |
595 |
public abstract $Type$Buffer asReadOnlyBuffer(); |
|
596 |
||
597 |
||
598 |
// -- Singleton get/put methods -- |
|
599 |
||
600 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
601 |
* Relative <i>get</i> method. Reads the $type$ at this buffer's |
18164 | 602 |
* current position, and then increments the position. |
2 | 603 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
604 |
* @return The $type$ at the buffer's current position |
2 | 605 |
* |
606 |
* @throws BufferUnderflowException |
|
607 |
* If the buffer's current position is not smaller than its limit |
|
608 |
*/ |
|
609 |
public abstract $type$ get(); |
|
610 |
||
611 |
/** |
|
612 |
* Relative <i>put</i> method <i>(optional operation)</i>. |
|
613 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
614 |
* <p> Writes the given $type$ into this buffer at the current |
2 | 615 |
* position, and then increments the position. </p> |
616 |
* |
|
617 |
* @param $x$ |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
618 |
* The $type$ to be written |
2 | 619 |
* |
620 |
* @return This buffer |
|
621 |
* |
|
622 |
* @throws BufferOverflowException |
|
623 |
* If this buffer's current position is not smaller than its limit |
|
624 |
* |
|
625 |
* @throws ReadOnlyBufferException |
|
626 |
* If this buffer is read-only |
|
627 |
*/ |
|
628 |
public abstract $Type$Buffer put($type$ $x$); |
|
629 |
||
630 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
631 |
* Absolute <i>get</i> method. Reads the $type$ at the given |
18164 | 632 |
* index. |
2 | 633 |
* |
634 |
* @param index |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
635 |
* The index from which the $type$ will be read |
2 | 636 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
637 |
* @return The $type$ at the given index |
2 | 638 |
* |
639 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
640 |
* If {@code index} is negative |
2 | 641 |
* or not smaller than the buffer's limit |
642 |
*/ |
|
643 |
public abstract $type$ get(int index); |
|
644 |
||
17922
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
645 |
#if[streamableType] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
646 |
/** |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
647 |
* Absolute <i>get</i> method. Reads the $type$ at the given |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
648 |
* index without any validation of the index. |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
649 |
* |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
650 |
* @param index |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
651 |
* The index from which the $type$ will be read |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
652 |
* |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
653 |
* @return The $type$ at the given index |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
654 |
*/ |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
655 |
abstract $type$ getUnchecked(int index); // package-private |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
656 |
#end[streamableType] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
657 |
|
2 | 658 |
/** |
659 |
* Absolute <i>put</i> method <i>(optional operation)</i>. |
|
660 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
661 |
* <p> Writes the given $type$ into this buffer at the given |
2 | 662 |
* index. </p> |
663 |
* |
|
664 |
* @param index |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
665 |
* The index at which the $type$ will be written |
2 | 666 |
* |
667 |
* @param $x$ |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
668 |
* The $type$ value to be written |
2 | 669 |
* |
670 |
* @return This buffer |
|
671 |
* |
|
672 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
673 |
* If {@code index} is negative |
2 | 674 |
* or not smaller than the buffer's limit |
675 |
* |
|
676 |
* @throws ReadOnlyBufferException |
|
677 |
* If this buffer is read-only |
|
678 |
*/ |
|
679 |
public abstract $Type$Buffer put(int index, $type$ $x$); |
|
680 |
||
681 |
||
682 |
// -- Bulk get operations -- |
|
683 |
||
684 |
/** |
|
685 |
* Relative bulk <i>get</i> method. |
|
686 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
687 |
* <p> This method transfers $type$s from this buffer into the given |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
688 |
* destination array. If there are fewer $type$s remaining in the |
2 | 689 |
* buffer than are required to satisfy the request, that is, if |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
690 |
* {@code length} {@code >} {@code remaining()}, then no |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
691 |
* $type$s are transferred and a {@link BufferUnderflowException} is |
2 | 692 |
* thrown. |
693 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
694 |
* <p> Otherwise, this method copies {@code length} $type$s from this |
2 | 695 |
* buffer into the given array, starting at the current position of this |
696 |
* buffer and at the given offset in the array. The position of this |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
697 |
* buffer is then incremented by {@code length}. |
2 | 698 |
* |
699 |
* <p> In other words, an invocation of this method of the form |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
700 |
* <code>src.get(dst, off, len)</code> has exactly the same effect as |
2 | 701 |
* the loop |
702 |
* |
|
18156 | 703 |
* <pre>{@code |
2 | 704 |
* for (int i = off; i < off + len; i++) |
49953 | 705 |
* dst[i] = src.get(); |
18156 | 706 |
* }</pre> |
2 | 707 |
* |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
708 |
* except that it first checks that there are sufficient $type$s in |
18164 | 709 |
* this buffer and it is potentially much more efficient. |
2 | 710 |
* |
711 |
* @param dst |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
712 |
* The array into which $type$s are to be written |
2 | 713 |
* |
714 |
* @param offset |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
715 |
* The offset within the array of the first $type$ to be |
2 | 716 |
* written; must be non-negative and no larger than |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
717 |
* {@code dst.length} |
2 | 718 |
* |
719 |
* @param length |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
720 |
* The maximum number of $type$s to be written to the given |
2 | 721 |
* array; must be non-negative and no larger than |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
722 |
* {@code dst.length - offset} |
2 | 723 |
* |
724 |
* @return This buffer |
|
725 |
* |
|
726 |
* @throws BufferUnderflowException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
727 |
* If there are fewer than {@code length} $type$s |
2 | 728 |
* remaining in this buffer |
729 |
* |
|
730 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
731 |
* If the preconditions on the {@code offset} and {@code length} |
2 | 732 |
* parameters do not hold |
733 |
*/ |
|
734 |
public $Type$Buffer get($type$[] dst, int offset, int length) { |
|
735 |
checkBounds(offset, length, dst.length); |
|
736 |
if (length > remaining()) |
|
737 |
throw new BufferUnderflowException(); |
|
738 |
int end = offset + length; |
|
739 |
for (int i = offset; i < end; i++) |
|
740 |
dst[i] = get(); |
|
741 |
return this; |
|
742 |
} |
|
743 |
||
744 |
/** |
|
745 |
* Relative bulk <i>get</i> method. |
|
746 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
747 |
* <p> This method transfers $type$s from this buffer into the given |
2 | 748 |
* destination array. An invocation of this method of the form |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
749 |
* {@code src.get(a)} behaves in exactly the same way as the invocation |
2 | 750 |
* |
751 |
* <pre> |
|
752 |
* src.get(a, 0, a.length) </pre> |
|
753 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
754 |
* @param dst |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
755 |
* The destination array |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
756 |
* |
2 | 757 |
* @return This buffer |
758 |
* |
|
759 |
* @throws BufferUnderflowException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
760 |
* If there are fewer than {@code length} $type$s |
2 | 761 |
* remaining in this buffer |
762 |
*/ |
|
763 |
public $Type$Buffer get($type$[] dst) { |
|
764 |
return get(dst, 0, dst.length); |
|
765 |
} |
|
766 |
||
53855 | 767 |
/** |
768 |
* Absolute bulk <i>get</i> method. |
|
769 |
* |
|
770 |
* <p> This method transfers {@code length} $type$s from this |
|
771 |
* buffer into the given array, starting at the given index in this |
|
772 |
* buffer and at the given offset in the array. The position of this |
|
773 |
* buffer is unchanged. |
|
774 |
* |
|
775 |
* <p> An invocation of this method of the form |
|
776 |
* <code>src.get(index, dst, offset, length)</code> |
|
777 |
* has exactly the same effect as the following loop except that it first |
|
778 |
* checks the consistency of the supplied parameters and it is potentially |
|
779 |
* much more efficient: |
|
780 |
* |
|
781 |
* <pre>{@code |
|
782 |
* for (int i = offset, j = index; i < offset + length; i++, j++) |
|
783 |
* dst[i] = src.get(j); |
|
784 |
* }</pre> |
|
785 |
* |
|
786 |
* @param index |
|
787 |
* The index in this buffer from which the first $type$ will be |
|
788 |
* read; must be non-negative and less than {@code limit()} |
|
789 |
* |
|
790 |
* @param dst |
|
791 |
* The destination array |
|
792 |
* |
|
793 |
* @param offset |
|
794 |
* The offset within the array of the first $type$ to be |
|
795 |
* written; must be non-negative and less than |
|
796 |
* {@code dst.length} |
|
797 |
* |
|
798 |
* @param length |
|
799 |
* The number of $type$s to be written to the given array; |
|
800 |
* must be non-negative and no larger than the smaller of |
|
801 |
* {@code limit() - index} and {@code dst.length - offset} |
|
802 |
* |
|
803 |
* @return This buffer |
|
804 |
* |
|
805 |
* @throws IndexOutOfBoundsException |
|
806 |
* If the preconditions on the {@code index}, {@code offset}, and |
|
807 |
* {@code length} parameters do not hold |
|
808 |
* |
|
809 |
* @since 13 |
|
810 |
*/ |
|
811 |
public $Type$Buffer get(int index, $type$[] dst, int offset, int length) { |
|
812 |
Objects.checkFromIndexSize(index, length, limit()); |
|
813 |
Objects.checkFromIndexSize(offset, length, dst.length); |
|
814 |
int end = offset + length; |
|
815 |
for (int i = offset, j = index; i < end; i++, j++) |
|
816 |
dst[i] = get(j); |
|
817 |
return this; |
|
818 |
} |
|
819 |
||
820 |
/** |
|
821 |
* Absolute bulk <i>get</i> method. |
|
822 |
* |
|
823 |
* <p> This method transfers $type$s from this buffer into the given |
|
824 |
* destination array. The position of this buffer is unchanged. An |
|
825 |
* invocation of this method of the form |
|
826 |
* <code>src.get(index, dst)</code> behaves in exactly the same |
|
827 |
* way as the invocation: |
|
828 |
* |
|
829 |
* <pre> |
|
830 |
* src.get(index, dst, 0, dst.length) </pre> |
|
831 |
* |
|
832 |
* @param index |
|
833 |
* The index in this buffer from which the first $type$ will be |
|
834 |
* read; must be non-negative and less than {@code limit()} |
|
835 |
* |
|
836 |
* @param dst |
|
837 |
* The destination array |
|
838 |
* |
|
839 |
* @return This buffer |
|
840 |
* |
|
841 |
* @throws IndexOutOfBoundsException |
|
842 |
* If {@code index} is negative, not smaller than {@code limit()}, |
|
843 |
* or {@code limit() - index < dst.length} |
|
844 |
* |
|
845 |
* @since 13 |
|
846 |
*/ |
|
847 |
public $Type$Buffer get(int index, $type$[] dst) { |
|
848 |
return get(index, dst, 0, dst.length); |
|
849 |
} |
|
2 | 850 |
|
851 |
// -- Bulk put operations -- |
|
852 |
||
853 |
/** |
|
854 |
* Relative bulk <i>put</i> method <i>(optional operation)</i>. |
|
855 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
856 |
* <p> This method transfers the $type$s remaining in the given source |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
857 |
* buffer into this buffer. If there are more $type$s remaining in the |
2 | 858 |
* source buffer than in this buffer, that is, if |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
859 |
* {@code src.remaining()} {@code >} {@code remaining()}, |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
860 |
* then no $type$s are transferred and a {@link |
2 | 861 |
* BufferOverflowException} is thrown. |
862 |
* |
|
863 |
* <p> Otherwise, this method copies |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
864 |
* <i>n</i> = {@code src.remaining()} $type$s from the given |
2 | 865 |
* buffer into this buffer, starting at each buffer's current position. |
866 |
* The positions of both buffers are then incremented by <i>n</i>. |
|
867 |
* |
|
868 |
* <p> In other words, an invocation of this method of the form |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
869 |
* {@code dst.put(src)} has exactly the same effect as the loop |
2 | 870 |
* |
871 |
* <pre> |
|
872 |
* while (src.hasRemaining()) |
|
873 |
* dst.put(src.get()); </pre> |
|
874 |
* |
|
875 |
* except that it first checks that there is sufficient space in this |
|
18164 | 876 |
* buffer and it is potentially much more efficient. |
2 | 877 |
* |
878 |
* @param src |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
879 |
* The source buffer from which $type$s are to be read; |
2 | 880 |
* must not be this buffer |
881 |
* |
|
882 |
* @return This buffer |
|
883 |
* |
|
884 |
* @throws BufferOverflowException |
|
885 |
* If there is insufficient space in this buffer |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
886 |
* for the remaining $type$s in the source buffer |
2 | 887 |
* |
888 |
* @throws IllegalArgumentException |
|
889 |
* If the source buffer is this buffer |
|
890 |
* |
|
891 |
* @throws ReadOnlyBufferException |
|
892 |
* If this buffer is read-only |
|
893 |
*/ |
|
894 |
public $Type$Buffer put($Type$Buffer src) { |
|
895 |
if (src == this) |
|
31873
87b015c2cd36
8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents:
31723
diff
changeset
|
896 |
throw createSameBufferException(); |
14001
e8e8413ad49a
7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents:
13563
diff
changeset
|
897 |
if (isReadOnly()) |
e8e8413ad49a
7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents:
13563
diff
changeset
|
898 |
throw new ReadOnlyBufferException(); |
2 | 899 |
int n = src.remaining(); |
900 |
if (n > remaining()) |
|
901 |
throw new BufferOverflowException(); |
|
902 |
for (int i = 0; i < n; i++) |
|
903 |
put(src.get()); |
|
904 |
return this; |
|
905 |
} |
|
906 |
||
907 |
/** |
|
908 |
* Relative bulk <i>put</i> method <i>(optional operation)</i>. |
|
909 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
910 |
* <p> This method transfers $type$s into this buffer from the given |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
911 |
* source array. If there are more $type$s to be copied from the array |
2 | 912 |
* than remain in this buffer, that is, if |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
913 |
* {@code length} {@code >} {@code remaining()}, then no |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
914 |
* $type$s are transferred and a {@link BufferOverflowException} is |
2 | 915 |
* thrown. |
916 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
917 |
* <p> Otherwise, this method copies {@code length} $type$s from the |
2 | 918 |
* given array into this buffer, starting at the given offset in the array |
919 |
* and at the current position of this buffer. The position of this buffer |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
920 |
* is then incremented by {@code length}. |
2 | 921 |
* |
922 |
* <p> In other words, an invocation of this method of the form |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
923 |
* <code>dst.put(src, off, len)</code> has exactly the same effect as |
2 | 924 |
* the loop |
925 |
* |
|
18156 | 926 |
* <pre>{@code |
2 | 927 |
* for (int i = off; i < off + len; i++) |
53855 | 928 |
* dst.put(src[i]); |
18156 | 929 |
* }</pre> |
2 | 930 |
* |
931 |
* except that it first checks that there is sufficient space in this |
|
18164 | 932 |
* buffer and it is potentially much more efficient. |
2 | 933 |
* |
934 |
* @param src |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
935 |
* The array from which $type$s are to be read |
2 | 936 |
* |
937 |
* @param offset |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
938 |
* The offset within the array of the first $type$ to be read; |
53855 | 939 |
* must be non-negative and no larger than {@code src.length} |
2 | 940 |
* |
941 |
* @param length |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
942 |
* The number of $type$s to be read from the given array; |
2 | 943 |
* must be non-negative and no larger than |
53855 | 944 |
* {@code src.length - offset} |
2 | 945 |
* |
946 |
* @return This buffer |
|
947 |
* |
|
948 |
* @throws BufferOverflowException |
|
949 |
* If there is insufficient space in this buffer |
|
950 |
* |
|
951 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
952 |
* If the preconditions on the {@code offset} and {@code length} |
2 | 953 |
* parameters do not hold |
954 |
* |
|
955 |
* @throws ReadOnlyBufferException |
|
956 |
* If this buffer is read-only |
|
957 |
*/ |
|
958 |
public $Type$Buffer put($type$[] src, int offset, int length) { |
|
959 |
checkBounds(offset, length, src.length); |
|
960 |
if (length > remaining()) |
|
961 |
throw new BufferOverflowException(); |
|
962 |
int end = offset + length; |
|
963 |
for (int i = offset; i < end; i++) |
|
964 |
this.put(src[i]); |
|
965 |
return this; |
|
966 |
} |
|
967 |
||
968 |
/** |
|
969 |
* Relative bulk <i>put</i> method <i>(optional operation)</i>. |
|
970 |
* |
|
971 |
* <p> This method transfers the entire content of the given source |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
972 |
* $type$ array into this buffer. An invocation of this method of the |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
973 |
* form {@code dst.put(a)} behaves in exactly the same way as the |
2 | 974 |
* invocation |
975 |
* |
|
976 |
* <pre> |
|
977 |
* dst.put(a, 0, a.length) </pre> |
|
978 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
979 |
* @param src |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
980 |
* The source array |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
981 |
* |
2 | 982 |
* @return This buffer |
983 |
* |
|
984 |
* @throws BufferOverflowException |
|
985 |
* If there is insufficient space in this buffer |
|
986 |
* |
|
987 |
* @throws ReadOnlyBufferException |
|
988 |
* If this buffer is read-only |
|
989 |
*/ |
|
990 |
public final $Type$Buffer put($type$[] src) { |
|
991 |
return put(src, 0, src.length); |
|
992 |
} |
|
993 |
||
53855 | 994 |
/** |
995 |
* Absolute bulk <i>put</i> method <i>(optional operation)</i>. |
|
996 |
* |
|
997 |
* <p> This method transfers {@code length} $type$s from the given |
|
998 |
* array, starting at the given offset in the array and at the given index |
|
999 |
* in this buffer. The position of this buffer is unchanged. |
|
1000 |
* |
|
1001 |
* <p> An invocation of this method of the form |
|
1002 |
* <code>dst.put(index, src, offset, length)</code> |
|
1003 |
* has exactly the same effect as the following loop except that it first |
|
1004 |
* checks the consistency of the supplied parameters and it is potentially |
|
1005 |
* much more efficient: |
|
1006 |
* |
|
1007 |
* <pre>{@code |
|
1008 |
* for (int i = offset, j = index; i < offset + length; i++, j++) |
|
1009 |
* dst.put(j, src[i]); |
|
1010 |
* }</pre> |
|
1011 |
* |
|
1012 |
* @param index |
|
1013 |
* The index in this buffer at which the first $type$ will be |
|
1014 |
* written; must be non-negative and less than {@code limit()} |
|
1015 |
* |
|
1016 |
* @param src |
|
1017 |
* The array from which $type$s are to be read |
|
1018 |
* |
|
1019 |
* @param offset |
|
1020 |
* The offset within the array of the first $type$ to be read; |
|
1021 |
* must be non-negative and less than {@code src.length} |
|
1022 |
* |
|
1023 |
* @param length |
|
1024 |
* The number of $type$s to be read from the given array; |
|
1025 |
* must be non-negative and no larger than the smaller of |
|
1026 |
* {@code limit() - index} and {@code src.length - offset} |
|
1027 |
* |
|
1028 |
* @return This buffer |
|
1029 |
* |
|
1030 |
* @throws IndexOutOfBoundsException |
|
1031 |
* If the preconditions on the {@code index}, {@code offset}, and |
|
1032 |
* {@code length} parameters do not hold |
|
1033 |
* |
|
1034 |
* @throws ReadOnlyBufferException |
|
1035 |
* If this buffer is read-only |
|
1036 |
* |
|
1037 |
* @since 13 |
|
1038 |
*/ |
|
1039 |
public $Type$Buffer put(int index, $type$[] src, int offset, int length) { |
|
1040 |
if (isReadOnly()) |
|
1041 |
throw new ReadOnlyBufferException(); |
|
1042 |
Objects.checkFromIndexSize(index, length, limit()); |
|
1043 |
Objects.checkFromIndexSize(offset, length, src.length); |
|
1044 |
int end = offset + length; |
|
1045 |
for (int i = offset, j = index; i < end; i++, j++) |
|
1046 |
this.put(j, src[i]); |
|
1047 |
return this; |
|
1048 |
} |
|
1049 |
||
1050 |
/** |
|
1051 |
* Absolute bulk <i>put</i> method <i>(optional operation)</i>. |
|
1052 |
* |
|
1053 |
* <p> This method copies $type$s into this buffer from the given source |
|
1054 |
* array. The position of this buffer is unchanged. An invocation of this |
|
1055 |
* method of the form <code>dst.put(index, src)</code> |
|
1056 |
* behaves in exactly the same way as the invocation: |
|
1057 |
* |
|
1058 |
* <pre> |
|
1059 |
* dst.put(index, src, 0, src.length); </pre> |
|
1060 |
* |
|
1061 |
* @param index |
|
1062 |
* The index in this buffer at which the first $type$ will be |
|
1063 |
* written; must be non-negative and less than {@code limit()} |
|
1064 |
* |
|
1065 |
* @param src |
|
1066 |
* The array from which $type$s are to be read |
|
1067 |
* |
|
1068 |
* @return This buffer |
|
1069 |
* |
|
1070 |
* @throws IndexOutOfBoundsException |
|
1071 |
* If {@code index} is negative, not smaller than {@code limit()}, |
|
1072 |
* or {@code limit() - index < src.length} |
|
1073 |
* |
|
1074 |
* @throws ReadOnlyBufferException |
|
1075 |
* If this buffer is read-only |
|
1076 |
* |
|
1077 |
* @since 13 |
|
1078 |
*/ |
|
1079 |
public $Type$Buffer put(int index, $type$[] src) { |
|
1080 |
return put(index, src, 0, src.length); |
|
1081 |
} |
|
1082 |
||
2 | 1083 |
#if[char] |
1084 |
||
1085 |
/** |
|
1086 |
* Relative bulk <i>put</i> method <i>(optional operation)</i>. |
|
1087 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1088 |
* <p> This method transfers $type$s from the given string into this |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1089 |
* buffer. If there are more $type$s to be copied from the string than |
2 | 1090 |
* remain in this buffer, that is, if |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1091 |
* <code>end - start</code> {@code >} {@code remaining()}, |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1092 |
* then no $type$s are transferred and a {@link |
2 | 1093 |
* BufferOverflowException} is thrown. |
1094 |
* |
|
1095 |
* <p> Otherwise, this method copies |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1096 |
* <i>n</i> = {@code end} - {@code start} $type$s |
2 | 1097 |
* from the given string into this buffer, starting at the given |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1098 |
* {@code start} index and at the current position of this buffer. The |
2 | 1099 |
* position of this buffer is then incremented by <i>n</i>. |
1100 |
* |
|
1101 |
* <p> In other words, an invocation of this method of the form |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1102 |
* <code>dst.put(src, start, end)</code> has exactly the same effect |
2 | 1103 |
* as the loop |
1104 |
* |
|
18156 | 1105 |
* <pre>{@code |
2 | 1106 |
* for (int i = start; i < end; i++) |
18156 | 1107 |
* dst.put(src.charAt(i)); |
1108 |
* }</pre> |
|
2 | 1109 |
* |
1110 |
* except that it first checks that there is sufficient space in this |
|
18164 | 1111 |
* buffer and it is potentially much more efficient. |
2 | 1112 |
* |
1113 |
* @param src |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1114 |
* The string from which $type$s are to be read |
2 | 1115 |
* |
1116 |
* @param start |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1117 |
* The offset within the string of the first $type$ to be read; |
2 | 1118 |
* must be non-negative and no larger than |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1119 |
* {@code string.length()} |
2 | 1120 |
* |
1121 |
* @param end |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1122 |
* The offset within the string of the last $type$ to be read, |
2 | 1123 |
* plus one; must be non-negative and no larger than |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1124 |
* {@code string.length()} |
2 | 1125 |
* |
1126 |
* @return This buffer |
|
1127 |
* |
|
1128 |
* @throws BufferOverflowException |
|
1129 |
* If there is insufficient space in this buffer |
|
1130 |
* |
|
1131 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1132 |
* If the preconditions on the {@code start} and {@code end} |
2 | 1133 |
* parameters do not hold |
1134 |
* |
|
1135 |
* @throws ReadOnlyBufferException |
|
1136 |
* If this buffer is read-only |
|
1137 |
*/ |
|
1138 |
public $Type$Buffer put(String src, int start, int end) { |
|
1139 |
checkBounds(start, end - start, src.length()); |
|
14001
e8e8413ad49a
7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents:
13563
diff
changeset
|
1140 |
if (isReadOnly()) |
e8e8413ad49a
7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
alanb
parents:
13563
diff
changeset
|
1141 |
throw new ReadOnlyBufferException(); |
13563
13c8e8f0302b
7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents:
10137
diff
changeset
|
1142 |
if (end - start > remaining()) |
13c8e8f0302b
7190219: (bf) CharBuffer.put(String,int,int) modifies position even if BufferOverflowException thrown
luchsh
parents:
10137
diff
changeset
|
1143 |
throw new BufferOverflowException(); |
2 | 1144 |
for (int i = start; i < end; i++) |
1145 |
this.put(src.charAt(i)); |
|
1146 |
return this; |
|
1147 |
} |
|
1148 |
||
1149 |
/** |
|
1150 |
* Relative bulk <i>put</i> method <i>(optional operation)</i>. |
|
1151 |
* |
|
1152 |
* <p> This method transfers the entire content of the given source string |
|
1153 |
* into this buffer. An invocation of this method of the form |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1154 |
* {@code dst.put(s)} behaves in exactly the same way as the invocation |
2 | 1155 |
* |
1156 |
* <pre> |
|
1157 |
* dst.put(s, 0, s.length()) </pre> |
|
1158 |
* |
|
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
1159 |
* @param src |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
1160 |
* The source string |
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
1161 |
* |
2 | 1162 |
* @return This buffer |
1163 |
* |
|
1164 |
* @throws BufferOverflowException |
|
1165 |
* If there is insufficient space in this buffer |
|
1166 |
* |
|
1167 |
* @throws ReadOnlyBufferException |
|
1168 |
* If this buffer is read-only |
|
1169 |
*/ |
|
1170 |
public final $Type$Buffer put(String src) { |
|
1171 |
return put(src, 0, src.length()); |
|
1172 |
} |
|
1173 |
||
1174 |
#end[char] |
|
1175 |
||
1176 |
||
1177 |
// -- Other stuff -- |
|
1178 |
||
1179 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1180 |
* Tells whether or not this buffer is backed by an accessible $type$ |
2 | 1181 |
* array. |
1182 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1183 |
* <p> If this method returns {@code true} then the {@link #array() array} |
2 | 1184 |
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked. |
1185 |
* </p> |
|
1186 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1187 |
* @return {@code true} if, and only if, this buffer |
2 | 1188 |
* is backed by an array and is not read-only |
1189 |
*/ |
|
1190 |
public final boolean hasArray() { |
|
1191 |
return (hb != null) && !isReadOnly; |
|
1192 |
} |
|
1193 |
||
1194 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1195 |
* Returns the $type$ array that backs this |
2 | 1196 |
* buffer <i>(optional operation)</i>. |
1197 |
* |
|
1198 |
* <p> Modifications to this buffer's content will cause the returned |
|
1199 |
* array's content to be modified, and vice versa. |
|
1200 |
* |
|
1201 |
* <p> Invoke the {@link #hasArray hasArray} method before invoking this |
|
1202 |
* method in order to ensure that this buffer has an accessible backing |
|
1203 |
* array. </p> |
|
1204 |
* |
|
1205 |
* @return The array that backs this buffer |
|
1206 |
* |
|
1207 |
* @throws ReadOnlyBufferException |
|
1208 |
* If this buffer is backed by an array but is read-only |
|
1209 |
* |
|
1210 |
* @throws UnsupportedOperationException |
|
1211 |
* If this buffer is not backed by an accessible array |
|
1212 |
*/ |
|
1213 |
public final $type$[] array() { |
|
1214 |
if (hb == null) |
|
1215 |
throw new UnsupportedOperationException(); |
|
1216 |
if (isReadOnly) |
|
1217 |
throw new ReadOnlyBufferException(); |
|
1218 |
return hb; |
|
1219 |
} |
|
1220 |
||
1221 |
/** |
|
1222 |
* Returns the offset within this buffer's backing array of the first |
|
1223 |
* element of the buffer <i>(optional operation)</i>. |
|
1224 |
* |
|
1225 |
* <p> If this buffer is backed by an array then buffer position <i>p</i> |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1226 |
* corresponds to array index <i>p</i> + {@code arrayOffset()}. |
2 | 1227 |
* |
1228 |
* <p> Invoke the {@link #hasArray hasArray} method before invoking this |
|
1229 |
* method in order to ensure that this buffer has an accessible backing |
|
1230 |
* array. </p> |
|
1231 |
* |
|
1232 |
* @return The offset within this buffer's array |
|
1233 |
* of the first element of the buffer |
|
1234 |
* |
|
1235 |
* @throws ReadOnlyBufferException |
|
1236 |
* If this buffer is backed by an array but is read-only |
|
1237 |
* |
|
1238 |
* @throws UnsupportedOperationException |
|
1239 |
* If this buffer is not backed by an accessible array |
|
1240 |
*/ |
|
1241 |
public final int arrayOffset() { |
|
1242 |
if (hb == null) |
|
1243 |
throw new UnsupportedOperationException(); |
|
1244 |
if (isReadOnly) |
|
1245 |
throw new ReadOnlyBufferException(); |
|
1246 |
return offset; |
|
1247 |
} |
|
1248 |
||
27292
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1249 |
// -- Covariant return type overrides |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1250 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1251 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1252 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1253 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1254 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1255 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1256 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1257 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1258 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1259 |
$Type$Buffer position(int newPosition) { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1260 |
super.position(newPosition); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1261 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1262 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1263 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1264 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1265 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1266 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1267 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1268 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1269 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1270 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1271 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1272 |
$Type$Buffer limit(int newLimit) { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1273 |
super.limit(newLimit); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1274 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1275 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1276 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1277 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1278 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1279 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1280 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1281 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1282 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1283 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1284 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1285 |
$Type$Buffer mark() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1286 |
super.mark(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1287 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1288 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1289 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1290 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1291 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1292 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1293 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1294 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1295 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1296 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1297 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1298 |
$Type$Buffer reset() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1299 |
super.reset(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1300 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1301 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1302 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1303 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1304 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1305 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1306 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1307 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1308 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1309 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1310 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1311 |
$Type$Buffer clear() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1312 |
super.clear(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1313 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1314 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1315 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1316 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1317 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1318 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1319 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1320 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1321 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1322 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1323 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1324 |
$Type$Buffer flip() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1325 |
super.flip(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1326 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1327 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1328 |
|
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1329 |
/** |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1330 |
* {@inheritDoc} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1331 |
*/ |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1332 |
@Override |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1333 |
public |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1334 |
#if[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1335 |
final |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1336 |
#end[!byte] |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1337 |
$Type$Buffer rewind() { |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1338 |
super.rewind(); |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1339 |
return this; |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1340 |
} |
7ff4b24b33ce
4774077: Use covariant return types in the NIO buffer hierarchy
rwarburton
parents:
26960
diff
changeset
|
1341 |
|
2 | 1342 |
/** |
1343 |
* Compacts this buffer <i>(optional operation)</i>. |
|
1344 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1345 |
* <p> The $type$s between the buffer's current position and its limit, |
2 | 1346 |
* if any, are copied to the beginning of the buffer. That is, the |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1347 |
* $type$ at index <i>p</i> = {@code position()} is copied |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1348 |
* to index zero, the $type$ at index <i>p</i> + 1 is copied |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1349 |
* to index one, and so forth until the $type$ at index |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1350 |
* {@code limit()} - 1 is copied to index |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1351 |
* <i>n</i> = {@code limit()} - {@code 1} - <i>p</i>. |
2 | 1352 |
* The buffer's position is then set to <i>n+1</i> and its limit is set to |
1353 |
* its capacity. The mark, if defined, is discarded. |
|
1354 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1355 |
* <p> The buffer's position is set to the number of $type$s copied, |
2 | 1356 |
* rather than to zero, so that an invocation of this method can be |
1357 |
* followed immediately by an invocation of another relative <i>put</i> |
|
1358 |
* method. </p> |
|
1359 |
* |
|
1360 |
#if[byte] |
|
1361 |
* |
|
1362 |
* <p> Invoke this method after writing data from a buffer in case the |
|
1363 |
* write was incomplete. The following loop, for example, copies bytes |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1364 |
* from one channel to another via the buffer {@code buf}: |
2 | 1365 |
* |
18156 | 1366 |
* <blockquote><pre>{@code |
1367 |
* buf.clear(); // Prepare buffer for use |
|
1368 |
* while (in.read(buf) >= 0 || buf.position != 0) { |
|
1369 |
* buf.flip(); |
|
1370 |
* out.write(buf); |
|
1371 |
* buf.compact(); // In case of partial write |
|
1372 |
* } |
|
2 | 1373 |
* }</pre></blockquote> |
1374 |
* |
|
1375 |
#end[byte] |
|
1376 |
* |
|
1377 |
* @return This buffer |
|
1378 |
* |
|
1379 |
* @throws ReadOnlyBufferException |
|
1380 |
* If this buffer is read-only |
|
1381 |
*/ |
|
1382 |
public abstract $Type$Buffer compact(); |
|
1383 |
||
1384 |
/** |
|
18164 | 1385 |
* Tells whether or not this $type$ buffer is direct. |
2 | 1386 |
* |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1387 |
* @return {@code true} if, and only if, this buffer is direct |
2 | 1388 |
*/ |
1389 |
public abstract boolean isDirect(); |
|
1390 |
||
1391 |
#if[!char] |
|
1392 |
||
1393 |
/** |
|
18164 | 1394 |
* Returns a string summarizing the state of this buffer. |
2 | 1395 |
* |
1396 |
* @return A summary string |
|
1397 |
*/ |
|
1398 |
public String toString() { |
|
1399 |
StringBuffer sb = new StringBuffer(); |
|
1400 |
sb.append(getClass().getName()); |
|
1401 |
sb.append("[pos="); |
|
1402 |
sb.append(position()); |
|
1403 |
sb.append(" lim="); |
|
1404 |
sb.append(limit()); |
|
1405 |
sb.append(" cap="); |
|
1406 |
sb.append(capacity()); |
|
1407 |
sb.append("]"); |
|
1408 |
return sb.toString(); |
|
1409 |
} |
|
1410 |
||
1411 |
#end[!char] |
|
1412 |
||
1413 |
||
1414 |
// ## Should really use unchecked accessors here for speed |
|
1415 |
||
1416 |
/** |
|
1417 |
* Returns the current hash code of this buffer. |
|
1418 |
* |
|
1419 |
* <p> The hash code of a $type$ buffer depends only upon its remaining |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1420 |
* elements; that is, upon the elements from {@code position()} up to, and |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1421 |
* including, the element at {@code limit()} - {@code 1}. |
2 | 1422 |
* |
1423 |
* <p> Because buffer hash codes are content-dependent, it is inadvisable |
|
1424 |
* to use buffers as keys in hash maps or similar data structures unless it |
|
1425 |
* is known that their contents will not change. </p> |
|
1426 |
* |
|
1427 |
* @return The current hash code of this buffer |
|
1428 |
*/ |
|
1429 |
public int hashCode() { |
|
1430 |
int h = 1; |
|
1431 |
int p = position(); |
|
1432 |
for (int i = limit() - 1; i >= p; i--) |
|
10137
d92637d3d673
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
5506
diff
changeset
|
1433 |
#if[int] |
d92637d3d673
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
5506
diff
changeset
|
1434 |
h = 31 * h + get(i); |
d92637d3d673
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
5506
diff
changeset
|
1435 |
#else[int] |
2 | 1436 |
h = 31 * h + (int)get(i); |
10137
d92637d3d673
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
jjg
parents:
5506
diff
changeset
|
1437 |
#end[int] |
2 | 1438 |
return h; |
1439 |
} |
|
1440 |
||
1441 |
/** |
|
1442 |
* Tells whether or not this buffer is equal to another object. |
|
1443 |
* |
|
1444 |
* <p> Two $type$ buffers are equal if, and only if, |
|
1445 |
* |
|
21334 | 1446 |
* <ol> |
2 | 1447 |
* |
1448 |
* <li><p> They have the same element type, </p></li> |
|
1449 |
* |
|
1450 |
* <li><p> They have the same number of remaining elements, and |
|
1451 |
* </p></li> |
|
1452 |
* |
|
1453 |
* <li><p> The two sequences of remaining elements, considered |
|
1454 |
* independently of their starting positions, are pointwise equal. |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1455 |
#if[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1456 |
* This method considers two $type$ elements {@code a} and {@code b} |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1457 |
* to be equal if |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1458 |
* {@code (a == b) || ($Fulltype$.isNaN(a) && $Fulltype$.isNaN(b))}. |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1459 |
* The values {@code -0.0} and {@code +0.0} are considered to be |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1460 |
* equal, unlike {@link $Fulltype$#equals(Object)}. |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1461 |
#end[floatingPointType] |
2 | 1462 |
* </p></li> |
1463 |
* |
|
1464 |
* </ol> |
|
1465 |
* |
|
1466 |
* <p> A $type$ buffer is not equal to any other type of object. </p> |
|
1467 |
* |
|
1468 |
* @param ob The object to which this buffer is to be compared |
|
1469 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1470 |
* @return {@code true} if, and only if, this buffer is equal to the |
2 | 1471 |
* given object |
1472 |
*/ |
|
1473 |
public boolean equals(Object ob) { |
|
1474 |
if (this == ob) |
|
1475 |
return true; |
|
1476 |
if (!(ob instanceof $Type$Buffer)) |
|
1477 |
return false; |
|
1478 |
$Type$Buffer that = ($Type$Buffer)ob; |
|
1479 |
if (this.remaining() != that.remaining()) |
|
1480 |
return false; |
|
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1481 |
return BufferMismatch.mismatch(this, this.position(), |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1482 |
that, that.position(), |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1483 |
this.remaining()) < 0; |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1484 |
} |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1485 |
|
2 | 1486 |
/** |
1487 |
* Compares this buffer to another. |
|
1488 |
* |
|
1489 |
* <p> Two $type$ buffers are compared by comparing their sequences of |
|
1490 |
* remaining elements lexicographically, without regard to the starting |
|
1491 |
* position of each sequence within its corresponding buffer. |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1492 |
#if[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1493 |
* Pairs of {@code $type$} elements are compared as if by invoking |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1494 |
* {@link $Fulltype$#compare($type$,$type$)}, except that |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1495 |
* {@code -0.0} and {@code 0.0} are considered to be equal. |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1496 |
* {@code $Fulltype$.NaN} is considered by this method to be equal |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1497 |
* to itself and greater than all other {@code $type$} values |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1498 |
* (including {@code $Fulltype$.POSITIVE_INFINITY}). |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1499 |
#else[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1500 |
* Pairs of {@code $type$} elements are compared as if by invoking |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1501 |
* {@link $Fulltype$#compare($type$,$type$)}. |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1502 |
#end[floatingPointType] |
2 | 1503 |
* |
1504 |
* <p> A $type$ buffer is not comparable to any other type of object. |
|
1505 |
* |
|
1506 |
* @return A negative integer, zero, or a positive integer as this buffer |
|
1507 |
* is less than, equal to, or greater than the given buffer |
|
1508 |
*/ |
|
1509 |
public int compareTo($Type$Buffer that) { |
|
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1510 |
int i = BufferMismatch.mismatch(this, this.position(), |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1511 |
that, that.position(), |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1512 |
Math.min(this.remaining(), that.remaining())); |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1513 |
if (i >= 0) { |
49282
271ef464fb3a
8199773: (bf) XXXBuffer:compareTo method is not working as expected
psandoz
parents:
49210
diff
changeset
|
1514 |
return compare(this.get(this.position() + i), that.get(that.position() + i)); |
2 | 1515 |
} |
1516 |
return this.remaining() - that.remaining(); |
|
1517 |
} |
|
1518 |
||
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1519 |
private static int compare($type$ x, $type$ y) { |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1520 |
#if[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1521 |
return ((x < y) ? -1 : |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1522 |
(x > y) ? +1 : |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1523 |
(x == y) ? 0 : |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1524 |
$Fulltype$.isNaN(x) ? ($Fulltype$.isNaN(y) ? 0 : +1) : -1); |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1525 |
#else[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1526 |
return $Fulltype$.compare(x, y); |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1527 |
#end[floatingPointType] |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1528 |
} |
2 | 1529 |
|
50596 | 1530 |
/** |
1531 |
* Finds and returns the relative index of the first mismatch between this |
|
1532 |
* buffer and a given buffer. The index is relative to the |
|
1533 |
* {@link #position() position} of each buffer and will be in the range of |
|
1534 |
* 0 (inclusive) up to the smaller of the {@link #remaining() remaining} |
|
1535 |
* elements in each buffer (exclusive). |
|
1536 |
* |
|
1537 |
* <p> If the two buffers share a common prefix then the returned index is |
|
1538 |
* the length of the common prefix and it follows that there is a mismatch |
|
1539 |
* between the two buffers at that index within the respective buffers. |
|
1540 |
* If one buffer is a proper prefix of the other then the returned index is |
|
1541 |
* the smaller of the remaining elements in each buffer, and it follows that |
|
1542 |
* the index is only valid for the buffer with the larger number of |
|
1543 |
* remaining elements. |
|
1544 |
* Otherwise, there is no mismatch. |
|
1545 |
* |
|
1546 |
* @param that |
|
1547 |
* The byte buffer to be tested for a mismatch with this buffer |
|
1548 |
* |
|
1549 |
* @return The relative index of the first mismatch between this and the |
|
1550 |
* given buffer, otherwise -1 if no mismatch. |
|
1551 |
* |
|
1552 |
* @since 11 |
|
1553 |
*/ |
|
1554 |
public int mismatch($Type$Buffer that) { |
|
1555 |
int length = Math.min(this.remaining(), that.remaining()); |
|
1556 |
int r = BufferMismatch.mismatch(this, this.position(), |
|
1557 |
that, that.position(), |
|
1558 |
length); |
|
1559 |
return (r == -1 && this.remaining() != that.remaining()) ? length : r; |
|
1560 |
} |
|
1561 |
||
2 | 1562 |
// -- Other char stuff -- |
1563 |
||
1564 |
#if[char] |
|
1565 |
||
1566 |
/** |
|
1567 |
* Returns a string containing the characters in this buffer. |
|
1568 |
* |
|
1569 |
* <p> The first character of the resulting string will be the character at |
|
1570 |
* this buffer's position, while the last character will be the character |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1571 |
* at index {@code limit()} - 1. Invoking this method does not |
2 | 1572 |
* change the buffer's position. </p> |
1573 |
* |
|
1574 |
* @return The specified string |
|
1575 |
*/ |
|
1576 |
public String toString() { |
|
1577 |
return toString(position(), limit()); |
|
1578 |
} |
|
1579 |
||
1580 |
abstract String toString(int start, int end); // package-private |
|
1581 |
||
1582 |
||
1583 |
// --- Methods to support CharSequence --- |
|
1584 |
||
1585 |
/** |
|
1586 |
* Returns the length of this character buffer. |
|
1587 |
* |
|
1588 |
* <p> When viewed as a character sequence, the length of a character |
|
1589 |
* buffer is simply the number of characters between the position |
|
1590 |
* (inclusive) and the limit (exclusive); that is, it is equivalent to |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1591 |
* {@code remaining()}. </p> |
2 | 1592 |
* |
1593 |
* @return The length of this character buffer |
|
1594 |
*/ |
|
1595 |
public final int length() { |
|
1596 |
return remaining(); |
|
1597 |
} |
|
1598 |
||
1599 |
/** |
|
1600 |
* Reads the character at the given index relative to the current |
|
18164 | 1601 |
* position. |
2 | 1602 |
* |
1603 |
* @param index |
|
1604 |
* The index of the character to be read, relative to the position; |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1605 |
* must be non-negative and smaller than {@code remaining()} |
2 | 1606 |
* |
1607 |
* @return The character at index |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1608 |
* <code>position() + index</code> |
2 | 1609 |
* |
1610 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1611 |
* If the preconditions on {@code index} do not hold |
2 | 1612 |
*/ |
1613 |
public final char charAt(int index) { |
|
1614 |
return get(position() + checkIndex(index, 1)); |
|
1615 |
} |
|
1616 |
||
1617 |
/** |
|
1618 |
* Creates a new character buffer that represents the specified subsequence |
|
1619 |
* of this buffer, relative to the current position. |
|
1620 |
* |
|
1621 |
* <p> The new buffer will share this buffer's content; that is, if the |
|
1622 |
* content of this buffer is mutable then modifications to one buffer will |
|
1623 |
* cause the other to be modified. The new buffer's capacity will be that |
|
1624 |
* of this buffer, its position will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1625 |
* {@code position()} + {@code start}, and its limit will be |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1626 |
* {@code position()} + {@code end}. The new buffer will be |
2 | 1627 |
* direct if, and only if, this buffer is direct, and it will be read-only |
1628 |
* if, and only if, this buffer is read-only. </p> |
|
1629 |
* |
|
1630 |
* @param start |
|
1631 |
* The index, relative to the current position, of the first |
|
1632 |
* character in the subsequence; must be non-negative and no larger |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1633 |
* than {@code remaining()} |
2 | 1634 |
* |
1635 |
* @param end |
|
1636 |
* The index, relative to the current position, of the character |
|
1637 |
* following the last character in the subsequence; must be no |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1638 |
* smaller than {@code start} and no larger than |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1639 |
* {@code remaining()} |
2 | 1640 |
* |
1224
8c1bc7c5dd00
6733145: (bf) CharBuffer.subSequence can be updated to take advantage of covariant returns
martin
parents:
2
diff
changeset
|
1641 |
* @return The new character buffer |
2 | 1642 |
* |
1643 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1644 |
* If the preconditions on {@code start} and {@code end} |
2 | 1645 |
* do not hold |
1646 |
*/ |
|
1224
8c1bc7c5dd00
6733145: (bf) CharBuffer.subSequence can be updated to take advantage of covariant returns
martin
parents:
2
diff
changeset
|
1647 |
public abstract CharBuffer subSequence(int start, int end); |
2 | 1648 |
|
1649 |
||
1650 |
// --- Methods to support Appendable --- |
|
1651 |
||
1652 |
/** |
|
1653 |
* Appends the specified character sequence to this |
|
1654 |
* buffer <i>(optional operation)</i>. |
|
1655 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1656 |
* <p> An invocation of this method of the form {@code dst.append(csq)} |
2 | 1657 |
* behaves in exactly the same way as the invocation |
1658 |
* |
|
1659 |
* <pre> |
|
1660 |
* dst.put(csq.toString()) </pre> |
|
1661 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1662 |
* <p> Depending on the specification of {@code toString} for the |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1663 |
* character sequence {@code csq}, the entire sequence may not be |
2 | 1664 |
* appended. For instance, invoking the {@link $Type$Buffer#toString() |
1665 |
* toString} method of a character buffer will return a subsequence whose |
|
1666 |
* content depends upon the buffer's position and limit. |
|
1667 |
* |
|
1668 |
* @param csq |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1669 |
* The character sequence to append. If {@code csq} is |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1670 |
* {@code null}, then the four characters {@code "null"} are |
2 | 1671 |
* appended to this character buffer. |
1672 |
* |
|
1673 |
* @return This buffer |
|
1674 |
* |
|
1675 |
* @throws BufferOverflowException |
|
1676 |
* If there is insufficient space in this buffer |
|
1677 |
* |
|
1678 |
* @throws ReadOnlyBufferException |
|
1679 |
* If this buffer is read-only |
|
1680 |
* |
|
1681 |
* @since 1.5 |
|
1682 |
*/ |
|
1683 |
public $Type$Buffer append(CharSequence csq) { |
|
1684 |
if (csq == null) |
|
1685 |
return put("null"); |
|
1686 |
else |
|
1687 |
return put(csq.toString()); |
|
1688 |
} |
|
1689 |
||
1690 |
/** |
|
1691 |
* Appends a subsequence of the specified character sequence to this |
|
1692 |
* buffer <i>(optional operation)</i>. |
|
1693 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1694 |
* <p> An invocation of this method of the form {@code dst.append(csq, start, |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1695 |
* end)} when {@code csq} is not {@code null}, behaves in exactly the |
2 | 1696 |
* same way as the invocation |
1697 |
* |
|
1698 |
* <pre> |
|
1699 |
* dst.put(csq.subSequence(start, end).toString()) </pre> |
|
1700 |
* |
|
1701 |
* @param csq |
|
1702 |
* The character sequence from which a subsequence will be |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1703 |
* appended. If {@code csq} is {@code null}, then characters |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1704 |
* will be appended as if {@code csq} contained the four |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1705 |
* characters {@code "null"}. |
2 | 1706 |
* |
1707 |
* @return This buffer |
|
1708 |
* |
|
1709 |
* @throws BufferOverflowException |
|
1710 |
* If there is insufficient space in this buffer |
|
1711 |
* |
|
1712 |
* @throws IndexOutOfBoundsException |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1713 |
* If {@code start} or {@code end} are negative, {@code start} |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1714 |
* is greater than {@code end}, or {@code end} is greater than |
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1715 |
* {@code csq.length()} |
2 | 1716 |
* |
1717 |
* @throws ReadOnlyBufferException |
|
1718 |
* If this buffer is read-only |
|
1719 |
* |
|
1720 |
* @since 1.5 |
|
1721 |
*/ |
|
1722 |
public $Type$Buffer append(CharSequence csq, int start, int end) { |
|
1723 |
CharSequence cs = (csq == null ? "null" : csq); |
|
1724 |
return put(cs.subSequence(start, end).toString()); |
|
1725 |
} |
|
1726 |
||
1727 |
/** |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1728 |
* Appends the specified $type$ to this |
2 | 1729 |
* buffer <i>(optional operation)</i>. |
1730 |
* |
|
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1731 |
* <p> An invocation of this method of the form {@code dst.append($x$)} |
2 | 1732 |
* behaves in exactly the same way as the invocation |
1733 |
* |
|
1734 |
* <pre> |
|
1735 |
* dst.put($x$) </pre> |
|
1736 |
* |
|
1737 |
* @param $x$ |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1738 |
* The 16-bit $type$ to append |
2 | 1739 |
* |
1740 |
* @return This buffer |
|
1741 |
* |
|
1742 |
* @throws BufferOverflowException |
|
1743 |
* If there is insufficient space in this buffer |
|
1744 |
* |
|
1745 |
* @throws ReadOnlyBufferException |
|
1746 |
* If this buffer is read-only |
|
1747 |
* |
|
1748 |
* @since 1.5 |
|
1749 |
*/ |
|
1750 |
public $Type$Buffer append($type$ $x$) { |
|
1751 |
return put($x$); |
|
1752 |
} |
|
1753 |
||
1754 |
#end[char] |
|
1755 |
||
1756 |
||
1757 |
// -- Other byte stuff: Access to binary data -- |
|
1758 |
||
1759 |
#if[!byte] |
|
1760 |
||
1761 |
/** |
|
1762 |
* Retrieves this buffer's byte order. |
|
1763 |
* |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1764 |
* <p> The byte order of $a$ $type$ buffer created by allocation or by |
32143
394ab6a6658d
8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents:
31873
diff
changeset
|
1765 |
* wrapping an existing {@code $type$} array is the {@link |
18574
4aeaeb541678
8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents:
18164
diff
changeset
|
1766 |
* ByteOrder#nativeOrder native order} of the underlying |
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
1767 |
* hardware. The byte order of $a$ $type$ buffer created as a <a |
2 | 1768 |
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the |
1769 |
* byte buffer at the moment that the view is created. </p> |
|
1770 |
* |
|
1771 |
* @return This buffer's byte order |
|
1772 |
*/ |
|
1773 |
public abstract ByteOrder order(); |
|
1774 |
||
1775 |
#end[!byte] |
|
1776 |
||
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1777 |
#if[char] |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1778 |
// The order or null if the buffer does not cover a memory region, |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1779 |
// such as StringCharBuffer |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1780 |
abstract ByteOrder charRegionOrder(); |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1781 |
#end[char] |
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
1782 |
|
2 | 1783 |
#if[byte] |
1784 |
||
1785 |
boolean bigEndian // package-private |
|
1786 |
= true; |
|
1787 |
boolean nativeByteOrder // package-private |
|
49581
bd45ce23b1ac
8201494: Avoid early initialization of java.nio.Bits
redestad
parents:
49282
diff
changeset
|
1788 |
= (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN); |
2 | 1789 |
|
1790 |
/** |
|
1791 |
* Retrieves this buffer's byte order. |
|
1792 |
* |
|
1793 |
* <p> The byte order is used when reading or writing multibyte values, and |
|
1794 |
* when creating buffers that are views of this byte buffer. The order of |
|
1795 |
* a newly-created byte buffer is always {@link ByteOrder#BIG_ENDIAN |
|
1796 |
* BIG_ENDIAN}. </p> |
|
1797 |
* |
|
1798 |
* @return This buffer's byte order |
|
1799 |
*/ |
|
1800 |
public final ByteOrder order() { |
|
1801 |
return bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; |
|
1802 |
} |
|
1803 |
||
1804 |
/** |
|
18164 | 1805 |
* Modifies this buffer's byte order. |
2 | 1806 |
* |
1807 |
* @param bo |
|
1808 |
* The new byte order, |
|
1809 |
* either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} |
|
1810 |
* or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} |
|
1811 |
* |
|
1812 |
* @return This buffer |
|
1813 |
*/ |
|
1814 |
public final $Type$Buffer order(ByteOrder bo) { |
|
1815 |
bigEndian = (bo == ByteOrder.BIG_ENDIAN); |
|
1816 |
nativeByteOrder = |
|
49581
bd45ce23b1ac
8201494: Avoid early initialization of java.nio.Bits
redestad
parents:
49282
diff
changeset
|
1817 |
(bigEndian == (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)); |
2 | 1818 |
return this; |
1819 |
} |
|
1820 |
||
36933
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1821 |
/** |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1822 |
* Returns the memory address, pointing to the byte at the given index, |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1823 |
* modulus the given unit size. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1824 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1825 |
* <p> A return value greater than zero indicates the address of the byte at |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1826 |
* the index is misaligned for the unit size, and the value's quantity |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1827 |
* indicates how much the index should be rounded up or down to locate a |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1828 |
* byte at an aligned address. Otherwise, a value of {@code 0} indicates |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1829 |
* that the address of the byte at the index is aligned for the unit size. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1830 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1831 |
* @apiNote |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1832 |
* This method may be utilized to determine if unit size bytes from an |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1833 |
* index can be accessed atomically, if supported by the native platform. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1834 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1835 |
* @implNote |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1836 |
* This implementation throws {@code UnsupportedOperationException} for |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1837 |
* non-direct buffers when the given unit size is greater then {@code 8}. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1838 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1839 |
* @param index |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1840 |
* The index to query for alignment offset, must be non-negative, no |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1841 |
* upper bounds check is performed |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1842 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1843 |
* @param unitSize |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1844 |
* The unit size in bytes, must be a power of {@code 2} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1845 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1846 |
* @return The indexed byte's memory address modulus the unit size |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1847 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1848 |
* @throws IllegalArgumentException |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1849 |
* If the index is negative or the unit size is not a power of |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1850 |
* {@code 2} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1851 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1852 |
* @throws UnsupportedOperationException |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1853 |
* If the native platform does not guarantee stable alignment offset |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1854 |
* values for the given unit size when managing the memory regions |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1855 |
* of buffers of the same kind as this buffer (direct or |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1856 |
* non-direct). For example, if garbage collection would result |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1857 |
* in the moving of a memory region covered by a non-direct buffer |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1858 |
* from one location to another and both locations have different |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1859 |
* alignment characteristics. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1860 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1861 |
* @see #alignedSlice(int) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1862 |
* @since 9 |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1863 |
*/ |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1864 |
public final int alignmentOffset(int index, int unitSize) { |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1865 |
if (index < 0) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1866 |
throw new IllegalArgumentException("Index less than zero: " + index); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1867 |
if (unitSize < 1 || (unitSize & (unitSize - 1)) != 0) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1868 |
throw new IllegalArgumentException("Unit size not a power of two: " + unitSize); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1869 |
if (unitSize > 8 && !isDirect()) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1870 |
throw new UnsupportedOperationException("Unit size unsupported for non-direct buffers: " + unitSize); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1871 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1872 |
return (int) ((address + index) % unitSize); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1873 |
} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1874 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1875 |
/** |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1876 |
* Creates a new byte buffer whose content is a shared and aligned |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1877 |
* subsequence of this buffer's content. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1878 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1879 |
* <p> The content of the new buffer will start at this buffer's current |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1880 |
* position rounded up to the index of the nearest aligned byte for the |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1881 |
* given unit size, and end at this buffer's limit rounded down to the index |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1882 |
* of the nearest aligned byte for the given unit size. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1883 |
* If rounding results in out-of-bound values then the new buffer's capacity |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1884 |
* and limit will be zero. If rounding is within bounds the following |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1885 |
* expressions will be true for a new buffer {@code nb} and unit size |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1886 |
* {@code unitSize}: |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1887 |
* <pre>{@code |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1888 |
* nb.alignmentOffset(0, unitSize) == 0 |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1889 |
* nb.alignmentOffset(nb.limit(), unitSize) == 0 |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1890 |
* }</pre> |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1891 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1892 |
* <p> Changes to this buffer's content will be visible in the new |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1893 |
* buffer, and vice versa; the two buffers' position, limit, and mark |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1894 |
* values will be independent. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1895 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1896 |
* <p> The new buffer's position will be zero, its capacity and its limit |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1897 |
* will be the number of bytes remaining in this buffer or fewer subject to |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1898 |
* alignment, its mark will be undefined, and its byte order will be |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1899 |
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1900 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1901 |
* The new buffer will be direct if, and only if, this buffer is direct, and |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1902 |
* it will be read-only if, and only if, this buffer is read-only. </p> |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1903 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1904 |
* @apiNote |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1905 |
* This method may be utilized to create a new buffer where unit size bytes |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1906 |
* from index, that is a multiple of the unit size, may be accessed |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1907 |
* atomically, if supported by the native platform. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1908 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1909 |
* @implNote |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1910 |
* This implementation throws {@code UnsupportedOperationException} for |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1911 |
* non-direct buffers when the given unit size is greater then {@code 8}. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1912 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1913 |
* @param unitSize |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1914 |
* The unit size in bytes, must be a power of {@code 2} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1915 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1916 |
* @return The new byte buffer |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1917 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1918 |
* @throws IllegalArgumentException |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1919 |
* If the unit size not a power of {@code 2} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1920 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1921 |
* @throws UnsupportedOperationException |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1922 |
* If the native platform does not guarantee stable aligned slices |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1923 |
* for the given unit size when managing the memory regions |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1924 |
* of buffers of the same kind as this buffer (direct or |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1925 |
* non-direct). For example, if garbage collection would result |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1926 |
* in the moving of a memory region covered by a non-direct buffer |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1927 |
* from one location to another and both locations have different |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1928 |
* alignment characteristics. |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1929 |
* |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1930 |
* @see #alignmentOffset(int, int) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1931 |
* @see #slice() |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1932 |
* @since 9 |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1933 |
*/ |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1934 |
public final ByteBuffer alignedSlice(int unitSize) { |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1935 |
int pos = position(); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1936 |
int lim = limit(); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1937 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1938 |
int pos_mod = alignmentOffset(pos, unitSize); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1939 |
int lim_mod = alignmentOffset(lim, unitSize); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1940 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1941 |
// Round up the position to align with unit size |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1942 |
int aligned_pos = (pos_mod > 0) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1943 |
? pos + (unitSize - pos_mod) |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1944 |
: pos; |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1945 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1946 |
// Round down the limit to align with unit size |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1947 |
int aligned_lim = lim - lim_mod; |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1948 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1949 |
if (aligned_pos > lim || aligned_lim < pos) { |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1950 |
aligned_pos = aligned_lim = pos; |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1951 |
} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1952 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1953 |
return slice(aligned_pos, aligned_lim); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1954 |
} |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1955 |
|
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1956 |
abstract ByteBuffer slice(int pos, int lim); |
3e6453e2d833
8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents:
35302
diff
changeset
|
1957 |
|
2 | 1958 |
// #BIN |
1959 |
// |
|
1960 |
// Binary-data access methods for short, char, int, long, float, |
|
1961 |
// and double will be inserted here |
|
1962 |
||
1963 |
#end[byte] |
|
1964 |
||
17922
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1965 |
#if[streamableType] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1966 |
|
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1967 |
#if[char] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1968 |
@Override |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1969 |
#end[char] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1970 |
public $Streamtype$Stream $type$s() { |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1971 |
return StreamSupport.$streamtype$Stream(() -> new $Type$BufferSpliterator(this), |
18822
4b6be7c19547
8019395: Consolidate StreamSupport.{stream,parallelStream} into a single method
psandoz
parents:
18574
diff
changeset
|
1972 |
Buffer.SPLITERATOR_CHARACTERISTICS, false); |
17922
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1973 |
} |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1974 |
|
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1975 |
#end[streamableType] |
d56eec572de5
8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents:
14342
diff
changeset
|
1976 |
|
2 | 1977 |
} |