Showing the changes to java (84 of 84 files). Show all
Unified · Split
| @@ -571,20 +571,24 @@ class Bits { // package-private · 570 unmodified lines | ||
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | static { |
| 574 | − long a = unsafe.allocateMemory(8); | |
| 575 | − try { | |
| 576 | − unsafe.putLong(a, 0x0102030405060708L); | |
| 577 | − byte b = unsafe.getByte(a); | |
| 578 | − switch (b) { | |
| 579 | − case 0x01: byteOrder = ByteOrder.BIG_ENDIAN; break; | |
| 580 | − case 0x08: byteOrder = ByteOrder.LITTLE_ENDIAN; break; | |
| 581 | − default: | |
| 582 | − assert false; | |
| 583 | − byteOrder = null; | |
| 584 | − } | |
| 585 | − } finally { | |
| 586 | − unsafe.freeMemory(a); | |
| 587 | − } | |
| 574 | + // [Inferno] < | |
| 575 | + //long a = unsafe.allocateMemory(8); | |
| 576 | + //try { | |
| 577 | + // unsafe.putLong(a, 0x0102030405060708L); | |
| 578 | + // byte b = unsafe.getByte(a); | |
| 579 | + // switch (b) { | |
| 580 | + // case 0x01: byteOrder = ByteOrder.BIG_ENDIAN; break; | |
| 581 | + // case 0x08: byteOrder = ByteOrder.LITTLE_ENDIAN; break; | |
| 582 | + // default: | |
| 583 | + // assert false; | |
| 584 | + // byteOrder = null; | |
| 585 | + // } | |
| 586 | + //} finally { | |
| 587 | + // unsafe.freeMemory(a); | |
| 588 | + //} | |
| 589 | + // [Inferno] = | |
| 590 | + byteOrder = ByteOrder.LITTLE_ENDIAN; | |
| 591 | + // [Inferno] > | |
| 588 | 592 | } |
| 589 | 593 | |
| 590 | 594 | |
| @@ -0,0 +1,65 @@ | ||
| 1 | +implement Bits_L; | |
| 2 | + | |
| 3 | +include "jni.m"; | |
| 4 | + jni : JNI; | |
| 5 | + ClassModule, | |
| 6 | + JString, | |
| 7 | + JArray, | |
| 8 | + JArrayI, | |
| 9 | + JArrayC, | |
| 10 | + JArrayB, | |
| 11 | + JArrayS, | |
| 12 | + JArrayJ, | |
| 13 | + JArrayF, | |
| 14 | + JArrayD, | |
| 15 | + JArrayZ, | |
| 16 | + JArrayJObject, | |
| 17 | + JArrayJClass, | |
| 18 | + JArrayJString, | |
| 19 | + JClass, | |
| 20 | + JObject : import jni; | |
| 21 | + | |
| 22 | +#>> extra pre includes here | |
| 23 | + | |
| 24 | +#<< | |
| 25 | + | |
| 26 | +include "Bits_L.m"; | |
| 27 | + | |
| 28 | +#>> extra post includes here | |
| 29 | + | |
| 30 | +#<< | |
| 31 | + | |
| 32 | +init( jni_p : JNI ) | |
| 33 | +{ | |
| 34 | + # save java native inteface mod instance | |
| 35 | + jni = jni_p; | |
| 36 | + #>>extra initialization here | |
| 37 | + #<< | |
| 38 | +} | |
| 39 | + | |
| 40 | +# TODO: implement this | |
| 41 | + | |
| 42 | +copyFromShortArray_rObject_J_J_J_V( p0 : JObject,p1 : big,p2 : big,p3 : big) | |
| 43 | +{#>> | |
| 44 | +}#<< | |
| 45 | + | |
| 46 | +copyToShortArray_J_rObject_J_J_V( p0 : big,p1 : JObject,p2 : big,p3 : big) | |
| 47 | +{#>> | |
| 48 | +}#<< | |
| 49 | + | |
| 50 | +copyFromIntArray_rObject_J_J_J_V( p0 : JObject,p1 : big,p2 : big,p3 : big) | |
| 51 | +{#>> | |
| 52 | +}#<< | |
| 53 | + | |
| 54 | +copyToIntArray_J_rObject_J_J_V( p0 : big,p1 : JObject,p2 : big,p3 : big) | |
| 55 | +{#>> | |
| 56 | +}#<< | |
| 57 | + | |
| 58 | +copyFromLongArray_rObject_J_J_J_V( p0 : JObject,p1 : big,p2 : big,p3 : big) | |
| 59 | +{#>> | |
| 60 | +}#<< | |
| 61 | + | |
| 62 | +copyToLongArray_J_rObject_J_J_V( p0 : big,p1 : JObject,p2 : big,p3 : big) | |
| 63 | +{#>> | |
| 64 | +}#<< | |
| 65 | + | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +# generated file edit with care | |
| 2 | + | |
| 3 | +Bits_L : module | |
| 4 | +{ | |
| 5 | + Bits_obj : adt | |
| 6 | + { | |
| 7 | + cl_mod : ClassModule; | |
| 8 | + }; | |
| 9 | + | |
| 10 | + init : fn( jni_p : JNI ); | |
| 11 | + copyFromShortArray_rObject_J_J_J_V : fn( p0 : JObject,p1 : big,p2 : big,p3 : big); | |
| 12 | + copyToShortArray_J_rObject_J_J_V : fn( p0 : big,p1 : JObject,p2 : big,p3 : big); | |
| 13 | + copyFromIntArray_rObject_J_J_J_V : fn( p0 : JObject,p1 : big,p2 : big,p3 : big); | |
| 14 | + copyToIntArray_J_rObject_J_J_V : fn( p0 : big,p1 : JObject,p2 : big,p3 : big); | |
| 15 | + copyFromLongArray_rObject_J_J_J_V : fn( p0 : JObject,p1 : big,p2 : big,p3 : big); | |
| 16 | + copyToLongArray_J_rObject_J_J_V : fn( p0 : big,p1 : JObject,p2 : big,p3 : big); | |
| 17 | + | |
| 18 | +}; | |
| @@ -0,0 +1,51 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * | |
| 4 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 5 | + * | |
| 6 | + * This code is free software; you can redistribute it and/or modify it | |
| 7 | + * under the terms of the GNU General Public License version 2 only, as | |
| 8 | + * published by the Free Software Foundation. Oracle designates this | |
| 9 | + * particular file as subject to the "Classpath" exception as provided | |
| 10 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 11 | + * | |
| 12 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 16 | + * accompanied this code). | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU General Public License version | |
| 19 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 20 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 21 | + * | |
| 22 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 23 | + * or visit www.oracle.com if you need additional information or have any | |
| 24 | + * questions. | |
| 25 | + * | |
| 26 | + */ | |
| 27 | + | |
| 28 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 29 | + | |
| 30 | +package java.nio; | |
| 31 | + | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * Unchecked exception thrown when a relative <i>put</i> operation reaches | |
| 35 | + * the target buffer's limit. | |
| 36 | + * | |
| 37 | + * @since 1.4 | |
| 38 | + */ | |
| 39 | + | |
| 40 | +public class BufferOverflowException | |
| 41 | + extends RuntimeException | |
| 42 | +{ | |
| 43 | + | |
| 44 | + private static final long serialVersionUID = -5484897634319144535L; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Constructs an instance of this class. | |
| 48 | + */ | |
| 49 | + public BufferOverflowException() { } | |
| 50 | + | |
| 51 | +} | |
| @@ -0,0 +1,51 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * | |
| 4 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 5 | + * | |
| 6 | + * This code is free software; you can redistribute it and/or modify it | |
| 7 | + * under the terms of the GNU General Public License version 2 only, as | |
| 8 | + * published by the Free Software Foundation. Oracle designates this | |
| 9 | + * particular file as subject to the "Classpath" exception as provided | |
| 10 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 11 | + * | |
| 12 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 16 | + * accompanied this code). | |
| 17 | + * | |
| 18 | + * You should have received a copy of the GNU General Public License version | |
| 19 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 20 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 21 | + * | |
| 22 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 23 | + * or visit www.oracle.com if you need additional information or have any | |
| 24 | + * questions. | |
| 25 | + * | |
| 26 | + */ | |
| 27 | + | |
| 28 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 29 | + | |
| 30 | +package java.nio; | |
| 31 | + | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * Unchecked exception thrown when a relative <i>get</i> operation reaches | |
| 35 | + * the source buffer's limit. | |
| 36 | + * | |
| 37 | + * @since 1.4 | |
| 38 | + */ | |
| 39 | + | |
| 40 | +public class BufferUnderflowException | |
| 41 | + extends RuntimeException | |
| 42 | +{ | |
| 43 | + | |
| 44 | + private static final long serialVersionUID = -1713313658691622206L; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Constructs an instance of this class. | |
| 48 | + */ | |
| 49 | + public BufferUnderflowException() { } | |
| 50 | + | |
| 51 | +} | |
| @@ -0,0 +1,2046 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * A byte buffer. | |
| 36 | + * | |
| 37 | + * <p> This class defines six categories of operations upon | |
| 38 | + * byte buffers: | |
| 39 | + * | |
| 40 | + * <ul> | |
| 41 | + * | |
| 42 | + * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and | |
| 43 | + * {@link #put(byte) </code><i>put</i><code>} methods that read and write | |
| 44 | + * single bytes; </p></li> | |
| 45 | + * | |
| 46 | + * <li><p> Relative {@link #get(byte[]) </code><i>bulk get</i><code>} | |
| 47 | + * methods that transfer contiguous sequences of bytes from this buffer | |
| 48 | + * into an array; </p></li> | |
| 49 | + * | |
| 50 | + * <li><p> Relative {@link #put(byte[]) </code><i>bulk put</i><code>} | |
| 51 | + * methods that transfer contiguous sequences of bytes from a | |
| 52 | + * byte array or some other byte | |
| 53 | + * buffer into this buffer; </p></li> | |
| 54 | + * | |
| 55 | + | |
| 56 | + * | |
| 57 | + * <li><p> Absolute and relative {@link #getChar() </code><i>get</i><code>} | |
| 58 | + * and {@link #putChar(char) </code><i>put</i><code>} methods that read and | |
| 59 | + * write values of other primitive types, translating them to and from | |
| 60 | + * sequences of bytes in a particular byte order; </p></li> | |
| 61 | + * | |
| 62 | + * <li><p> Methods for creating <i><a href="#views">view buffers</a></i>, | |
| 63 | + * which allow a byte buffer to be viewed as a buffer containing values of | |
| 64 | + * some other primitive type; and </p></li> | |
| 65 | + * | |
| 66 | + | |
| 67 | + * | |
| 68 | + * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link | |
| 69 | + * #duplicate </code>duplicating<code>}, and {@link #slice | |
| 70 | + * </code>slicing<code>} a byte buffer. </p></li> | |
| 71 | + * | |
| 72 | + * </ul> | |
| 73 | + * | |
| 74 | + * <p> Byte buffers can be created either by {@link #allocate | |
| 75 | + * </code><i>allocation</i><code>}, which allocates space for the buffer's | |
| 76 | + * | |
| 77 | + | |
| 78 | + * | |
| 79 | + * content, or by {@link #wrap(byte[]) </code><i>wrapping</i><code>} an | |
| 80 | + * existing byte array into a buffer. | |
| 81 | + * | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + * | |
| 90 | + | |
| 91 | + * | |
| 92 | + * <a name="direct"> | |
| 93 | + * <h4> Direct <i>vs.</i> non-direct buffers </h4> | |
| 94 | + * | |
| 95 | + * <p> A byte buffer is either <i>direct</i> or <i>non-direct</i>. Given a | |
| 96 | + * direct byte buffer, the Java virtual machine will make a best effort to | |
| 97 | + * perform native I/O operations directly upon it. That is, it will attempt to | |
| 98 | + * avoid copying the buffer's content to (or from) an intermediate buffer | |
| 99 | + * before (or after) each invocation of one of the underlying operating | |
| 100 | + * system's native I/O operations. | |
| 101 | + * | |
| 102 | + * <p> A direct byte buffer may be created by invoking the {@link | |
| 103 | + * #allocateDirect(int) allocateDirect} factory method of this class. The | |
| 104 | + * buffers returned by this method typically have somewhat higher allocation | |
| 105 | + * and deallocation costs than non-direct buffers. The contents of direct | |
| 106 | + * buffers may reside outside of the normal garbage-collected heap, and so | |
| 107 | + * their impact upon the memory footprint of an application might not be | |
| 108 | + * obvious. It is therefore recommended that direct buffers be allocated | |
| 109 | + * primarily for large, long-lived buffers that are subject to the underlying | |
| 110 | + * system's native I/O operations. In general it is best to allocate direct | |
| 111 | + * buffers only when they yield a measureable gain in program performance. | |
| 112 | + * | |
| 113 | + * <p> A direct byte buffer may also be created by {@link | |
| 114 | + * java.nio.channels.FileChannel#map </code>mapping<code>} a region of a file | |
| 115 | + * directly into memory. An implementation of the Java platform may optionally | |
| 116 | + * support the creation of direct byte buffers from native code via JNI. If an | |
| 117 | + * instance of one of these kinds of buffers refers to an inaccessible region | |
| 118 | + * of memory then an attempt to access that region will not change the buffer's | |
| 119 | + * content and will cause an unspecified exception to be thrown either at the | |
| 120 | + * time of the access or at some later time. | |
| 121 | + * | |
| 122 | + * <p> Whether a byte buffer is direct or non-direct may be determined by | |
| 123 | + * invoking its {@link #isDirect isDirect} method. This method is provided so | |
| 124 | + * that explicit buffer management can be done in performance-critical code. | |
| 125 | + * | |
| 126 | + * | |
| 127 | + * <a name="bin"> | |
| 128 | + * <h4> Access to binary data </h4> | |
| 129 | + * | |
| 130 | + * <p> This class defines methods for reading and writing values of all other | |
| 131 | + * primitive types, except <tt>boolean</tt>. Primitive values are translated | |
| 132 | + * to (or from) sequences of bytes according to the buffer's current byte | |
| 133 | + * order, which may be retrieved and modified via the {@link #order order} | |
| 134 | + * methods. Specific byte orders are represented by instances of the {@link | |
| 135 | + * ByteOrder} class. The initial order of a byte buffer is always {@link | |
| 136 | + * ByteOrder#BIG_ENDIAN BIG_ENDIAN}. | |
| 137 | + * | |
| 138 | + * <p> For access to heterogeneous binary data, that is, sequences of values of | |
| 139 | + * different types, this class defines a family of absolute and relative | |
| 140 | + * <i>get</i> and <i>put</i> methods for each type. For 32-bit floating-point | |
| 141 | + * values, for example, this class defines: | |
| 142 | + * | |
| 143 | + * <blockquote><pre> | |
| 144 | + * float {@link #getFloat()} | |
| 145 | + * float {@link #getFloat(int) getFloat(int index)} | |
| 146 | + * void {@link #putFloat(float) putFloat(float f)} | |
| 147 | + * void {@link #putFloat(int,float) putFloat(int index, float f)}</pre></blockquote> | |
| 148 | + * | |
| 149 | + * <p> Corresponding methods are defined for the types <tt>char</tt>, | |
| 150 | + * <tt>short</tt>, <tt>int</tt>, <tt>long</tt>, and <tt>double</tt>. The index | |
| 151 | + * parameters of the absolute <i>get</i> and <i>put</i> methods are in terms of | |
| 152 | + * bytes rather than of the type being read or written. | |
| 153 | + * | |
| 154 | + * <a name="views"> | |
| 155 | + * | |
| 156 | + * <p> For access to homogeneous binary data, that is, sequences of values of | |
| 157 | + * the same type, this class defines methods that can create <i>views</i> of a | |
| 158 | + * given byte buffer. A <i>view buffer</i> is simply another buffer whose | |
| 159 | + * content is backed by the byte buffer. Changes to the byte buffer's content | |
| 160 | + * will be visible in the view buffer, and vice versa; the two buffers' | |
| 161 | + * position, limit, and mark values are independent. The {@link | |
| 162 | + * #asFloatBuffer() asFloatBuffer} method, for example, creates an instance of | |
| 163 | + * the {@link FloatBuffer} class that is backed by the byte buffer upon which | |
| 164 | + * the method is invoked. Corresponding view-creation methods are defined for | |
| 165 | + * the types <tt>char</tt>, <tt>short</tt>, <tt>int</tt>, <tt>long</tt>, and | |
| 166 | + * <tt>double</tt>. | |
| 167 | + * | |
| 168 | + * <p> View buffers have three important advantages over the families of | |
| 169 | + * type-specific <i>get</i> and <i>put</i> methods described above: | |
| 170 | + * | |
| 171 | + * <ul> | |
| 172 | + * | |
| 173 | + * <li><p> A view buffer is indexed not in terms of bytes but rather in terms | |
| 174 | + * of the type-specific size of its values; </p></li> | |
| 175 | + * | |
| 176 | + * <li><p> A view buffer provides relative bulk <i>get</i> and <i>put</i> | |
| 177 | + * methods that can transfer contiguous sequences of values between a buffer | |
| 178 | + * and an array or some other buffer of the same type; and </p></li> | |
| 179 | + * | |
| 180 | + * <li><p> A view buffer is potentially much more efficient because it will | |
| 181 | + * be direct if, and only if, its backing byte buffer is direct. </p></li> | |
| 182 | + * | |
| 183 | + * </ul> | |
| 184 | + * | |
| 185 | + * <p> The byte order of a view buffer is fixed to be that of its byte buffer | |
| 186 | + * at the time that the view is created. </p> | |
| 187 | + * | |
| 188 | + | |
| 189 | +* | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | +* | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + * | |
| 211 | + | |
| 212 | + * <h4> Invocation chaining </h4> | |
| 213 | + | |
| 214 | + * | |
| 215 | + * <p> Methods in this class that do not otherwise have a value to return are | |
| 216 | + * specified to return the buffer upon which they are invoked. This allows | |
| 217 | + * method invocations to be chained. | |
| 218 | + * | |
| 219 | + | |
| 220 | + * | |
| 221 | + * The sequence of statements | |
| 222 | + * | |
| 223 | + * <blockquote><pre> | |
| 224 | + * bb.putInt(0xCAFEBABE); | |
| 225 | + * bb.putShort(3); | |
| 226 | + * bb.putShort(45);</pre></blockquote> | |
| 227 | + * | |
| 228 | + * can, for example, be replaced by the single statement | |
| 229 | + * | |
| 230 | + * <blockquote><pre> | |
| 231 | + * bb.putInt(0xCAFEBABE).putShort(3).putShort(45);</pre></blockquote> | |
| 232 | + * | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + * | |
| 251 | + * | |
| 252 | + * @author Mark Reinhold | |
| 253 | + * @author JSR-51 Expert Group | |
| 254 | + * @since 1.4 | |
| 255 | + */ | |
| 256 | + | |
| 257 | +public abstract class ByteBuffer | |
| 258 | + extends Buffer | |
| 259 | + implements Comparable<ByteBuffer> | |
| 260 | +{ | |
| 261 | + | |
| 262 | + // These fields are declared here rather than in Heap-X-Buffer in order to | |
| 263 | + // reduce the number of virtual method invocations needed to access these | |
| 264 | + // values, which is especially costly when coding small buffers. | |
| 265 | + // | |
| 266 | + final byte[] hb; // Non-null only for heap buffers | |
| 267 | + final int offset; | |
| 268 | + boolean isReadOnly; // Valid only for heap buffers | |
| 269 | + | |
| 270 | + // Creates a new buffer with the given mark, position, limit, capacity, | |
| 271 | + // backing array, and array offset | |
| 272 | + // | |
| 273 | + ByteBuffer(int mark, int pos, int lim, int cap, // package-private | |
| 274 | + byte[] hb, int offset) | |
| 275 | + { | |
| 276 | + super(mark, pos, lim, cap); | |
| 277 | + this.hb = hb; | |
| 278 | + this.offset = offset; | |
| 279 | + } | |
| 280 | + | |
| 281 | + // Creates a new buffer with the given mark, position, limit, and capacity | |
| 282 | + // | |
| 283 | + ByteBuffer(int mark, int pos, int lim, int cap) { // package-private | |
| 284 | + this(mark, pos, lim, cap, null, 0); | |
| 285 | + } | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * Allocates a new direct byte buffer. | |
| 291 | + * | |
| 292 | + * <p> The new buffer's position will be zero, its limit will be its | |
| 293 | + * capacity, its mark will be undefined, and each of its elements will be | |
| 294 | + * initialized to zero. Whether or not it has a | |
| 295 | + * {@link #hasArray </code>backing array<code>} is unspecified. | |
| 296 | + * | |
| 297 | + * @param capacity | |
| 298 | + * The new buffer's capacity, in bytes | |
| 299 | + * | |
| 300 | + * @return The new byte buffer | |
| 301 | + * | |
| 302 | + * @throws IllegalArgumentException | |
| 303 | + * If the <tt>capacity</tt> is a negative integer | |
| 304 | + */ | |
| 305 | + public static ByteBuffer allocateDirect(int capacity) { | |
| 306 | + return new DirectByteBuffer(capacity); | |
| 307 | + } | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + /** | |
| 312 | + * Allocates a new byte buffer. | |
| 313 | + * | |
| 314 | + * <p> The new buffer's position will be zero, its limit will be its | |
| 315 | + * capacity, its mark will be undefined, and each of its elements will be | |
| 316 | + * initialized to zero. It will have a {@link #array | |
| 317 | + * </code>backing array<code>}, and its {@link #arrayOffset </code>array | |
| 318 | + * offset<code>} will be zero. | |
| 319 | + * | |
| 320 | + * @param capacity | |
| 321 | + * The new buffer's capacity, in bytes | |
| 322 | + * | |
| 323 | + * @return The new byte buffer | |
| 324 | + * | |
| 325 | + * @throws IllegalArgumentException | |
| 326 | + * If the <tt>capacity</tt> is a negative integer | |
| 327 | + */ | |
| 328 | + public static ByteBuffer allocate(int capacity) { | |
| 329 | + if (capacity < 0) | |
| 330 | + throw new IllegalArgumentException(); | |
| 331 | + return new HeapByteBuffer(capacity, capacity); | |
| 332 | + } | |
| 333 | + | |
| 334 | + /** | |
| 335 | + * Wraps a byte array into a buffer. | |
| 336 | + * | |
| 337 | + * <p> The new buffer will be backed by the given byte array; | |
| 338 | + * that is, modifications to the buffer will cause the array to be modified | |
| 339 | + * and vice versa. The new buffer's capacity will be | |
| 340 | + * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit | |
| 341 | + * will be <tt>offset + length</tt>, and its mark will be undefined. Its | |
| 342 | + * {@link #array </code>backing array<code>} will be the given array, and | |
| 343 | + * its {@link #arrayOffset </code>array offset<code>} will be zero. </p> | |
| 344 | + * | |
| 345 | + * @param array | |
| 346 | + * The array that will back the new buffer | |
| 347 | + * | |
| 348 | + * @param offset | |
| 349 | + * The offset of the subarray to be used; must be non-negative and | |
| 350 | + * no larger than <tt>array.length</tt>. The new buffer's position | |
| 351 | + * will be set to this value. | |
| 352 | + * | |
| 353 | + * @param length | |
| 354 | + * The length of the subarray to be used; | |
| 355 | + * must be non-negative and no larger than | |
| 356 | + * <tt>array.length - offset</tt>. | |
| 357 | + * The new buffer's limit will be set to <tt>offset + length</tt>. | |
| 358 | + * | |
| 359 | + * @return The new byte buffer | |
| 360 | + * | |
| 361 | + * @throws IndexOutOfBoundsException | |
| 362 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 363 | + * parameters do not hold | |
| 364 | + */ | |
| 365 | + public static ByteBuffer wrap(byte[] array, | |
| 366 | + int offset, int length) | |
| 367 | + { | |
| 368 | + try { | |
| 369 | + return new HeapByteBuffer(array, offset, length); | |
| 370 | + } catch (IllegalArgumentException x) { | |
| 371 | + throw new IndexOutOfBoundsException(); | |
| 372 | + } | |
| 373 | + } | |
| 374 | + | |
| 375 | + /** | |
| 376 | + * Wraps a byte array into a buffer. | |
| 377 | + * | |
| 378 | + * <p> The new buffer will be backed by the given byte array; | |
| 379 | + * that is, modifications to the buffer will cause the array to be modified | |
| 380 | + * and vice versa. The new buffer's capacity and limit will be | |
| 381 | + * <tt>array.length</tt>, its position will be zero, and its mark will be | |
| 382 | + * undefined. Its {@link #array </code>backing array<code>} will be the | |
| 383 | + * given array, and its {@link #arrayOffset </code>array offset<code>} will | |
| 384 | + * be zero. </p> | |
| 385 | + * | |
| 386 | + * @param array | |
| 387 | + * The array that will back this buffer | |
| 388 | + * | |
| 389 | + * @return The new byte buffer | |
| 390 | + */ | |
| 391 | + public static ByteBuffer wrap(byte[] array) { | |
| 392 | + return wrap(array, 0, array.length); | |
| 393 | + } | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + /** | |
| 489 | + * Creates a new byte buffer whose content is a shared subsequence of | |
| 490 | + * this buffer's content. | |
| 491 | + * | |
| 492 | + * <p> The content of the new buffer will start at this buffer's current | |
| 493 | + * position. Changes to this buffer's content will be visible in the new | |
| 494 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 495 | + * values will be independent. | |
| 496 | + * | |
| 497 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 498 | + * will be the number of bytes remaining in this buffer, and its mark | |
| 499 | + * will be undefined. The new buffer will be direct if, and only if, this | |
| 500 | + * buffer is direct, and it will be read-only if, and only if, this buffer | |
| 501 | + * is read-only. </p> | |
| 502 | + * | |
| 503 | + * @return The new byte buffer | |
| 504 | + */ | |
| 505 | + public abstract ByteBuffer slice(); | |
| 506 | + | |
| 507 | + /** | |
| 508 | + * Creates a new byte buffer that shares this buffer's content. | |
| 509 | + * | |
| 510 | + * <p> The content of the new buffer will be that of this buffer. Changes | |
| 511 | + * to this buffer's content will be visible in the new buffer, and vice | |
| 512 | + * versa; the two buffers' position, limit, and mark values will be | |
| 513 | + * independent. | |
| 514 | + * | |
| 515 | + * <p> The new buffer's capacity, limit, position, and mark values will be | |
| 516 | + * identical to those of this buffer. The new buffer will be direct if, | |
| 517 | + * and only if, this buffer is direct, and it will be read-only if, and | |
| 518 | + * only if, this buffer is read-only. </p> | |
| 519 | + * | |
| 520 | + * @return The new byte buffer | |
| 521 | + */ | |
| 522 | + public abstract ByteBuffer duplicate(); | |
| 523 | + | |
| 524 | + /** | |
| 525 | + * Creates a new, read-only byte buffer that shares this buffer's | |
| 526 | + * content. | |
| 527 | + * | |
| 528 | + * <p> The content of the new buffer will be that of this buffer. Changes | |
| 529 | + * to this buffer's content will be visible in the new buffer; the new | |
| 530 | + * buffer itself, however, will be read-only and will not allow the shared | |
| 531 | + * content to be modified. The two buffers' position, limit, and mark | |
| 532 | + * values will be independent. | |
| 533 | + * | |
| 534 | + * <p> The new buffer's capacity, limit, position, and mark values will be | |
| 535 | + * identical to those of this buffer. | |
| 536 | + * | |
| 537 | + * <p> If this buffer is itself read-only then this method behaves in | |
| 538 | + * exactly the same way as the {@link #duplicate duplicate} method. </p> | |
| 539 | + * | |
| 540 | + * @return The new, read-only byte buffer | |
| 541 | + */ | |
| 542 | + public abstract ByteBuffer asReadOnlyBuffer(); | |
| 543 | + | |
| 544 | + | |
| 545 | + // -- Singleton get/put methods -- | |
| 546 | + | |
| 547 | + /** | |
| 548 | + * Relative <i>get</i> method. Reads the byte at this buffer's | |
| 549 | + * current position, and then increments the position. </p> | |
| 550 | + * | |
| 551 | + * @return The byte at the buffer's current position | |
| 552 | + * | |
| 553 | + * @throws BufferUnderflowException | |
| 554 | + * If the buffer's current position is not smaller than its limit | |
| 555 | + */ | |
| 556 | + public abstract byte get(); | |
| 557 | + | |
| 558 | + /** | |
| 559 | + * Relative <i>put</i> method <i>(optional operation)</i>. | |
| 560 | + * | |
| 561 | + * <p> Writes the given byte into this buffer at the current | |
| 562 | + * position, and then increments the position. </p> | |
| 563 | + * | |
| 564 | + * @param b | |
| 565 | + * The byte to be written | |
| 566 | + * | |
| 567 | + * @return This buffer | |
| 568 | + * | |
| 569 | + * @throws BufferOverflowException | |
| 570 | + * If this buffer's current position is not smaller than its limit | |
| 571 | + * | |
| 572 | + * @throws ReadOnlyBufferException | |
| 573 | + * If this buffer is read-only | |
| 574 | + */ | |
| 575 | + public abstract ByteBuffer put(byte b); | |
| 576 | + | |
| 577 | + /** | |
| 578 | + * Absolute <i>get</i> method. Reads the byte at the given | |
| 579 | + * index. </p> | |
| 580 | + * | |
| 581 | + * @param index | |
| 582 | + * The index from which the byte will be read | |
| 583 | + * | |
| 584 | + * @return The byte at the given index | |
| 585 | + * | |
| 586 | + * @throws IndexOutOfBoundsException | |
| 587 | + * If <tt>index</tt> is negative | |
| 588 | + * or not smaller than the buffer's limit | |
| 589 | + */ | |
| 590 | + public abstract byte get(int index); | |
| 591 | + | |
| 592 | + /** | |
| 593 | + * Absolute <i>put</i> method <i>(optional operation)</i>. | |
| 594 | + * | |
| 595 | + * <p> Writes the given byte into this buffer at the given | |
| 596 | + * index. </p> | |
| 597 | + * | |
| 598 | + * @param index | |
| 599 | + * The index at which the byte will be written | |
| 600 | + * | |
| 601 | + * @param b | |
| 602 | + * The byte value to be written | |
| 603 | + * | |
| 604 | + * @return This buffer | |
| 605 | + * | |
| 606 | + * @throws IndexOutOfBoundsException | |
| 607 | + * If <tt>index</tt> is negative | |
| 608 | + * or not smaller than the buffer's limit | |
| 609 | + * | |
| 610 | + * @throws ReadOnlyBufferException | |
| 611 | + * If this buffer is read-only | |
| 612 | + */ | |
| 613 | + public abstract ByteBuffer put(int index, byte b); | |
| 614 | + | |
| 615 | + | |
| 616 | + // -- Bulk get operations -- | |
| 617 | + | |
| 618 | + /** | |
| 619 | + * Relative bulk <i>get</i> method. | |
| 620 | + * | |
| 621 | + * <p> This method transfers bytes from this buffer into the given | |
| 622 | + * destination array. If there are fewer bytes remaining in the | |
| 623 | + * buffer than are required to satisfy the request, that is, if | |
| 624 | + * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no | |
| 625 | + * bytes are transferred and a {@link BufferUnderflowException} is | |
| 626 | + * thrown. | |
| 627 | + * | |
| 628 | + * <p> Otherwise, this method copies <tt>length</tt> bytes from this | |
| 629 | + * buffer into the given array, starting at the current position of this | |
| 630 | + * buffer and at the given offset in the array. The position of this | |
| 631 | + * buffer is then incremented by <tt>length</tt>. | |
| 632 | + * | |
| 633 | + * <p> In other words, an invocation of this method of the form | |
| 634 | + * <tt>src.get(dst, off, len)</tt> has exactly the same effect as | |
| 635 | + * the loop | |
| 636 | + * | |
| 637 | + * <pre> | |
| 638 | + * for (int i = off; i < off + len; i++) | |
| 639 | + * dst[i] = src.get(); </pre> | |
| 640 | + * | |
| 641 | + * except that it first checks that there are sufficient bytes in | |
| 642 | + * this buffer and it is potentially much more efficient. </p> | |
| 643 | + * | |
| 644 | + * @param dst | |
| 645 | + * The array into which bytes are to be written | |
| 646 | + * | |
| 647 | + * @param offset | |
| 648 | + * The offset within the array of the first byte to be | |
| 649 | + * written; must be non-negative and no larger than | |
| 650 | + * <tt>dst.length</tt> | |
| 651 | + * | |
| 652 | + * @param length | |
| 653 | + * The maximum number of bytes to be written to the given | |
| 654 | + * array; must be non-negative and no larger than | |
| 655 | + * <tt>dst.length - offset</tt> | |
| 656 | + * | |
| 657 | + * @return This buffer | |
| 658 | + * | |
| 659 | + * @throws BufferUnderflowException | |
| 660 | + * If there are fewer than <tt>length</tt> bytes | |
| 661 | + * remaining in this buffer | |
| 662 | + * | |
| 663 | + * @throws IndexOutOfBoundsException | |
| 664 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 665 | + * parameters do not hold | |
| 666 | + */ | |
| 667 | + public ByteBuffer get(byte[] dst, int offset, int length) { | |
| 668 | + // [Inferno] < | |
| 669 | + //checkBounds(offset, length, dst.length); | |
| 670 | + // [Inferno] = | |
| 671 | + Buffer.checkBounds(offset, length, dst.length); | |
| 672 | + // [Inferno] > | |
| 673 | + if (length > remaining()) | |
| 674 | + throw new BufferUnderflowException(); | |
| 675 | + int end = offset + length; | |
| 676 | + for (int i = offset; i < end; i++) | |
| 677 | + dst[i] = get(); | |
| 678 | + return this; | |
| 679 | + } | |
| 680 | + | |
| 681 | + /** | |
| 682 | + * Relative bulk <i>get</i> method. | |
| 683 | + * | |
| 684 | + * <p> This method transfers bytes from this buffer into the given | |
| 685 | + * destination array. An invocation of this method of the form | |
| 686 | + * <tt>src.get(a)</tt> behaves in exactly the same way as the invocation | |
| 687 | + * | |
| 688 | + * <pre> | |
| 689 | + * src.get(a, 0, a.length) </pre> | |
| 690 | + * | |
| 691 | + * @return This buffer | |
| 692 | + * | |
| 693 | + * @throws BufferUnderflowException | |
| 694 | + * If there are fewer than <tt>length</tt> bytes | |
| 695 | + * remaining in this buffer | |
| 696 | + */ | |
| 697 | + public ByteBuffer get(byte[] dst) { | |
| 698 | + return get(dst, 0, dst.length); | |
| 699 | + } | |
| 700 | + | |
| 701 | + | |
| 702 | + // -- Bulk put operations -- | |
| 703 | + | |
| 704 | + /** | |
| 705 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 706 | + * | |
| 707 | + * <p> This method transfers the bytes remaining in the given source | |
| 708 | + * buffer into this buffer. If there are more bytes remaining in the | |
| 709 | + * source buffer than in this buffer, that is, if | |
| 710 | + * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>, | |
| 711 | + * then no bytes are transferred and a {@link | |
| 712 | + * BufferOverflowException} is thrown. | |
| 713 | + * | |
| 714 | + * <p> Otherwise, this method copies | |
| 715 | + * <i>n</i> = <tt>src.remaining()</tt> bytes from the given | |
| 716 | + * buffer into this buffer, starting at each buffer's current position. | |
| 717 | + * The positions of both buffers are then incremented by <i>n</i>. | |
| 718 | + * | |
| 719 | + * <p> In other words, an invocation of this method of the form | |
| 720 | + * <tt>dst.put(src)</tt> has exactly the same effect as the loop | |
| 721 | + * | |
| 722 | + * <pre> | |
| 723 | + * while (src.hasRemaining()) | |
| 724 | + * dst.put(src.get()); </pre> | |
| 725 | + * | |
| 726 | + * except that it first checks that there is sufficient space in this | |
| 727 | + * buffer and it is potentially much more efficient. </p> | |
| 728 | + * | |
| 729 | + * @param src | |
| 730 | + * The source buffer from which bytes are to be read; | |
| 731 | + * must not be this buffer | |
| 732 | + * | |
| 733 | + * @return This buffer | |
| 734 | + * | |
| 735 | + * @throws BufferOverflowException | |
| 736 | + * If there is insufficient space in this buffer | |
| 737 | + * for the remaining bytes in the source buffer | |
| 738 | + * | |
| 739 | + * @throws IllegalArgumentException | |
| 740 | + * If the source buffer is this buffer | |
| 741 | + * | |
| 742 | + * @throws ReadOnlyBufferException | |
| 743 | + * If this buffer is read-only | |
| 744 | + */ | |
| 745 | + public ByteBuffer put(ByteBuffer src) { | |
| 746 | + if (src == this) | |
| 747 | + throw new IllegalArgumentException(); | |
| 748 | + int n = src.remaining(); | |
| 749 | + if (n > remaining()) | |
| 750 | + throw new BufferOverflowException(); | |
| 751 | + for (int i = 0; i < n; i++) | |
| 752 | + put(src.get()); | |
| 753 | + return this; | |
| 754 | + } | |
| 755 | + | |
| 756 | + /** | |
| 757 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 758 | + * | |
| 759 | + * <p> This method transfers bytes into this buffer from the given | |
| 760 | + * source array. If there are more bytes to be copied from the array | |
| 761 | + * than remain in this buffer, that is, if | |
| 762 | + * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no | |
| 763 | + * bytes are transferred and a {@link BufferOverflowException} is | |
| 764 | + * thrown. | |
| 765 | + * | |
| 766 | + * <p> Otherwise, this method copies <tt>length</tt> bytes from the | |
| 767 | + * given array into this buffer, starting at the given offset in the array | |
| 768 | + * and at the current position of this buffer. The position of this buffer | |
| 769 | + * is then incremented by <tt>length</tt>. | |
| 770 | + * | |
| 771 | + * <p> In other words, an invocation of this method of the form | |
| 772 | + * <tt>dst.put(src, off, len)</tt> has exactly the same effect as | |
| 773 | + * the loop | |
| 774 | + * | |
| 775 | + * <pre> | |
| 776 | + * for (int i = off; i < off + len; i++) | |
| 777 | + * dst.put(a[i]); </pre> | |
| 778 | + * | |
| 779 | + * except that it first checks that there is sufficient space in this | |
| 780 | + * buffer and it is potentially much more efficient. </p> | |
| 781 | + * | |
| 782 | + * @param src | |
| 783 | + * The array from which bytes are to be read | |
| 784 | + * | |
| 785 | + * @param offset | |
| 786 | + * The offset within the array of the first byte to be read; | |
| 787 | + * must be non-negative and no larger than <tt>array.length</tt> | |
| 788 | + * | |
| 789 | + * @param length | |
| 790 | + * The number of bytes to be read from the given array; | |
| 791 | + * must be non-negative and no larger than | |
| 792 | + * <tt>array.length - offset</tt> | |
| 793 | + * | |
| 794 | + * @return This buffer | |
| 795 | + * | |
| 796 | + * @throws BufferOverflowException | |
| 797 | + * If there is insufficient space in this buffer | |
| 798 | + * | |
| 799 | + * @throws IndexOutOfBoundsException | |
| 800 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 801 | + * parameters do not hold | |
| 802 | + * | |
| 803 | + * @throws ReadOnlyBufferException | |
| 804 | + * If this buffer is read-only | |
| 805 | + */ | |
| 806 | + public ByteBuffer put(byte[] src, int offset, int length) { | |
| 807 | + // [Inferno] < | |
| 808 | + //checkBounds(offset, length, src.length); | |
| 809 | + // [Inferno] = | |
| 810 | + Buffer.checkBounds(offset, length, src.length); | |
| 811 | + // [Inferno] > | |
| 812 | + if (length > remaining()) | |
| 813 | + throw new BufferOverflowException(); | |
| 814 | + int end = offset + length; | |
| 815 | + for (int i = offset; i < end; i++) | |
| 816 | + this.put(src[i]); | |
| 817 | + return this; | |
| 818 | + } | |
| 819 | + | |
| 820 | + /** | |
| 821 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 822 | + * | |
| 823 | + * <p> This method transfers the entire content of the given source | |
| 824 | + * byte array into this buffer. An invocation of this method of the | |
| 825 | + * form <tt>dst.put(a)</tt> behaves in exactly the same way as the | |
| 826 | + * invocation | |
| 827 | + * | |
| 828 | + * <pre> | |
| 829 | + * dst.put(a, 0, a.length) </pre> | |
| 830 | + * | |
| 831 | + * @return This buffer | |
| 832 | + * | |
| 833 | + * @throws BufferOverflowException | |
| 834 | + * If there is insufficient space in this buffer | |
| 835 | + * | |
| 836 | + * @throws ReadOnlyBufferException | |
| 837 | + * If this buffer is read-only | |
| 838 | + */ | |
| 839 | + public final ByteBuffer put(byte[] src) { | |
| 840 | + return put(src, 0, src.length); | |
| 841 | + } | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + // -- Other stuff -- | |
| 930 | + | |
| 931 | + /** | |
| 932 | + * Tells whether or not this buffer is backed by an accessible byte | |
| 933 | + * array. | |
| 934 | + * | |
| 935 | + * <p> If this method returns <tt>true</tt> then the {@link #array() array} | |
| 936 | + * and {@link #arrayOffset() arrayOffset} methods may safely be invoked. | |
| 937 | + * </p> | |
| 938 | + * | |
| 939 | + * @return <tt>true</tt> if, and only if, this buffer | |
| 940 | + * is backed by an array and is not read-only | |
| 941 | + */ | |
| 942 | + public final boolean hasArray() { | |
| 943 | + return (hb != null) && !isReadOnly; | |
| 944 | + } | |
| 945 | + | |
| 946 | + /** | |
| 947 | + * Returns the byte array that backs this | |
| 948 | + * buffer <i>(optional operation)</i>. | |
| 949 | + * | |
| 950 | + * <p> Modifications to this buffer's content will cause the returned | |
| 951 | + * array's content to be modified, and vice versa. | |
| 952 | + * | |
| 953 | + * <p> Invoke the {@link #hasArray hasArray} method before invoking this | |
| 954 | + * method in order to ensure that this buffer has an accessible backing | |
| 955 | + * array. </p> | |
| 956 | + * | |
| 957 | + * @return The array that backs this buffer | |
| 958 | + * | |
| 959 | + * @throws ReadOnlyBufferException | |
| 960 | + * If this buffer is backed by an array but is read-only | |
| 961 | + * | |
| 962 | + * @throws UnsupportedOperationException | |
| 963 | + * If this buffer is not backed by an accessible array | |
| 964 | + */ | |
| 965 | + public final byte[] array() { | |
| 966 | + if (hb == null) | |
| 967 | + throw new UnsupportedOperationException(); | |
| 968 | + if (isReadOnly) | |
| 969 | + throw new ReadOnlyBufferException(); | |
| 970 | + return hb; | |
| 971 | + } | |
| 972 | + | |
| 973 | + /** | |
| 974 | + * Returns the offset within this buffer's backing array of the first | |
| 975 | + * element of the buffer <i>(optional operation)</i>. | |
| 976 | + * | |
| 977 | + * <p> If this buffer is backed by an array then buffer position <i>p</i> | |
| 978 | + * corresponds to array index <i>p</i> + <tt>arrayOffset()</tt>. | |
| 979 | + * | |
| 980 | + * <p> Invoke the {@link #hasArray hasArray} method before invoking this | |
| 981 | + * method in order to ensure that this buffer has an accessible backing | |
| 982 | + * array. </p> | |
| 983 | + * | |
| 984 | + * @return The offset within this buffer's array | |
| 985 | + * of the first element of the buffer | |
| 986 | + * | |
| 987 | + * @throws ReadOnlyBufferException | |
| 988 | + * If this buffer is backed by an array but is read-only | |
| 989 | + * | |
| 990 | + * @throws UnsupportedOperationException | |
| 991 | + * If this buffer is not backed by an accessible array | |
| 992 | + */ | |
| 993 | + public final int arrayOffset() { | |
| 994 | + if (hb == null) | |
| 995 | + throw new UnsupportedOperationException(); | |
| 996 | + if (isReadOnly) | |
| 997 | + throw new ReadOnlyBufferException(); | |
| 998 | + return offset; | |
| 999 | + } | |
| 1000 | + | |
| 1001 | + /** | |
| 1002 | + * Compacts this buffer <i>(optional operation)</i>. | |
| 1003 | + * | |
| 1004 | + * <p> The bytes between the buffer's current position and its limit, | |
| 1005 | + * if any, are copied to the beginning of the buffer. That is, the | |
| 1006 | + * byte at index <i>p</i> = <tt>position()</tt> is copied | |
| 1007 | + * to index zero, the byte at index <i>p</i> + 1 is copied | |
| 1008 | + * to index one, and so forth until the byte at index | |
| 1009 | + * <tt>limit()</tt> - 1 is copied to index | |
| 1010 | + * <i>n</i> = <tt>limit()</tt> - <tt>1</tt> - <i>p</i>. | |
| 1011 | + * The buffer's position is then set to <i>n+1</i> and its limit is set to | |
| 1012 | + * its capacity. The mark, if defined, is discarded. | |
| 1013 | + * | |
| 1014 | + * <p> The buffer's position is set to the number of bytes copied, | |
| 1015 | + * rather than to zero, so that an invocation of this method can be | |
| 1016 | + * followed immediately by an invocation of another relative <i>put</i> | |
| 1017 | + * method. </p> | |
| 1018 | + * | |
| 1019 | + | |
| 1020 | + * | |
| 1021 | + * <p> Invoke this method after writing data from a buffer in case the | |
| 1022 | + * write was incomplete. The following loop, for example, copies bytes | |
| 1023 | + * from one channel to another via the buffer <tt>buf</tt>: | |
| 1024 | + * | |
| 1025 | + * <blockquote><pre> | |
| 1026 | + * buf.clear(); // Prepare buffer for use | |
| 1027 | + * while (in.read(buf) >= 0 || buf.position != 0) { | |
| 1028 | + * buf.flip(); | |
| 1029 | + * out.write(buf); | |
| 1030 | + * buf.compact(); // In case of partial write | |
| 1031 | + * }</pre></blockquote> | |
| 1032 | + * | |
| 1033 | + | |
| 1034 | + * | |
| 1035 | + * @return This buffer | |
| 1036 | + * | |
| 1037 | + * @throws ReadOnlyBufferException | |
| 1038 | + * If this buffer is read-only | |
| 1039 | + */ | |
| 1040 | + public abstract ByteBuffer compact(); | |
| 1041 | + | |
| 1042 | + /** | |
| 1043 | + * Tells whether or not this byte buffer is direct. </p> | |
| 1044 | + * | |
| 1045 | + * @return <tt>true</tt> if, and only if, this buffer is direct | |
| 1046 | + */ | |
| 1047 | + public abstract boolean isDirect(); | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + /** | |
| 1052 | + * Returns a string summarizing the state of this buffer. </p> | |
| 1053 | + * | |
| 1054 | + * @return A summary string | |
| 1055 | + */ | |
| 1056 | + public String toString() { | |
| 1057 | + StringBuffer sb = new StringBuffer(); | |
| 1058 | + sb.append(getClass().getName()); | |
| 1059 | + sb.append("[pos="); | |
| 1060 | + sb.append(position()); | |
| 1061 | + sb.append(" lim="); | |
| 1062 | + sb.append(limit()); | |
| 1063 | + sb.append(" cap="); | |
| 1064 | + sb.append(capacity()); | |
| 1065 | + sb.append("]"); | |
| 1066 | + return sb.toString(); | |
| 1067 | + } | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + /** | |
| 1075 | + * Returns the current hash code of this buffer. | |
| 1076 | + * | |
| 1077 | + * <p> The hash code of a byte buffer depends only upon its remaining | |
| 1078 | + * elements; that is, upon the elements from <tt>position()</tt> up to, and | |
| 1079 | + * including, the element at <tt>limit()</tt> - <tt>1</tt>. | |
| 1080 | + * | |
| 1081 | + * <p> Because buffer hash codes are content-dependent, it is inadvisable | |
| 1082 | + * to use buffers as keys in hash maps or similar data structures unless it | |
| 1083 | + * is known that their contents will not change. </p> | |
| 1084 | + * | |
| 1085 | + * @return The current hash code of this buffer | |
| 1086 | + */ | |
| 1087 | + public int hashCode() { | |
| 1088 | + int h = 1; | |
| 1089 | + int p = position(); | |
| 1090 | + for (int i = limit() - 1; i >= p; i--) | |
| 1091 | + h = 31 * h + (int)get(i); | |
| 1092 | + return h; | |
| 1093 | + } | |
| 1094 | + | |
| 1095 | + /** | |
| 1096 | + * Tells whether or not this buffer is equal to another object. | |
| 1097 | + * | |
| 1098 | + * <p> Two byte buffers are equal if, and only if, | |
| 1099 | + * | |
| 1100 | + * <p><ol> | |
| 1101 | + * | |
| 1102 | + * <li><p> They have the same element type, </p></li> | |
| 1103 | + * | |
| 1104 | + * <li><p> They have the same number of remaining elements, and | |
| 1105 | + * </p></li> | |
| 1106 | + * | |
| 1107 | + * <li><p> The two sequences of remaining elements, considered | |
| 1108 | + * independently of their starting positions, are pointwise equal. | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + * </p></li> | |
| 1117 | + * | |
| 1118 | + * </ol> | |
| 1119 | + * | |
| 1120 | + * <p> A byte buffer is not equal to any other type of object. </p> | |
| 1121 | + * | |
| 1122 | + * @param ob The object to which this buffer is to be compared | |
| 1123 | + * | |
| 1124 | + * @return <tt>true</tt> if, and only if, this buffer is equal to the | |
| 1125 | + * given object | |
| 1126 | + */ | |
| 1127 | + public boolean equals(Object ob) { | |
| 1128 | + if (this == ob) | |
| 1129 | + return true; | |
| 1130 | + if (!(ob instanceof ByteBuffer)) | |
| 1131 | + return false; | |
| 1132 | + ByteBuffer that = (ByteBuffer)ob; | |
| 1133 | + if (this.remaining() != that.remaining()) | |
| 1134 | + return false; | |
| 1135 | + int p = this.position(); | |
| 1136 | + for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) | |
| 1137 | + if (!equals(this.get(i), that.get(j))) | |
| 1138 | + return false; | |
| 1139 | + return true; | |
| 1140 | + } | |
| 1141 | + | |
| 1142 | + private static boolean equals(byte x, byte y) { | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + return x == y; | |
| 1147 | + | |
| 1148 | + } | |
| 1149 | + | |
| 1150 | + /** | |
| 1151 | + * Compares this buffer to another. | |
| 1152 | + * | |
| 1153 | + * <p> Two byte buffers are compared by comparing their sequences of | |
| 1154 | + * remaining elements lexicographically, without regard to the starting | |
| 1155 | + * position of each sequence within its corresponding buffer. | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + * Pairs of {@code byte} elements are compared as if by invoking | |
| 1165 | + * {@link Byte#compare(byte,byte)}. | |
| 1166 | + | |
| 1167 | + * | |
| 1168 | + * <p> A byte buffer is not comparable to any other type of object. | |
| 1169 | + * | |
| 1170 | + * @return A negative integer, zero, or a positive integer as this buffer | |
| 1171 | + * is less than, equal to, or greater than the given buffer | |
| 1172 | + */ | |
| 1173 | + public int compareTo(ByteBuffer that) { | |
| 1174 | + int n = this.position() + Math.min(this.remaining(), that.remaining()); | |
| 1175 | + for (int i = this.position(), j = that.position(); i < n; i++, j++) { | |
| 1176 | + int cmp = compare(this.get(i), that.get(j)); | |
| 1177 | + if (cmp != 0) | |
| 1178 | + return cmp; | |
| 1179 | + } | |
| 1180 | + return this.remaining() - that.remaining(); | |
| 1181 | + } | |
| 1182 | + | |
| 1183 | + private static int compare(byte x, byte y) { | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + return Byte.compare(x, y); | |
| 1191 | + | |
| 1192 | + } | |
| 1193 | + | |
| 1194 | + // -- Other char stuff -- | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + // -- Other byte stuff: Access to binary data -- | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + boolean bigEndian // package-private | |
| 1412 | + = true; | |
| 1413 | + boolean nativeByteOrder // package-private | |
| 1414 | + = (Bits.byteOrder() == ByteOrder.BIG_ENDIAN); | |
| 1415 | + | |
| 1416 | + /** | |
| 1417 | + * Retrieves this buffer's byte order. | |
| 1418 | + * | |
| 1419 | + * <p> The byte order is used when reading or writing multibyte values, and | |
| 1420 | + * when creating buffers that are views of this byte buffer. The order of | |
| 1421 | + * a newly-created byte buffer is always {@link ByteOrder#BIG_ENDIAN | |
| 1422 | + * BIG_ENDIAN}. </p> | |
| 1423 | + * | |
| 1424 | + * @return This buffer's byte order | |
| 1425 | + */ | |
| 1426 | + public final ByteOrder order() { | |
| 1427 | + return bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; | |
| 1428 | + } | |
| 1429 | + | |
| 1430 | + /** | |
| 1431 | + * Modifies this buffer's byte order. </p> | |
| 1432 | + * | |
| 1433 | + * @param bo | |
| 1434 | + * The new byte order, | |
| 1435 | + * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} | |
| 1436 | + * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} | |
| 1437 | + * | |
| 1438 | + * @return This buffer | |
| 1439 | + */ | |
| 1440 | + public final ByteBuffer order(ByteOrder bo) { | |
| 1441 | + bigEndian = (bo == ByteOrder.BIG_ENDIAN); | |
| 1442 | + nativeByteOrder = | |
| 1443 | + (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN)); | |
| 1444 | + return this; | |
| 1445 | + } | |
| 1446 | + | |
| 1447 | + // Unchecked accessors, for use by ByteBufferAs-X-Buffer classes | |
| 1448 | + // | |
| 1449 | + abstract byte _get(int i); // package-private | |
| 1450 | + abstract void _put(int i, byte b); // package-private | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + /** | |
| 1454 | + * Relative <i>get</i> method for reading a char value. | |
| 1455 | + * | |
| 1456 | + * <p> Reads the next two bytes at this buffer's current position, | |
| 1457 | + * composing them into a char value according to the current byte order, | |
| 1458 | + * and then increments the position by two. </p> | |
| 1459 | + * | |
| 1460 | + * @return The char value at the buffer's current position | |
| 1461 | + * | |
| 1462 | + * @throws BufferUnderflowException | |
| 1463 | + * If there are fewer than two bytes | |
| 1464 | + * remaining in this buffer | |
| 1465 | + */ | |
| 1466 | + public abstract char getChar(); | |
| 1467 | + | |
| 1468 | + /** | |
| 1469 | + * Relative <i>put</i> method for writing a char | |
| 1470 | + * value <i>(optional operation)</i>. | |
| 1471 | + * | |
| 1472 | + * <p> Writes two bytes containing the given char value, in the | |
| 1473 | + * current byte order, into this buffer at the current position, and then | |
| 1474 | + * increments the position by two. </p> | |
| 1475 | + * | |
| 1476 | + * @param value | |
| 1477 | + * The char value to be written | |
| 1478 | + * | |
| 1479 | + * @return This buffer | |
| 1480 | + * | |
| 1481 | + * @throws BufferOverflowException | |
| 1482 | + * If there are fewer than two bytes | |
| 1483 | + * remaining in this buffer | |
| 1484 | + * | |
| 1485 | + * @throws ReadOnlyBufferException | |
| 1486 | + * If this buffer is read-only | |
| 1487 | + */ | |
| 1488 | + public abstract ByteBuffer putChar(char value); | |
| 1489 | + | |
| 1490 | + /** | |
| 1491 | + * Absolute <i>get</i> method for reading a char value. | |
| 1492 | + * | |
| 1493 | + * <p> Reads two bytes at the given index, composing them into a | |
| 1494 | + * char value according to the current byte order. </p> | |
| 1495 | + * | |
| 1496 | + * @param index | |
| 1497 | + * The index from which the bytes will be read | |
| 1498 | + * | |
| 1499 | + * @return The char value at the given index | |
| 1500 | + * | |
| 1501 | + * @throws IndexOutOfBoundsException | |
| 1502 | + * If <tt>index</tt> is negative | |
| 1503 | + * or not smaller than the buffer's limit, | |
| 1504 | + * minus one | |
| 1505 | + */ | |
| 1506 | + public abstract char getChar(int index); | |
| 1507 | + | |
| 1508 | + /** | |
| 1509 | + * Absolute <i>put</i> method for writing a char | |
| 1510 | + * value <i>(optional operation)</i>. | |
| 1511 | + * | |
| 1512 | + * <p> Writes two bytes containing the given char value, in the | |
| 1513 | + * current byte order, into this buffer at the given index. </p> | |
| 1514 | + * | |
| 1515 | + * @param index | |
| 1516 | + * The index at which the bytes will be written | |
| 1517 | + * | |
| 1518 | + * @param value | |
| 1519 | + * The char value to be written | |
| 1520 | + * | |
| 1521 | + * @return This buffer | |
| 1522 | + * | |
| 1523 | + * @throws IndexOutOfBoundsException | |
| 1524 | + * If <tt>index</tt> is negative | |
| 1525 | + * or not smaller than the buffer's limit, | |
| 1526 | + * minus one | |
| 1527 | + * | |
| 1528 | + * @throws ReadOnlyBufferException | |
| 1529 | + * If this buffer is read-only | |
| 1530 | + */ | |
| 1531 | + public abstract ByteBuffer putChar(int index, char value); | |
| 1532 | + | |
| 1533 | + /** | |
| 1534 | + * Creates a view of this byte buffer as a char buffer. | |
| 1535 | + * | |
| 1536 | + * <p> The content of the new buffer will start at this buffer's current | |
| 1537 | + * position. Changes to this buffer's content will be visible in the new | |
| 1538 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 1539 | + * values will be independent. | |
| 1540 | + * | |
| 1541 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 1542 | + * will be the number of bytes remaining in this buffer divided by | |
| 1543 | + * two, and its mark will be undefined. The new buffer will be direct | |
| 1544 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 1545 | + * only if, this buffer is read-only. </p> | |
| 1546 | + * | |
| 1547 | + * @return A new char buffer | |
| 1548 | + */ | |
| 1549 | + public abstract CharBuffer asCharBuffer(); | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + /** | |
| 1553 | + * Relative <i>get</i> method for reading a short value. | |
| 1554 | + * | |
| 1555 | + * <p> Reads the next two bytes at this buffer's current position, | |
| 1556 | + * composing them into a short value according to the current byte order, | |
| 1557 | + * and then increments the position by two. </p> | |
| 1558 | + * | |
| 1559 | + * @return The short value at the buffer's current position | |
| 1560 | + * | |
| 1561 | + * @throws BufferUnderflowException | |
| 1562 | + * If there are fewer than two bytes | |
| 1563 | + * remaining in this buffer | |
| 1564 | + */ | |
| 1565 | + public abstract short getShort(); | |
| 1566 | + | |
| 1567 | + /** | |
| 1568 | + * Relative <i>put</i> method for writing a short | |
| 1569 | + * value <i>(optional operation)</i>. | |
| 1570 | + * | |
| 1571 | + * <p> Writes two bytes containing the given short value, in the | |
| 1572 | + * current byte order, into this buffer at the current position, and then | |
| 1573 | + * increments the position by two. </p> | |
| 1574 | + * | |
| 1575 | + * @param value | |
| 1576 | + * The short value to be written | |
| 1577 | + * | |
| 1578 | + * @return This buffer | |
| 1579 | + * | |
| 1580 | + * @throws BufferOverflowException | |
| 1581 | + * If there are fewer than two bytes | |
| 1582 | + * remaining in this buffer | |
| 1583 | + * | |
| 1584 | + * @throws ReadOnlyBufferException | |
| 1585 | + * If this buffer is read-only | |
| 1586 | + */ | |
| 1587 | + public abstract ByteBuffer putShort(short value); | |
| 1588 | + | |
| 1589 | + /** | |
| 1590 | + * Absolute <i>get</i> method for reading a short value. | |
| 1591 | + * | |
| 1592 | + * <p> Reads two bytes at the given index, composing them into a | |
| 1593 | + * short value according to the current byte order. </p> | |
| 1594 | + * | |
| 1595 | + * @param index | |
| 1596 | + * The index from which the bytes will be read | |
| 1597 | + * | |
| 1598 | + * @return The short value at the given index | |
| 1599 | + * | |
| 1600 | + * @throws IndexOutOfBoundsException | |
| 1601 | + * If <tt>index</tt> is negative | |
| 1602 | + * or not smaller than the buffer's limit, | |
| 1603 | + * minus one | |
| 1604 | + */ | |
| 1605 | + public abstract short getShort(int index); | |
| 1606 | + | |
| 1607 | + /** | |
| 1608 | + * Absolute <i>put</i> method for writing a short | |
| 1609 | + * value <i>(optional operation)</i>. | |
| 1610 | + * | |
| 1611 | + * <p> Writes two bytes containing the given short value, in the | |
| 1612 | + * current byte order, into this buffer at the given index. </p> | |
| 1613 | + * | |
| 1614 | + * @param index | |
| 1615 | + * The index at which the bytes will be written | |
| 1616 | + * | |
| 1617 | + * @param value | |
| 1618 | + * The short value to be written | |
| 1619 | + * | |
| 1620 | + * @return This buffer | |
| 1621 | + * | |
| 1622 | + * @throws IndexOutOfBoundsException | |
| 1623 | + * If <tt>index</tt> is negative | |
| 1624 | + * or not smaller than the buffer's limit, | |
| 1625 | + * minus one | |
| 1626 | + * | |
| 1627 | + * @throws ReadOnlyBufferException | |
| 1628 | + * If this buffer is read-only | |
| 1629 | + */ | |
| 1630 | + public abstract ByteBuffer putShort(int index, short value); | |
| 1631 | + | |
| 1632 | + /** | |
| 1633 | + * Creates a view of this byte buffer as a short buffer. | |
| 1634 | + * | |
| 1635 | + * <p> The content of the new buffer will start at this buffer's current | |
| 1636 | + * position. Changes to this buffer's content will be visible in the new | |
| 1637 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 1638 | + * values will be independent. | |
| 1639 | + * | |
| 1640 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 1641 | + * will be the number of bytes remaining in this buffer divided by | |
| 1642 | + * two, and its mark will be undefined. The new buffer will be direct | |
| 1643 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 1644 | + * only if, this buffer is read-only. </p> | |
| 1645 | + * | |
| 1646 | + * @return A new short buffer | |
| 1647 | + */ | |
| 1648 | + public abstract ShortBuffer asShortBuffer(); | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + /** | |
| 1652 | + * Relative <i>get</i> method for reading an int value. | |
| 1653 | + * | |
| 1654 | + * <p> Reads the next four bytes at this buffer's current position, | |
| 1655 | + * composing them into an int value according to the current byte order, | |
| 1656 | + * and then increments the position by four. </p> | |
| 1657 | + * | |
| 1658 | + * @return The int value at the buffer's current position | |
| 1659 | + * | |
| 1660 | + * @throws BufferUnderflowException | |
| 1661 | + * If there are fewer than four bytes | |
| 1662 | + * remaining in this buffer | |
| 1663 | + */ | |
| 1664 | + public abstract int getInt(); | |
| 1665 | + | |
| 1666 | + /** | |
| 1667 | + * Relative <i>put</i> method for writing an int | |
| 1668 | + * value <i>(optional operation)</i>. | |
| 1669 | + * | |
| 1670 | + * <p> Writes four bytes containing the given int value, in the | |
| 1671 | + * current byte order, into this buffer at the current position, and then | |
| 1672 | + * increments the position by four. </p> | |
| 1673 | + * | |
| 1674 | + * @param value | |
| 1675 | + * The int value to be written | |
| 1676 | + * | |
| 1677 | + * @return This buffer | |
| 1678 | + * | |
| 1679 | + * @throws BufferOverflowException | |
| 1680 | + * If there are fewer than four bytes | |
| 1681 | + * remaining in this buffer | |
| 1682 | + * | |
| 1683 | + * @throws ReadOnlyBufferException | |
| 1684 | + * If this buffer is read-only | |
| 1685 | + */ | |
| 1686 | + public abstract ByteBuffer putInt(int value); | |
| 1687 | + | |
| 1688 | + /** | |
| 1689 | + * Absolute <i>get</i> method for reading an int value. | |
| 1690 | + * | |
| 1691 | + * <p> Reads four bytes at the given index, composing them into a | |
| 1692 | + * int value according to the current byte order. </p> | |
| 1693 | + * | |
| 1694 | + * @param index | |
| 1695 | + * The index from which the bytes will be read | |
| 1696 | + * | |
| 1697 | + * @return The int value at the given index | |
| 1698 | + * | |
| 1699 | + * @throws IndexOutOfBoundsException | |
| 1700 | + * If <tt>index</tt> is negative | |
| 1701 | + * or not smaller than the buffer's limit, | |
| 1702 | + * minus three | |
| 1703 | + */ | |
| 1704 | + public abstract int getInt(int index); | |
| 1705 | + | |
| 1706 | + /** | |
| 1707 | + * Absolute <i>put</i> method for writing an int | |
| 1708 | + * value <i>(optional operation)</i>. | |
| 1709 | + * | |
| 1710 | + * <p> Writes four bytes containing the given int value, in the | |
| 1711 | + * current byte order, into this buffer at the given index. </p> | |
| 1712 | + * | |
| 1713 | + * @param index | |
| 1714 | + * The index at which the bytes will be written | |
| 1715 | + * | |
| 1716 | + * @param value | |
| 1717 | + * The int value to be written | |
| 1718 | + * | |
| 1719 | + * @return This buffer | |
| 1720 | + * | |
| 1721 | + * @throws IndexOutOfBoundsException | |
| 1722 | + * If <tt>index</tt> is negative | |
| 1723 | + * or not smaller than the buffer's limit, | |
| 1724 | + * minus three | |
| 1725 | + * | |
| 1726 | + * @throws ReadOnlyBufferException | |
| 1727 | + * If this buffer is read-only | |
| 1728 | + */ | |
| 1729 | + public abstract ByteBuffer putInt(int index, int value); | |
| 1730 | + | |
| 1731 | + /** | |
| 1732 | + * Creates a view of this byte buffer as an int buffer. | |
| 1733 | + * | |
| 1734 | + * <p> The content of the new buffer will start at this buffer's current | |
| 1735 | + * position. Changes to this buffer's content will be visible in the new | |
| 1736 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 1737 | + * values will be independent. | |
| 1738 | + * | |
| 1739 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 1740 | + * will be the number of bytes remaining in this buffer divided by | |
| 1741 | + * four, and its mark will be undefined. The new buffer will be direct | |
| 1742 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 1743 | + * only if, this buffer is read-only. </p> | |
| 1744 | + * | |
| 1745 | + * @return A new int buffer | |
| 1746 | + */ | |
| 1747 | + public abstract IntBuffer asIntBuffer(); | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + /** | |
| 1751 | + * Relative <i>get</i> method for reading a long value. | |
| 1752 | + * | |
| 1753 | + * <p> Reads the next eight bytes at this buffer's current position, | |
| 1754 | + * composing them into a long value according to the current byte order, | |
| 1755 | + * and then increments the position by eight. </p> | |
| 1756 | + * | |
| 1757 | + * @return The long value at the buffer's current position | |
| 1758 | + * | |
| 1759 | + * @throws BufferUnderflowException | |
| 1760 | + * If there are fewer than eight bytes | |
| 1761 | + * remaining in this buffer | |
| 1762 | + */ | |
| 1763 | + public abstract long getLong(); | |
| 1764 | + | |
| 1765 | + /** | |
| 1766 | + * Relative <i>put</i> method for writing a long | |
| 1767 | + * value <i>(optional operation)</i>. | |
| 1768 | + * | |
| 1769 | + * <p> Writes eight bytes containing the given long value, in the | |
| 1770 | + * current byte order, into this buffer at the current position, and then | |
| 1771 | + * increments the position by eight. </p> | |
| 1772 | + * | |
| 1773 | + * @param value | |
| 1774 | + * The long value to be written | |
| 1775 | + * | |
| 1776 | + * @return This buffer | |
| 1777 | + * | |
| 1778 | + * @throws BufferOverflowException | |
| 1779 | + * If there are fewer than eight bytes | |
| 1780 | + * remaining in this buffer | |
| 1781 | + * | |
| 1782 | + * @throws ReadOnlyBufferException | |
| 1783 | + * If this buffer is read-only | |
| 1784 | + */ | |
| 1785 | + public abstract ByteBuffer putLong(long value); | |
| 1786 | + | |
| 1787 | + /** | |
| 1788 | + * Absolute <i>get</i> method for reading a long value. | |
| 1789 | + * | |
| 1790 | + * <p> Reads eight bytes at the given index, composing them into a | |
| 1791 | + * long value according to the current byte order. </p> | |
| 1792 | + * | |
| 1793 | + * @param index | |
| 1794 | + * The index from which the bytes will be read | |
| 1795 | + * | |
| 1796 | + * @return The long value at the given index | |
| 1797 | + * | |
| 1798 | + * @throws IndexOutOfBoundsException | |
| 1799 | + * If <tt>index</tt> is negative | |
| 1800 | + * or not smaller than the buffer's limit, | |
| 1801 | + * minus seven | |
| 1802 | + */ | |
| 1803 | + public abstract long getLong(int index); | |
| 1804 | + | |
| 1805 | + /** | |
| 1806 | + * Absolute <i>put</i> method for writing a long | |
| 1807 | + * value <i>(optional operation)</i>. | |
| 1808 | + * | |
| 1809 | + * <p> Writes eight bytes containing the given long value, in the | |
| 1810 | + * current byte order, into this buffer at the given index. </p> | |
| 1811 | + * | |
| 1812 | + * @param index | |
| 1813 | + * The index at which the bytes will be written | |
| 1814 | + * | |
| 1815 | + * @param value | |
| 1816 | + * The long value to be written | |
| 1817 | + * | |
| 1818 | + * @return This buffer | |
| 1819 | + * | |
| 1820 | + * @throws IndexOutOfBoundsException | |
| 1821 | + * If <tt>index</tt> is negative | |
| 1822 | + * or not smaller than the buffer's limit, | |
| 1823 | + * minus seven | |
| 1824 | + * | |
| 1825 | + * @throws ReadOnlyBufferException | |
| 1826 | + * If this buffer is read-only | |
| 1827 | + */ | |
| 1828 | + public abstract ByteBuffer putLong(int index, long value); | |
| 1829 | + | |
| 1830 | + /** | |
| 1831 | + * Creates a view of this byte buffer as a long buffer. | |
| 1832 | + * | |
| 1833 | + * <p> The content of the new buffer will start at this buffer's current | |
| 1834 | + * position. Changes to this buffer's content will be visible in the new | |
| 1835 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 1836 | + * values will be independent. | |
| 1837 | + * | |
| 1838 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 1839 | + * will be the number of bytes remaining in this buffer divided by | |
| 1840 | + * eight, and its mark will be undefined. The new buffer will be direct | |
| 1841 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 1842 | + * only if, this buffer is read-only. </p> | |
| 1843 | + * | |
| 1844 | + * @return A new long buffer | |
| 1845 | + */ | |
| 1846 | + public abstract LongBuffer asLongBuffer(); | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + /** | |
| 1850 | + * Relative <i>get</i> method for reading a float value. | |
| 1851 | + * | |
| 1852 | + * <p> Reads the next four bytes at this buffer's current position, | |
| 1853 | + * composing them into a float value according to the current byte order, | |
| 1854 | + * and then increments the position by four. </p> | |
| 1855 | + * | |
| 1856 | + * @return The float value at the buffer's current position | |
| 1857 | + * | |
| 1858 | + * @throws BufferUnderflowException | |
| 1859 | + * If there are fewer than four bytes | |
| 1860 | + * remaining in this buffer | |
| 1861 | + */ | |
| 1862 | + public abstract float getFloat(); | |
| 1863 | + | |
| 1864 | + /** | |
| 1865 | + * Relative <i>put</i> method for writing a float | |
| 1866 | + * value <i>(optional operation)</i>. | |
| 1867 | + * | |
| 1868 | + * <p> Writes four bytes containing the given float value, in the | |
| 1869 | + * current byte order, into this buffer at the current position, and then | |
| 1870 | + * increments the position by four. </p> | |
| 1871 | + * | |
| 1872 | + * @param value | |
| 1873 | + * The float value to be written | |
| 1874 | + * | |
| 1875 | + * @return This buffer | |
| 1876 | + * | |
| 1877 | + * @throws BufferOverflowException | |
| 1878 | + * If there are fewer than four bytes | |
| 1879 | + * remaining in this buffer | |
| 1880 | + * | |
| 1881 | + * @throws ReadOnlyBufferException | |
| 1882 | + * If this buffer is read-only | |
| 1883 | + */ | |
| 1884 | + public abstract ByteBuffer putFloat(float value); | |
| 1885 | + | |
| 1886 | + /** | |
| 1887 | + * Absolute <i>get</i> method for reading a float value. | |
| 1888 | + * | |
| 1889 | + * <p> Reads four bytes at the given index, composing them into a | |
| 1890 | + * float value according to the current byte order. </p> | |
| 1891 | + * | |
| 1892 | + * @param index | |
| 1893 | + * The index from which the bytes will be read | |
| 1894 | + * | |
| 1895 | + * @return The float value at the given index | |
| 1896 | + * | |
| 1897 | + * @throws IndexOutOfBoundsException | |
| 1898 | + * If <tt>index</tt> is negative | |
| 1899 | + * or not smaller than the buffer's limit, | |
| 1900 | + * minus three | |
| 1901 | + */ | |
| 1902 | + public abstract float getFloat(int index); | |
| 1903 | + | |
| 1904 | + /** | |
| 1905 | + * Absolute <i>put</i> method for writing a float | |
| 1906 | + * value <i>(optional operation)</i>. | |
| 1907 | + * | |
| 1908 | + * <p> Writes four bytes containing the given float value, in the | |
| 1909 | + * current byte order, into this buffer at the given index. </p> | |
| 1910 | + * | |
| 1911 | + * @param index | |
| 1912 | + * The index at which the bytes will be written | |
| 1913 | + * | |
| 1914 | + * @param value | |
| 1915 | + * The float value to be written | |
| 1916 | + * | |
| 1917 | + * @return This buffer | |
| 1918 | + * | |
| 1919 | + * @throws IndexOutOfBoundsException | |
| 1920 | + * If <tt>index</tt> is negative | |
| 1921 | + * or not smaller than the buffer's limit, | |
| 1922 | + * minus three | |
| 1923 | + * | |
| 1924 | + * @throws ReadOnlyBufferException | |
| 1925 | + * If this buffer is read-only | |
| 1926 | + */ | |
| 1927 | + public abstract ByteBuffer putFloat(int index, float value); | |
| 1928 | + | |
| 1929 | + /** | |
| 1930 | + * Creates a view of this byte buffer as a float buffer. | |
| 1931 | + * | |
| 1932 | + * <p> The content of the new buffer will start at this buffer's current | |
| 1933 | + * position. Changes to this buffer's content will be visible in the new | |
| 1934 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 1935 | + * values will be independent. | |
| 1936 | + * | |
| 1937 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 1938 | + * will be the number of bytes remaining in this buffer divided by | |
| 1939 | + * four, and its mark will be undefined. The new buffer will be direct | |
| 1940 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 1941 | + * only if, this buffer is read-only. </p> | |
| 1942 | + * | |
| 1943 | + * @return A new float buffer | |
| 1944 | + */ | |
| 1945 | + public abstract FloatBuffer asFloatBuffer(); | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + /** | |
| 1949 | + * Relative <i>get</i> method for reading a double value. | |
| 1950 | + * | |
| 1951 | + * <p> Reads the next eight bytes at this buffer's current position, | |
| 1952 | + * composing them into a double value according to the current byte order, | |
| 1953 | + * and then increments the position by eight. </p> | |
| 1954 | + * | |
| 1955 | + * @return The double value at the buffer's current position | |
| 1956 | + * | |
| 1957 | + * @throws BufferUnderflowException | |
| 1958 | + * If there are fewer than eight bytes | |
| 1959 | + * remaining in this buffer | |
| 1960 | + */ | |
| 1961 | + public abstract double getDouble(); | |
| 1962 | + | |
| 1963 | + /** | |
| 1964 | + * Relative <i>put</i> method for writing a double | |
| 1965 | + * value <i>(optional operation)</i>. | |
| 1966 | + * | |
| 1967 | + * <p> Writes eight bytes containing the given double value, in the | |
| 1968 | + * current byte order, into this buffer at the current position, and then | |
| 1969 | + * increments the position by eight. </p> | |
| 1970 | + * | |
| 1971 | + * @param value | |
| 1972 | + * The double value to be written | |
| 1973 | + * | |
| 1974 | + * @return This buffer | |
| 1975 | + * | |
| 1976 | + * @throws BufferOverflowException | |
| 1977 | + * If there are fewer than eight bytes | |
| 1978 | + * remaining in this buffer | |
| 1979 | + * | |
| 1980 | + * @throws ReadOnlyBufferException | |
| 1981 | + * If this buffer is read-only | |
| 1982 | + */ | |
| 1983 | + public abstract ByteBuffer putDouble(double value); | |
| 1984 | + | |
| 1985 | + /** | |
| 1986 | + * Absolute <i>get</i> method for reading a double value. | |
| 1987 | + * | |
| 1988 | + * <p> Reads eight bytes at the given index, composing them into a | |
| 1989 | + * double value according to the current byte order. </p> | |
| 1990 | + * | |
| 1991 | + * @param index | |
| 1992 | + * The index from which the bytes will be read | |
| 1993 | + * | |
| 1994 | + * @return The double value at the given index | |
| 1995 | + * | |
| 1996 | + * @throws IndexOutOfBoundsException | |
| 1997 | + * If <tt>index</tt> is negative | |
| 1998 | + * or not smaller than the buffer's limit, | |
| 1999 | + * minus seven | |
| 2000 | + */ | |
| 2001 | + public abstract double getDouble(int index); | |
| 2002 | + | |
| 2003 | + /** | |
| 2004 | + * Absolute <i>put</i> method for writing a double | |
| 2005 | + * value <i>(optional operation)</i>. | |
| 2006 | + * | |
| 2007 | + * <p> Writes eight bytes containing the given double value, in the | |
| 2008 | + * current byte order, into this buffer at the given index. </p> | |
| 2009 | + * | |
| 2010 | + * @param index | |
| 2011 | + * The index at which the bytes will be written | |
| 2012 | + * | |
| 2013 | + * @param value | |
| 2014 | + * The double value to be written | |
| 2015 | + * | |
| 2016 | + * @return This buffer | |
| 2017 | + * | |
| 2018 | + * @throws IndexOutOfBoundsException | |
| 2019 | + * If <tt>index</tt> is negative | |
| 2020 | + * or not smaller than the buffer's limit, | |
| 2021 | + * minus seven | |
| 2022 | + * | |
| 2023 | + * @throws ReadOnlyBufferException | |
| 2024 | + * If this buffer is read-only | |
| 2025 | + */ | |
| 2026 | + public abstract ByteBuffer putDouble(int index, double value); | |
| 2027 | + | |
| 2028 | + /** | |
| 2029 | + * Creates a view of this byte buffer as a double buffer. | |
| 2030 | + * | |
| 2031 | + * <p> The content of the new buffer will start at this buffer's current | |
| 2032 | + * position. Changes to this buffer's content will be visible in the new | |
| 2033 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 2034 | + * values will be independent. | |
| 2035 | + * | |
| 2036 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 2037 | + * will be the number of bytes remaining in this buffer divided by | |
| 2038 | + * eight, and its mark will be undefined. The new buffer will be direct | |
| 2039 | + * if, and only if, this buffer is direct, and it will be read-only if, and | |
| 2040 | + * only if, this buffer is read-only. </p> | |
| 2041 | + * | |
| 2042 | + * @return A new double buffer | |
| 2043 | + */ | |
| 2044 | + public abstract DoubleBuffer asDoubleBuffer(); | |
| 2045 | + | |
| 2046 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsCharBufferB // package-private | |
| 32 | + extends CharBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsCharBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 1, | |
| 46 | + bb.remaining() >> 1); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsCharBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public CharBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsCharBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public CharBuffer duplicate() { | |
| 83 | + return new ByteBufferAsCharBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public CharBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsCharBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 1) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public char get() { | |
| 111 | + return Bits.getCharB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public char get(int i) { | |
| 115 | + return Bits.getCharB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public CharBuffer put(char x) { | |
| 121 | + | |
| 122 | + Bits.putCharB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public CharBuffer put(int i, char x) { | |
| 130 | + | |
| 131 | + Bits.putCharB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public CharBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 1); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + public String toString(int start, int end) { | |
| 171 | + if ((end > limit()) || (start > end)) | |
| 172 | + throw new IndexOutOfBoundsException(); | |
| 173 | + try { | |
| 174 | + int len = end - start; | |
| 175 | + char[] ca = new char[len]; | |
| 176 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 177 | + CharBuffer db = this.duplicate(); | |
| 178 | + db.position(start); | |
| 179 | + db.limit(end); | |
| 180 | + cb.put(db); | |
| 181 | + return new String(ca); | |
| 182 | + } catch (StringIndexOutOfBoundsException x) { | |
| 183 | + throw new IndexOutOfBoundsException(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + // --- Methods to support CharSequence --- | |
| 189 | + | |
| 190 | + public CharBuffer subSequence(int start, int end) { | |
| 191 | + int pos = position(); | |
| 192 | + int lim = limit(); | |
| 193 | + assert (pos <= lim); | |
| 194 | + pos = (pos <= lim ? pos : lim); | |
| 195 | + int len = lim - pos; | |
| 196 | + | |
| 197 | + if ((start < 0) || (end > len) || (start > end)) | |
| 198 | + throw new IndexOutOfBoundsException(); | |
| 199 | + return new ByteBufferAsCharBufferB(bb, | |
| 200 | + -1, | |
| 201 | + pos + start, | |
| 202 | + pos + end, | |
| 203 | + capacity(), | |
| 204 | + offset); | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsCharBufferL // package-private | |
| 32 | + extends CharBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsCharBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 1, | |
| 46 | + bb.remaining() >> 1); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsCharBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public CharBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsCharBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public CharBuffer duplicate() { | |
| 83 | + return new ByteBufferAsCharBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public CharBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsCharBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 1) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public char get() { | |
| 111 | + return Bits.getCharL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public char get(int i) { | |
| 115 | + return Bits.getCharL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public CharBuffer put(char x) { | |
| 121 | + | |
| 122 | + Bits.putCharL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public CharBuffer put(int i, char x) { | |
| 130 | + | |
| 131 | + Bits.putCharL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public CharBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 1); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + public String toString(int start, int end) { | |
| 171 | + if ((end > limit()) || (start > end)) | |
| 172 | + throw new IndexOutOfBoundsException(); | |
| 173 | + try { | |
| 174 | + int len = end - start; | |
| 175 | + char[] ca = new char[len]; | |
| 176 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 177 | + CharBuffer db = this.duplicate(); | |
| 178 | + db.position(start); | |
| 179 | + db.limit(end); | |
| 180 | + cb.put(db); | |
| 181 | + return new String(ca); | |
| 182 | + } catch (StringIndexOutOfBoundsException x) { | |
| 183 | + throw new IndexOutOfBoundsException(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + // --- Methods to support CharSequence --- | |
| 189 | + | |
| 190 | + public CharBuffer subSequence(int start, int end) { | |
| 191 | + int pos = position(); | |
| 192 | + int lim = limit(); | |
| 193 | + assert (pos <= lim); | |
| 194 | + pos = (pos <= lim ? pos : lim); | |
| 195 | + int len = lim - pos; | |
| 196 | + | |
| 197 | + if ((start < 0) || (end > len) || (start > end)) | |
| 198 | + throw new IndexOutOfBoundsException(); | |
| 199 | + return new ByteBufferAsCharBufferL(bb, | |
| 200 | + -1, | |
| 201 | + pos + start, | |
| 202 | + pos + end, | |
| 203 | + capacity(), | |
| 204 | + offset); | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsCharBufferRB // package-private | |
| 32 | + extends ByteBufferAsCharBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsCharBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsCharBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public CharBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsCharBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public CharBuffer duplicate() { | |
| 83 | + return new ByteBufferAsCharBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public CharBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public CharBuffer put(char x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public CharBuffer put(int i, char x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public CharBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + public String toString(int start, int end) { | |
| 171 | + if ((end > limit()) || (start > end)) | |
| 172 | + throw new IndexOutOfBoundsException(); | |
| 173 | + try { | |
| 174 | + int len = end - start; | |
| 175 | + char[] ca = new char[len]; | |
| 176 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 177 | + CharBuffer db = this.duplicate(); | |
| 178 | + db.position(start); | |
| 179 | + db.limit(end); | |
| 180 | + cb.put(db); | |
| 181 | + return new String(ca); | |
| 182 | + } catch (StringIndexOutOfBoundsException x) { | |
| 183 | + throw new IndexOutOfBoundsException(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + // --- Methods to support CharSequence --- | |
| 189 | + | |
| 190 | + public CharBuffer subSequence(int start, int end) { | |
| 191 | + int pos = position(); | |
| 192 | + int lim = limit(); | |
| 193 | + assert (pos <= lim); | |
| 194 | + pos = (pos <= lim ? pos : lim); | |
| 195 | + int len = lim - pos; | |
| 196 | + | |
| 197 | + if ((start < 0) || (end > len) || (start > end)) | |
| 198 | + throw new IndexOutOfBoundsException(); | |
| 199 | + return new ByteBufferAsCharBufferRB(bb, | |
| 200 | + -1, | |
| 201 | + pos + start, | |
| 202 | + pos + end, | |
| 203 | + capacity(), | |
| 204 | + offset); | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsCharBufferRL // package-private | |
| 32 | + extends ByteBufferAsCharBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsCharBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsCharBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public CharBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsCharBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public CharBuffer duplicate() { | |
| 83 | + return new ByteBufferAsCharBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public CharBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public CharBuffer put(char x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public CharBuffer put(int i, char x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public CharBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + public String toString(int start, int end) { | |
| 171 | + if ((end > limit()) || (start > end)) | |
| 172 | + throw new IndexOutOfBoundsException(); | |
| 173 | + try { | |
| 174 | + int len = end - start; | |
| 175 | + char[] ca = new char[len]; | |
| 176 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 177 | + CharBuffer db = this.duplicate(); | |
| 178 | + db.position(start); | |
| 179 | + db.limit(end); | |
| 180 | + cb.put(db); | |
| 181 | + return new String(ca); | |
| 182 | + } catch (StringIndexOutOfBoundsException x) { | |
| 183 | + throw new IndexOutOfBoundsException(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + // --- Methods to support CharSequence --- | |
| 189 | + | |
| 190 | + public CharBuffer subSequence(int start, int end) { | |
| 191 | + int pos = position(); | |
| 192 | + int lim = limit(); | |
| 193 | + assert (pos <= lim); | |
| 194 | + pos = (pos <= lim ? pos : lim); | |
| 195 | + int len = lim - pos; | |
| 196 | + | |
| 197 | + if ((start < 0) || (end > len) || (start > end)) | |
| 198 | + throw new IndexOutOfBoundsException(); | |
| 199 | + return new ByteBufferAsCharBufferRL(bb, | |
| 200 | + -1, | |
| 201 | + pos + start, | |
| 202 | + pos + end, | |
| 203 | + capacity(), | |
| 204 | + offset); | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsDoubleBufferB // package-private | |
| 32 | + extends DoubleBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsDoubleBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 3, | |
| 46 | + bb.remaining() >> 3); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsDoubleBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public DoubleBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsDoubleBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public DoubleBuffer duplicate() { | |
| 83 | + return new ByteBufferAsDoubleBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsDoubleBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 3) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public double get() { | |
| 111 | + return Bits.getDoubleB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public double get(int i) { | |
| 115 | + return Bits.getDoubleB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public DoubleBuffer put(double x) { | |
| 121 | + | |
| 122 | + Bits.putDoubleB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public DoubleBuffer put(int i, double x) { | |
| 130 | + | |
| 131 | + Bits.putDoubleB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public DoubleBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 3); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsDoubleBufferL // package-private | |
| 32 | + extends DoubleBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsDoubleBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 3, | |
| 46 | + bb.remaining() >> 3); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsDoubleBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public DoubleBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsDoubleBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public DoubleBuffer duplicate() { | |
| 83 | + return new ByteBufferAsDoubleBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsDoubleBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 3) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public double get() { | |
| 111 | + return Bits.getDoubleL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public double get(int i) { | |
| 115 | + return Bits.getDoubleL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public DoubleBuffer put(double x) { | |
| 121 | + | |
| 122 | + Bits.putDoubleL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public DoubleBuffer put(int i, double x) { | |
| 130 | + | |
| 131 | + Bits.putDoubleL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public DoubleBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 3); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsDoubleBufferRB // package-private | |
| 32 | + extends ByteBufferAsDoubleBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsDoubleBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsDoubleBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public DoubleBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsDoubleBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public DoubleBuffer duplicate() { | |
| 83 | + return new ByteBufferAsDoubleBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public DoubleBuffer put(double x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public DoubleBuffer put(int i, double x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public DoubleBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsDoubleBufferRL // package-private | |
| 32 | + extends ByteBufferAsDoubleBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsDoubleBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsDoubleBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public DoubleBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsDoubleBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public DoubleBuffer duplicate() { | |
| 83 | + return new ByteBufferAsDoubleBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public DoubleBuffer put(double x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public DoubleBuffer put(int i, double x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public DoubleBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsFloatBufferB // package-private | |
| 32 | + extends FloatBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsFloatBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 2, | |
| 46 | + bb.remaining() >> 2); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsFloatBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public FloatBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsFloatBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public FloatBuffer duplicate() { | |
| 83 | + return new ByteBufferAsFloatBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public FloatBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsFloatBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 2) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public float get() { | |
| 111 | + return Bits.getFloatB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public float get(int i) { | |
| 115 | + return Bits.getFloatB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public FloatBuffer put(float x) { | |
| 121 | + | |
| 122 | + Bits.putFloatB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public FloatBuffer put(int i, float x) { | |
| 130 | + | |
| 131 | + Bits.putFloatB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public FloatBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 2); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsFloatBufferL // package-private | |
| 32 | + extends FloatBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsFloatBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 2, | |
| 46 | + bb.remaining() >> 2); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsFloatBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public FloatBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsFloatBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public FloatBuffer duplicate() { | |
| 83 | + return new ByteBufferAsFloatBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public FloatBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsFloatBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 2) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public float get() { | |
| 111 | + return Bits.getFloatL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public float get(int i) { | |
| 115 | + return Bits.getFloatL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public FloatBuffer put(float x) { | |
| 121 | + | |
| 122 | + Bits.putFloatL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public FloatBuffer put(int i, float x) { | |
| 130 | + | |
| 131 | + Bits.putFloatL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public FloatBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 2); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsFloatBufferRB // package-private | |
| 32 | + extends ByteBufferAsFloatBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsFloatBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsFloatBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public FloatBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsFloatBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public FloatBuffer duplicate() { | |
| 83 | + return new ByteBufferAsFloatBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public FloatBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public FloatBuffer put(float x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public FloatBuffer put(int i, float x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public FloatBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsFloatBufferRL // package-private | |
| 32 | + extends ByteBufferAsFloatBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsFloatBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsFloatBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public FloatBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsFloatBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public FloatBuffer duplicate() { | |
| 83 | + return new ByteBufferAsFloatBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public FloatBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public FloatBuffer put(float x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public FloatBuffer put(int i, float x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public FloatBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsIntBufferB // package-private | |
| 32 | + extends IntBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsIntBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 2, | |
| 46 | + bb.remaining() >> 2); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsIntBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public IntBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsIntBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public IntBuffer duplicate() { | |
| 83 | + return new ByteBufferAsIntBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public IntBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsIntBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 2) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public int get() { | |
| 111 | + return Bits.getIntB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public int get(int i) { | |
| 115 | + return Bits.getIntB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public IntBuffer put(int x) { | |
| 121 | + | |
| 122 | + Bits.putIntB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public IntBuffer put(int i, int x) { | |
| 130 | + | |
| 131 | + Bits.putIntB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public IntBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 2); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsIntBufferL // package-private | |
| 32 | + extends IntBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsIntBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 2, | |
| 46 | + bb.remaining() >> 2); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsIntBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public IntBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsIntBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public IntBuffer duplicate() { | |
| 83 | + return new ByteBufferAsIntBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public IntBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsIntBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 2) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public int get() { | |
| 111 | + return Bits.getIntL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public int get(int i) { | |
| 115 | + return Bits.getIntL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public IntBuffer put(int x) { | |
| 121 | + | |
| 122 | + Bits.putIntL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public IntBuffer put(int i, int x) { | |
| 130 | + | |
| 131 | + Bits.putIntL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public IntBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 2); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsIntBufferRB // package-private | |
| 32 | + extends ByteBufferAsIntBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsIntBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsIntBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public IntBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsIntBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public IntBuffer duplicate() { | |
| 83 | + return new ByteBufferAsIntBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public IntBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public IntBuffer put(int x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public IntBuffer put(int i, int x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public IntBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsIntBufferRL // package-private | |
| 32 | + extends ByteBufferAsIntBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsIntBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsIntBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public IntBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 2) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsIntBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public IntBuffer duplicate() { | |
| 83 | + return new ByteBufferAsIntBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public IntBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public IntBuffer put(int x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public IntBuffer put(int i, int x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public IntBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsLongBufferB // package-private | |
| 32 | + extends LongBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsLongBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 3, | |
| 46 | + bb.remaining() >> 3); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsLongBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public LongBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsLongBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public LongBuffer duplicate() { | |
| 83 | + return new ByteBufferAsLongBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public LongBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsLongBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 3) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public long get() { | |
| 111 | + return Bits.getLongB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public long get(int i) { | |
| 115 | + return Bits.getLongB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public LongBuffer put(long x) { | |
| 121 | + | |
| 122 | + Bits.putLongB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public LongBuffer put(int i, long x) { | |
| 130 | + | |
| 131 | + Bits.putLongB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public LongBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 3); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsLongBufferL // package-private | |
| 32 | + extends LongBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsLongBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 3, | |
| 46 | + bb.remaining() >> 3); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsLongBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public LongBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsLongBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public LongBuffer duplicate() { | |
| 83 | + return new ByteBufferAsLongBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public LongBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsLongBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 3) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public long get() { | |
| 111 | + return Bits.getLongL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public long get(int i) { | |
| 115 | + return Bits.getLongL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public LongBuffer put(long x) { | |
| 121 | + | |
| 122 | + Bits.putLongL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public LongBuffer put(int i, long x) { | |
| 130 | + | |
| 131 | + Bits.putLongL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public LongBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 3); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsLongBufferRB // package-private | |
| 32 | + extends ByteBufferAsLongBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsLongBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsLongBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public LongBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsLongBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public LongBuffer duplicate() { | |
| 83 | + return new ByteBufferAsLongBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public LongBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public LongBuffer put(long x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public LongBuffer put(int i, long x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public LongBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsLongBufferRL // package-private | |
| 32 | + extends ByteBufferAsLongBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsLongBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsLongBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public LongBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 3) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsLongBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public LongBuffer duplicate() { | |
| 83 | + return new ByteBufferAsLongBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public LongBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public LongBuffer put(long x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public LongBuffer put(int i, long x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public LongBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsShortBufferB // package-private | |
| 32 | + extends ShortBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsShortBufferB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 1, | |
| 46 | + bb.remaining() >> 1); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsShortBufferB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public ShortBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsShortBufferB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public ShortBuffer duplicate() { | |
| 83 | + return new ByteBufferAsShortBufferB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public ShortBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsShortBufferRB(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 1) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public short get() { | |
| 111 | + return Bits.getShortB(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public short get(int i) { | |
| 115 | + return Bits.getShortB(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public ShortBuffer put(short x) { | |
| 121 | + | |
| 122 | + Bits.putShortB(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public ShortBuffer put(int i, short x) { | |
| 130 | + | |
| 131 | + Bits.putShortB(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public ShortBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 1); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsShortBufferL // package-private | |
| 32 | + extends ShortBuffer | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + protected final ByteBuffer bb; | |
| 38 | + protected final int offset; | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsShortBufferL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + super(-1, 0, | |
| 45 | + bb.remaining() >> 1, | |
| 46 | + bb.remaining() >> 1); | |
| 47 | + this.bb = bb; | |
| 48 | + // enforce limit == capacity | |
| 49 | + int cap = this.capacity(); | |
| 50 | + this.limit(cap); | |
| 51 | + int pos = this.position(); | |
| 52 | + assert (pos <= cap); | |
| 53 | + offset = pos; | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsShortBufferL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + super(mark, pos, lim, cap); | |
| 65 | + this.bb = bb; | |
| 66 | + offset = off; | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public ShortBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsShortBufferL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public ShortBuffer duplicate() { | |
| 83 | + return new ByteBufferAsShortBufferL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public ShortBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + return new ByteBufferAsShortBufferRL(bb, | |
| 94 | + this.markValue(), | |
| 95 | + this.position(), | |
| 96 | + this.limit(), | |
| 97 | + this.capacity(), | |
| 98 | + offset); | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + protected int ix(int i) { | |
| 107 | + return (i << 1) + offset; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public short get() { | |
| 111 | + return Bits.getShortL(bb, ix(nextGetIndex())); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public short get(int i) { | |
| 115 | + return Bits.getShortL(bb, ix(checkIndex(i))); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public ShortBuffer put(short x) { | |
| 121 | + | |
| 122 | + Bits.putShortL(bb, ix(nextPutIndex()), x); | |
| 123 | + return this; | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public ShortBuffer put(int i, short x) { | |
| 130 | + | |
| 131 | + Bits.putShortL(bb, ix(checkIndex(i)), x); | |
| 132 | + return this; | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public ShortBuffer compact() { | |
| 139 | + | |
| 140 | + int pos = position(); | |
| 141 | + int lim = limit(); | |
| 142 | + assert (pos <= lim); | |
| 143 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 144 | + | |
| 145 | + ByteBuffer db = bb.duplicate(); | |
| 146 | + db.limit(ix(lim)); | |
| 147 | + db.position(ix(0)); | |
| 148 | + ByteBuffer sb = db.slice(); | |
| 149 | + sb.position(pos << 1); | |
| 150 | + sb.compact(); | |
| 151 | + position(rem); | |
| 152 | + limit(capacity()); | |
| 153 | + discardMark(); | |
| 154 | + return this; | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return false; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsShortBufferRB // package-private | |
| 32 | + extends ByteBufferAsShortBufferB | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsShortBufferRB(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsShortBufferRB(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public ShortBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsShortBufferRB(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public ShortBuffer duplicate() { | |
| 83 | + return new ByteBufferAsShortBufferRB(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public ShortBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public ShortBuffer put(short x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public ShortBuffer put(int i, short x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public ShortBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + return ByteOrder.BIG_ENDIAN; | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,219 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +class ByteBufferAsShortBufferRL // package-private | |
| 32 | + extends ByteBufferAsShortBufferL | |
| 33 | +{ | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + ByteBufferAsShortBufferRL(ByteBuffer bb) { // package-private | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + super(bb); | |
| 56 | + | |
| 57 | + } | |
| 58 | + | |
| 59 | + ByteBufferAsShortBufferRL(ByteBuffer bb, | |
| 60 | + int mark, int pos, int lim, int cap, | |
| 61 | + int off) | |
| 62 | + { | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + super(bb, mark, pos, lim, cap, off); | |
| 69 | + | |
| 70 | + } | |
| 71 | + | |
| 72 | + public ShortBuffer slice() { | |
| 73 | + int pos = this.position(); | |
| 74 | + int lim = this.limit(); | |
| 75 | + assert (pos <= lim); | |
| 76 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 77 | + int off = (pos << 1) + offset; | |
| 78 | + assert (off >= 0); | |
| 79 | + return new ByteBufferAsShortBufferRL(bb, -1, 0, rem, rem, off); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public ShortBuffer duplicate() { | |
| 83 | + return new ByteBufferAsShortBufferRL(bb, | |
| 84 | + this.markValue(), | |
| 85 | + this.position(), | |
| 86 | + this.limit(), | |
| 87 | + this.capacity(), | |
| 88 | + offset); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public ShortBuffer asReadOnlyBuffer() { | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + return duplicate(); | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + public ShortBuffer put(short x) { | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + throw new ReadOnlyBufferException(); | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + public ShortBuffer put(int i, short x) { | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + throw new ReadOnlyBufferException(); | |
| 135 | + | |
| 136 | + } | |
| 137 | + | |
| 138 | + public ShortBuffer compact() { | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + throw new ReadOnlyBufferException(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + | |
| 160 | + public boolean isDirect() { | |
| 161 | + return bb.isDirect(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + public boolean isReadOnly() { | |
| 165 | + return true; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + public ByteOrder order() { | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + return ByteOrder.LITTLE_ENDIAN; | |
| 216 | + | |
| 217 | + } | |
| 218 | + | |
| 219 | +} | |
| @@ -0,0 +1,1463 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | + | |
| 31 | +import java.io.IOException; | |
| 32 | + | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * A char buffer. | |
| 36 | + * | |
| 37 | + * <p> This class defines four categories of operations upon | |
| 38 | + * char buffers: | |
| 39 | + * | |
| 40 | + * <ul> | |
| 41 | + * | |
| 42 | + * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and | |
| 43 | + * {@link #put(char) </code><i>put</i><code>} methods that read and write | |
| 44 | + * single chars; </p></li> | |
| 45 | + * | |
| 46 | + * <li><p> Relative {@link #get(char[]) </code><i>bulk get</i><code>} | |
| 47 | + * methods that transfer contiguous sequences of chars from this buffer | |
| 48 | + * into an array; and</p></li> | |
| 49 | + * | |
| 50 | + * <li><p> Relative {@link #put(char[]) </code><i>bulk put</i><code>} | |
| 51 | + * methods that transfer contiguous sequences of chars from a | |
| 52 | + * char array, a string, or some other char | |
| 53 | + * buffer into this buffer; and </p></li> | |
| 54 | + * | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + * | |
| 68 | + * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link | |
| 69 | + * #duplicate </code>duplicating<code>}, and {@link #slice | |
| 70 | + * </code>slicing<code>} a char buffer. </p></li> | |
| 71 | + * | |
| 72 | + * </ul> | |
| 73 | + * | |
| 74 | + * <p> Char buffers can be created either by {@link #allocate | |
| 75 | + * </code><i>allocation</i><code>}, which allocates space for the buffer's | |
| 76 | + * | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + * | |
| 84 | + * content, by {@link #wrap(char[]) </code><i>wrapping</i><code>} an existing | |
| 85 | + * char array or string into a buffer, or by creating a | |
| 86 | + * <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer. | |
| 87 | + * | |
| 88 | + | |
| 89 | + * | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | +* | |
| 190 | + | |
| 191 | + * | |
| 192 | + * <p> Like a byte buffer, a char buffer is either <a | |
| 193 | + * href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A | |
| 194 | + * char buffer created via the <tt>wrap</tt> methods of this class will | |
| 195 | + * be non-direct. A char buffer created as a view of a byte buffer will | |
| 196 | + * be direct if, and only if, the byte buffer itself is direct. Whether or not | |
| 197 | + * a char buffer is direct may be determined by invoking the {@link | |
| 198 | + * #isDirect isDirect} method. </p> | |
| 199 | + * | |
| 200 | + | |
| 201 | +* | |
| 202 | + | |
| 203 | + * | |
| 204 | + * <p> This class implements the {@link CharSequence} interface so that | |
| 205 | + * character buffers may be used wherever character sequences are accepted, for | |
| 206 | + * example in the regular-expression package <tt>{@link java.util.regex}</tt>. | |
| 207 | + * </p> | |
| 208 | + * | |
| 209 | + | |
| 210 | + * | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + * | |
| 215 | + * <p> Methods in this class that do not otherwise have a value to return are | |
| 216 | + * specified to return the buffer upon which they are invoked. This allows | |
| 217 | + * method invocations to be chained. | |
| 218 | + * | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + * | |
| 236 | + * The sequence of statements | |
| 237 | + * | |
| 238 | + * <blockquote><pre> | |
| 239 | + * cb.put("text/"); | |
| 240 | + * cb.put(subtype); | |
| 241 | + * cb.put("; charset="); | |
| 242 | + * cb.put(enc);</pre></blockquote> | |
| 243 | + * | |
| 244 | + * can, for example, be replaced by the single statement | |
| 245 | + * | |
| 246 | + * <blockquote><pre> | |
| 247 | + * cb.put("text/").put(subtype).put("; charset=").put(enc);</pre></blockquote> | |
| 248 | + * | |
| 249 | + | |
| 250 | + * | |
| 251 | + * | |
| 252 | + * @author Mark Reinhold | |
| 253 | + * @author JSR-51 Expert Group | |
| 254 | + * @since 1.4 | |
| 255 | + */ | |
| 256 | + | |
| 257 | +public abstract class CharBuffer | |
| 258 | + extends Buffer | |
| 259 | + implements Comparable<CharBuffer>, Appendable, CharSequence, Readable | |
| 260 | +{ | |
| 261 | + | |
| 262 | + // These fields are declared here rather than in Heap-X-Buffer in order to | |
| 263 | + // reduce the number of virtual method invocations needed to access these | |
| 264 | + // values, which is especially costly when coding small buffers. | |
| 265 | + // | |
| 266 | + final char[] hb; // Non-null only for heap buffers | |
| 267 | + final int offset; | |
| 268 | + boolean isReadOnly; // Valid only for heap buffers | |
| 269 | + | |
| 270 | + // Creates a new buffer with the given mark, position, limit, capacity, | |
| 271 | + // backing array, and array offset | |
| 272 | + // | |
| 273 | + CharBuffer(int mark, int pos, int lim, int cap, // package-private | |
| 274 | + char[] hb, int offset) | |
| 275 | + { | |
| 276 | + super(mark, pos, lim, cap); | |
| 277 | + this.hb = hb; | |
| 278 | + this.offset = offset; | |
| 279 | + } | |
| 280 | + | |
| 281 | + // Creates a new buffer with the given mark, position, limit, and capacity | |
| 282 | + // | |
| 283 | + CharBuffer(int mark, int pos, int lim, int cap) { // package-private | |
| 284 | + this(mark, pos, lim, cap, null, 0); | |
| 285 | + } | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + /** | |
| 312 | + * Allocates a new char buffer. | |
| 313 | + * | |
| 314 | + * <p> The new buffer's position will be zero, its limit will be its | |
| 315 | + * capacity, its mark will be undefined, and each of its elements will be | |
| 316 | + * initialized to zero. It will have a {@link #array | |
| 317 | + * </code>backing array<code>}, and its {@link #arrayOffset </code>array | |
| 318 | + * offset<code>} will be zero. | |
| 319 | + * | |
| 320 | + * @param capacity | |
| 321 | + * The new buffer's capacity, in chars | |
| 322 | + * | |
| 323 | + * @return The new char buffer | |
| 324 | + * | |
| 325 | + * @throws IllegalArgumentException | |
| 326 | + * If the <tt>capacity</tt> is a negative integer | |
| 327 | + */ | |
| 328 | + public static CharBuffer allocate(int capacity) { | |
| 329 | + if (capacity < 0) | |
| 330 | + throw new IllegalArgumentException(); | |
| 331 | + return new HeapCharBuffer(capacity, capacity); | |
| 332 | + } | |
| 333 | + | |
| 334 | + /** | |
| 335 | + * Wraps a char array into a buffer. | |
| 336 | + * | |
| 337 | + * <p> The new buffer will be backed by the given char array; | |
| 338 | + * that is, modifications to the buffer will cause the array to be modified | |
| 339 | + * and vice versa. The new buffer's capacity will be | |
| 340 | + * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit | |
| 341 | + * will be <tt>offset + length</tt>, and its mark will be undefined. Its | |
| 342 | + * {@link #array </code>backing array<code>} will be the given array, and | |
| 343 | + * its {@link #arrayOffset </code>array offset<code>} will be zero. </p> | |
| 344 | + * | |
| 345 | + * @param array | |
| 346 | + * The array that will back the new buffer | |
| 347 | + * | |
| 348 | + * @param offset | |
| 349 | + * The offset of the subarray to be used; must be non-negative and | |
| 350 | + * no larger than <tt>array.length</tt>. The new buffer's position | |
| 351 | + * will be set to this value. | |
| 352 | + * | |
| 353 | + * @param length | |
| 354 | + * The length of the subarray to be used; | |
| 355 | + * must be non-negative and no larger than | |
| 356 | + * <tt>array.length - offset</tt>. | |
| 357 | + * The new buffer's limit will be set to <tt>offset + length</tt>. | |
| 358 | + * | |
| 359 | + * @return The new char buffer | |
| 360 | + * | |
| 361 | + * @throws IndexOutOfBoundsException | |
| 362 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 363 | + * parameters do not hold | |
| 364 | + */ | |
| 365 | + public static CharBuffer wrap(char[] array, | |
| 366 | + int offset, int length) | |
| 367 | + { | |
| 368 | + try { | |
| 369 | + return new HeapCharBuffer(array, offset, length); | |
| 370 | + } catch (IllegalArgumentException x) { | |
| 371 | + throw new IndexOutOfBoundsException(); | |
| 372 | + } | |
| 373 | + } | |
| 374 | + | |
| 375 | + /** | |
| 376 | + * Wraps a char array into a buffer. | |
| 377 | + * | |
| 378 | + * <p> The new buffer will be backed by the given char array; | |
| 379 | + * that is, modifications to the buffer will cause the array to be modified | |
| 380 | + * and vice versa. The new buffer's capacity and limit will be | |
| 381 | + * <tt>array.length</tt>, its position will be zero, and its mark will be | |
| 382 | + * undefined. Its {@link #array </code>backing array<code>} will be the | |
| 383 | + * given array, and its {@link #arrayOffset </code>array offset<code>} will | |
| 384 | + * be zero. </p> | |
| 385 | + * | |
| 386 | + * @param array | |
| 387 | + * The array that will back this buffer | |
| 388 | + * | |
| 389 | + * @return The new char buffer | |
| 390 | + */ | |
| 391 | + public static CharBuffer wrap(char[] array) { | |
| 392 | + return wrap(array, 0, array.length); | |
| 393 | + } | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + /** | |
| 398 | + * Attempts to read characters into the specified character buffer. | |
| 399 | + * The buffer is used as a repository of characters as-is: the only | |
| 400 | + * changes made are the results of a put operation. No flipping or | |
| 401 | + * rewinding of the buffer is performed. | |
| 402 | + * | |
| 403 | + * @param target the buffer to read characters into | |
| 404 | + * @return The number of characters added to the buffer, or | |
| 405 | + * -1 if this source of characters is at its end | |
| 406 | + * @throws IOException if an I/O error occurs | |
| 407 | + * @throws NullPointerException if target is null | |
| 408 | + * @throws ReadOnlyBufferException if target is a read only buffer | |
| 409 | + * @since 1.5 | |
| 410 | + */ | |
| 411 | + public int read(CharBuffer target) throws IOException { | |
| 412 | + // Determine the number of bytes n that can be transferred | |
| 413 | + int targetRemaining = target.remaining(); | |
| 414 | + int remaining = remaining(); | |
| 415 | + if (remaining == 0) | |
| 416 | + return -1; | |
| 417 | + int n = Math.min(remaining, targetRemaining); | |
| 418 | + int limit = limit(); | |
| 419 | + // Set source limit to prevent target overflow | |
| 420 | + if (targetRemaining < remaining) | |
| 421 | + limit(position() + n); | |
| 422 | + try { | |
| 423 | + if (n > 0) | |
| 424 | + target.put(this); | |
| 425 | + } finally { | |
| 426 | + limit(limit); // restore real limit | |
| 427 | + } | |
| 428 | + return n; | |
| 429 | + } | |
| 430 | + | |
| 431 | + /** | |
| 432 | + * Wraps a character sequence into a buffer. | |
| 433 | + * | |
| 434 | + * <p> The content of the new, read-only buffer will be the content of the | |
| 435 | + * given character sequence. The buffer's capacity will be | |
| 436 | + * <tt>csq.length()</tt>, its position will be <tt>start</tt>, its limit | |
| 437 | + * will be <tt>end</tt>, and its mark will be undefined. </p> | |
| 438 | + * | |
| 439 | + * @param csq | |
| 440 | + * The character sequence from which the new character buffer is to | |
| 441 | + * be created | |
| 442 | + * | |
| 443 | + * @param start | |
| 444 | + * The index of the first character to be used; | |
| 445 | + * must be non-negative and no larger than <tt>csq.length()</tt>. | |
| 446 | + * The new buffer's position will be set to this value. | |
| 447 | + * | |
| 448 | + * @param end | |
| 449 | + * The index of the character following the last character to be | |
| 450 | + * used; must be no smaller than <tt>start</tt> and no larger | |
| 451 | + * than <tt>csq.length()</tt>. | |
| 452 | + * The new buffer's limit will be set to this value. | |
| 453 | + * | |
| 454 | + * @return The new character buffer | |
| 455 | + * | |
| 456 | + * @throws IndexOutOfBoundsException | |
| 457 | + * If the preconditions on the <tt>start</tt> and <tt>end</tt> | |
| 458 | + * parameters do not hold | |
| 459 | + */ | |
| 460 | + public static CharBuffer wrap(CharSequence csq, int start, int end) { | |
| 461 | + try { | |
| 462 | + return new StringCharBuffer(csq, start, end); | |
| 463 | + } catch (IllegalArgumentException x) { | |
| 464 | + throw new IndexOutOfBoundsException(); | |
| 465 | + } | |
| 466 | + } | |
| 467 | + | |
| 468 | + /** | |
| 469 | + * Wraps a character sequence into a buffer. | |
| 470 | + * | |
| 471 | + * <p> The content of the new, read-only buffer will be the content of the | |
| 472 | + * given character sequence. The new buffer's capacity and limit will be | |
| 473 | + * <tt>csq.length()</tt>, its position will be zero, and its mark will be | |
| 474 | + * undefined. </p> | |
| 475 | + * | |
| 476 | + * @param csq | |
| 477 | + * The character sequence from which the new character buffer is to | |
| 478 | + * be created | |
| 479 | + * | |
| 480 | + * @return The new character buffer | |
| 481 | + */ | |
| 482 | + public static CharBuffer wrap(CharSequence csq) { | |
| 483 | + return wrap(csq, 0, csq.length()); | |
| 484 | + } | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + /** | |
| 489 | + * Creates a new char buffer whose content is a shared subsequence of | |
| 490 | + * this buffer's content. | |
| 491 | + * | |
| 492 | + * <p> The content of the new buffer will start at this buffer's current | |
| 493 | + * position. Changes to this buffer's content will be visible in the new | |
| 494 | + * buffer, and vice versa; the two buffers' position, limit, and mark | |
| 495 | + * values will be independent. | |
| 496 | + * | |
| 497 | + * <p> The new buffer's position will be zero, its capacity and its limit | |
| 498 | + * will be the number of chars remaining in this buffer, and its mark | |
| 499 | + * will be undefined. The new buffer will be direct if, and only if, this | |
| 500 | + * buffer is direct, and it will be read-only if, and only if, this buffer | |
| 501 | + * is read-only. </p> | |
| 502 | + * | |
| 503 | + * @return The new char buffer | |
| 504 | + */ | |
| 505 | + public abstract CharBuffer slice(); | |
| 506 | + | |
| 507 | + /** | |
| 508 | + * Creates a new char buffer that shares this buffer's content. | |
| 509 | + * | |
| 510 | + * <p> The content of the new buffer will be that of this buffer. Changes | |
| 511 | + * to this buffer's content will be visible in the new buffer, and vice | |
| 512 | + * versa; the two buffers' position, limit, and mark values will be | |
| 513 | + * independent. | |
| 514 | + * | |
| 515 | + * <p> The new buffer's capacity, limit, position, and mark values will be | |
| 516 | + * identical to those of this buffer. The new buffer will be direct if, | |
| 517 | + * and only if, this buffer is direct, and it will be read-only if, and | |
| 518 | + * only if, this buffer is read-only. </p> | |
| 519 | + * | |
| 520 | + * @return The new char buffer | |
| 521 | + */ | |
| 522 | + public abstract CharBuffer duplicate(); | |
| 523 | + | |
| 524 | + /** | |
| 525 | + * Creates a new, read-only char buffer that shares this buffer's | |
| 526 | + * content. | |
| 527 | + * | |
| 528 | + * <p> The content of the new buffer will be that of this buffer. Changes | |
| 529 | + * to this buffer's content will be visible in the new buffer; the new | |
| 530 | + * buffer itself, however, will be read-only and will not allow the shared | |
| 531 | + * content to be modified. The two buffers' position, limit, and mark | |
| 532 | + * values will be independent. | |
| 533 | + * | |
| 534 | + * <p> The new buffer's capacity, limit, position, and mark values will be | |
| 535 | + * identical to those of this buffer. | |
| 536 | + * | |
| 537 | + * <p> If this buffer is itself read-only then this method behaves in | |
| 538 | + * exactly the same way as the {@link #duplicate duplicate} method. </p> | |
| 539 | + * | |
| 540 | + * @return The new, read-only char buffer | |
| 541 | + */ | |
| 542 | + public abstract CharBuffer asReadOnlyBuffer(); | |
| 543 | + | |
| 544 | + | |
| 545 | + // -- Singleton get/put methods -- | |
| 546 | + | |
| 547 | + /** | |
| 548 | + * Relative <i>get</i> method. Reads the char at this buffer's | |
| 549 | + * current position, and then increments the position. </p> | |
| 550 | + * | |
| 551 | + * @return The char at the buffer's current position | |
| 552 | + * | |
| 553 | + * @throws BufferUnderflowException | |
| 554 | + * If the buffer's current position is not smaller than its limit | |
| 555 | + */ | |
| 556 | + public abstract char get(); | |
| 557 | + | |
| 558 | + /** | |
| 559 | + * Relative <i>put</i> method <i>(optional operation)</i>. | |
| 560 | + * | |
| 561 | + * <p> Writes the given char into this buffer at the current | |
| 562 | + * position, and then increments the position. </p> | |
| 563 | + * | |
| 564 | + * @param c | |
| 565 | + * The char to be written | |
| 566 | + * | |
| 567 | + * @return This buffer | |
| 568 | + * | |
| 569 | + * @throws BufferOverflowException | |
| 570 | + * If this buffer's current position is not smaller than its limit | |
| 571 | + * | |
| 572 | + * @throws ReadOnlyBufferException | |
| 573 | + * If this buffer is read-only | |
| 574 | + */ | |
| 575 | + public abstract CharBuffer put(char c); | |
| 576 | + | |
| 577 | + /** | |
| 578 | + * Absolute <i>get</i> method. Reads the char at the given | |
| 579 | + * index. </p> | |
| 580 | + * | |
| 581 | + * @param index | |
| 582 | + * The index from which the char will be read | |
| 583 | + * | |
| 584 | + * @return The char at the given index | |
| 585 | + * | |
| 586 | + * @throws IndexOutOfBoundsException | |
| 587 | + * If <tt>index</tt> is negative | |
| 588 | + * or not smaller than the buffer's limit | |
| 589 | + */ | |
| 590 | + public abstract char get(int index); | |
| 591 | + | |
| 592 | + /** | |
| 593 | + * Absolute <i>put</i> method <i>(optional operation)</i>. | |
| 594 | + * | |
| 595 | + * <p> Writes the given char into this buffer at the given | |
| 596 | + * index. </p> | |
| 597 | + * | |
| 598 | + * @param index | |
| 599 | + * The index at which the char will be written | |
| 600 | + * | |
| 601 | + * @param c | |
| 602 | + * The char value to be written | |
| 603 | + * | |
| 604 | + * @return This buffer | |
| 605 | + * | |
| 606 | + * @throws IndexOutOfBoundsException | |
| 607 | + * If <tt>index</tt> is negative | |
| 608 | + * or not smaller than the buffer's limit | |
| 609 | + * | |
| 610 | + * @throws ReadOnlyBufferException | |
| 611 | + * If this buffer is read-only | |
| 612 | + */ | |
| 613 | + public abstract CharBuffer put(int index, char c); | |
| 614 | + | |
| 615 | + | |
| 616 | + // -- Bulk get operations -- | |
| 617 | + | |
| 618 | + /** | |
| 619 | + * Relative bulk <i>get</i> method. | |
| 620 | + * | |
| 621 | + * <p> This method transfers chars from this buffer into the given | |
| 622 | + * destination array. If there are fewer chars remaining in the | |
| 623 | + * buffer than are required to satisfy the request, that is, if | |
| 624 | + * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no | |
| 625 | + * chars are transferred and a {@link BufferUnderflowException} is | |
| 626 | + * thrown. | |
| 627 | + * | |
| 628 | + * <p> Otherwise, this method copies <tt>length</tt> chars from this | |
| 629 | + * buffer into the given array, starting at the current position of this | |
| 630 | + * buffer and at the given offset in the array. The position of this | |
| 631 | + * buffer is then incremented by <tt>length</tt>. | |
| 632 | + * | |
| 633 | + * <p> In other words, an invocation of this method of the form | |
| 634 | + * <tt>src.get(dst, off, len)</tt> has exactly the same effect as | |
| 635 | + * the loop | |
| 636 | + * | |
| 637 | + * <pre> | |
| 638 | + * for (int i = off; i < off + len; i++) | |
| 639 | + * dst[i] = src.get(); </pre> | |
| 640 | + * | |
| 641 | + * except that it first checks that there are sufficient chars in | |
| 642 | + * this buffer and it is potentially much more efficient. </p> | |
| 643 | + * | |
| 644 | + * @param dst | |
| 645 | + * The array into which chars are to be written | |
| 646 | + * | |
| 647 | + * @param offset | |
| 648 | + * The offset within the array of the first char to be | |
| 649 | + * written; must be non-negative and no larger than | |
| 650 | + * <tt>dst.length</tt> | |
| 651 | + * | |
| 652 | + * @param length | |
| 653 | + * The maximum number of chars to be written to the given | |
| 654 | + * array; must be non-negative and no larger than | |
| 655 | + * <tt>dst.length - offset</tt> | |
| 656 | + * | |
| 657 | + * @return This buffer | |
| 658 | + * | |
| 659 | + * @throws BufferUnderflowException | |
| 660 | + * If there are fewer than <tt>length</tt> chars | |
| 661 | + * remaining in this buffer | |
| 662 | + * | |
| 663 | + * @throws IndexOutOfBoundsException | |
| 664 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 665 | + * parameters do not hold | |
| 666 | + */ | |
| 667 | + public CharBuffer get(char[] dst, int offset, int length) { | |
| 668 | + // [Inferno] < | |
| 669 | + //checkBounds(offset, length, dst.length); | |
| 670 | + // [Inferno] = | |
| 671 | + Buffer.checkBounds(offset, length, dst.length); | |
| 672 | + // [Inferno] > | |
| 673 | + if (length > remaining()) | |
| 674 | + throw new BufferUnderflowException(); | |
| 675 | + int end = offset + length; | |
| 676 | + for (int i = offset; i < end; i++) | |
| 677 | + dst[i] = get(); | |
| 678 | + return this; | |
| 679 | + } | |
| 680 | + | |
| 681 | + /** | |
| 682 | + * Relative bulk <i>get</i> method. | |
| 683 | + * | |
| 684 | + * <p> This method transfers chars from this buffer into the given | |
| 685 | + * destination array. An invocation of this method of the form | |
| 686 | + * <tt>src.get(a)</tt> behaves in exactly the same way as the invocation | |
| 687 | + * | |
| 688 | + * <pre> | |
| 689 | + * src.get(a, 0, a.length) </pre> | |
| 690 | + * | |
| 691 | + * @return This buffer | |
| 692 | + * | |
| 693 | + * @throws BufferUnderflowException | |
| 694 | + * If there are fewer than <tt>length</tt> chars | |
| 695 | + * remaining in this buffer | |
| 696 | + */ | |
| 697 | + public CharBuffer get(char[] dst) { | |
| 698 | + return get(dst, 0, dst.length); | |
| 699 | + } | |
| 700 | + | |
| 701 | + | |
| 702 | + // -- Bulk put operations -- | |
| 703 | + | |
| 704 | + /** | |
| 705 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 706 | + * | |
| 707 | + * <p> This method transfers the chars remaining in the given source | |
| 708 | + * buffer into this buffer. If there are more chars remaining in the | |
| 709 | + * source buffer than in this buffer, that is, if | |
| 710 | + * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>, | |
| 711 | + * then no chars are transferred and a {@link | |
| 712 | + * BufferOverflowException} is thrown. | |
| 713 | + * | |
| 714 | + * <p> Otherwise, this method copies | |
| 715 | + * <i>n</i> = <tt>src.remaining()</tt> chars from the given | |
| 716 | + * buffer into this buffer, starting at each buffer's current position. | |
| 717 | + * The positions of both buffers are then incremented by <i>n</i>. | |
| 718 | + * | |
| 719 | + * <p> In other words, an invocation of this method of the form | |
| 720 | + * <tt>dst.put(src)</tt> has exactly the same effect as the loop | |
| 721 | + * | |
| 722 | + * <pre> | |
| 723 | + * while (src.hasRemaining()) | |
| 724 | + * dst.put(src.get()); </pre> | |
| 725 | + * | |
| 726 | + * except that it first checks that there is sufficient space in this | |
| 727 | + * buffer and it is potentially much more efficient. </p> | |
| 728 | + * | |
| 729 | + * @param src | |
| 730 | + * The source buffer from which chars are to be read; | |
| 731 | + * must not be this buffer | |
| 732 | + * | |
| 733 | + * @return This buffer | |
| 734 | + * | |
| 735 | + * @throws BufferOverflowException | |
| 736 | + * If there is insufficient space in this buffer | |
| 737 | + * for the remaining chars in the source buffer | |
| 738 | + * | |
| 739 | + * @throws IllegalArgumentException | |
| 740 | + * If the source buffer is this buffer | |
| 741 | + * | |
| 742 | + * @throws ReadOnlyBufferException | |
| 743 | + * If this buffer is read-only | |
| 744 | + */ | |
| 745 | + public CharBuffer put(CharBuffer src) { | |
| 746 | + if (src == this) | |
| 747 | + throw new IllegalArgumentException(); | |
| 748 | + int n = src.remaining(); | |
| 749 | + if (n > remaining()) | |
| 750 | + throw new BufferOverflowException(); | |
| 751 | + for (int i = 0; i < n; i++) | |
| 752 | + put(src.get()); | |
| 753 | + return this; | |
| 754 | + } | |
| 755 | + | |
| 756 | + /** | |
| 757 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 758 | + * | |
| 759 | + * <p> This method transfers chars into this buffer from the given | |
| 760 | + * source array. If there are more chars to be copied from the array | |
| 761 | + * than remain in this buffer, that is, if | |
| 762 | + * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no | |
| 763 | + * chars are transferred and a {@link BufferOverflowException} is | |
| 764 | + * thrown. | |
| 765 | + * | |
| 766 | + * <p> Otherwise, this method copies <tt>length</tt> chars from the | |
| 767 | + * given array into this buffer, starting at the given offset in the array | |
| 768 | + * and at the current position of this buffer. The position of this buffer | |
| 769 | + * is then incremented by <tt>length</tt>. | |
| 770 | + * | |
| 771 | + * <p> In other words, an invocation of this method of the form | |
| 772 | + * <tt>dst.put(src, off, len)</tt> has exactly the same effect as | |
| 773 | + * the loop | |
| 774 | + * | |
| 775 | + * <pre> | |
| 776 | + * for (int i = off; i < off + len; i++) | |
| 777 | + * dst.put(a[i]); </pre> | |
| 778 | + * | |
| 779 | + * except that it first checks that there is sufficient space in this | |
| 780 | + * buffer and it is potentially much more efficient. </p> | |
| 781 | + * | |
| 782 | + * @param src | |
| 783 | + * The array from which chars are to be read | |
| 784 | + * | |
| 785 | + * @param offset | |
| 786 | + * The offset within the array of the first char to be read; | |
| 787 | + * must be non-negative and no larger than <tt>array.length</tt> | |
| 788 | + * | |
| 789 | + * @param length | |
| 790 | + * The number of chars to be read from the given array; | |
| 791 | + * must be non-negative and no larger than | |
| 792 | + * <tt>array.length - offset</tt> | |
| 793 | + * | |
| 794 | + * @return This buffer | |
| 795 | + * | |
| 796 | + * @throws BufferOverflowException | |
| 797 | + * If there is insufficient space in this buffer | |
| 798 | + * | |
| 799 | + * @throws IndexOutOfBoundsException | |
| 800 | + * If the preconditions on the <tt>offset</tt> and <tt>length</tt> | |
| 801 | + * parameters do not hold | |
| 802 | + * | |
| 803 | + * @throws ReadOnlyBufferException | |
| 804 | + * If this buffer is read-only | |
| 805 | + */ | |
| 806 | + public CharBuffer put(char[] src, int offset, int length) { | |
| 807 | + // [Inferno] < | |
| 808 | + //checkBounds(offset, length, src.length); | |
| 809 | + // [Inferno] = | |
| 810 | + Buffer.checkBounds(offset, length, src.length); | |
| 811 | + // [Inferno] > | |
| 812 | + if (length > remaining()) | |
| 813 | + throw new BufferOverflowException(); | |
| 814 | + int end = offset + length; | |
| 815 | + for (int i = offset; i < end; i++) | |
| 816 | + this.put(src[i]); | |
| 817 | + return this; | |
| 818 | + } | |
| 819 | + | |
| 820 | + /** | |
| 821 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 822 | + * | |
| 823 | + * <p> This method transfers the entire content of the given source | |
| 824 | + * char array into this buffer. An invocation of this method of the | |
| 825 | + * form <tt>dst.put(a)</tt> behaves in exactly the same way as the | |
| 826 | + * invocation | |
| 827 | + * | |
| 828 | + * <pre> | |
| 829 | + * dst.put(a, 0, a.length) </pre> | |
| 830 | + * | |
| 831 | + * @return This buffer | |
| 832 | + * | |
| 833 | + * @throws BufferOverflowException | |
| 834 | + * If there is insufficient space in this buffer | |
| 835 | + * | |
| 836 | + * @throws ReadOnlyBufferException | |
| 837 | + * If this buffer is read-only | |
| 838 | + */ | |
| 839 | + public final CharBuffer put(char[] src) { | |
| 840 | + return put(src, 0, src.length); | |
| 841 | + } | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + /** | |
| 846 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 847 | + * | |
| 848 | + * <p> This method transfers chars from the given string into this | |
| 849 | + * buffer. If there are more chars to be copied from the string than | |
| 850 | + * remain in this buffer, that is, if | |
| 851 | + * <tt>end - start</tt> <tt>></tt> <tt>remaining()</tt>, | |
| 852 | + * then no chars are transferred and a {@link | |
| 853 | + * BufferOverflowException} is thrown. | |
| 854 | + * | |
| 855 | + * <p> Otherwise, this method copies | |
| 856 | + * <i>n</i> = <tt>end</tt> - <tt>start</tt> chars | |
| 857 | + * from the given string into this buffer, starting at the given | |
| 858 | + * <tt>start</tt> index and at the current position of this buffer. The | |
| 859 | + * position of this buffer is then incremented by <i>n</i>. | |
| 860 | + * | |
| 861 | + * <p> In other words, an invocation of this method of the form | |
| 862 | + * <tt>dst.put(src, start, end)</tt> has exactly the same effect | |
| 863 | + * as the loop | |
| 864 | + * | |
| 865 | + * <pre> | |
| 866 | + * for (int i = start; i < end; i++) | |
| 867 | + * dst.put(src.charAt(i)); </pre> | |
| 868 | + * | |
| 869 | + * except that it first checks that there is sufficient space in this | |
| 870 | + * buffer and it is potentially much more efficient. </p> | |
| 871 | + * | |
| 872 | + * @param src | |
| 873 | + * The string from which chars are to be read | |
| 874 | + * | |
| 875 | + * @param start | |
| 876 | + * The offset within the string of the first char to be read; | |
| 877 | + * must be non-negative and no larger than | |
| 878 | + * <tt>string.length()</tt> | |
| 879 | + * | |
| 880 | + * @param end | |
| 881 | + * The offset within the string of the last char to be read, | |
| 882 | + * plus one; must be non-negative and no larger than | |
| 883 | + * <tt>string.length()</tt> | |
| 884 | + * | |
| 885 | + * @return This buffer | |
| 886 | + * | |
| 887 | + * @throws BufferOverflowException | |
| 888 | + * If there is insufficient space in this buffer | |
| 889 | + * | |
| 890 | + * @throws IndexOutOfBoundsException | |
| 891 | + * If the preconditions on the <tt>start</tt> and <tt>end</tt> | |
| 892 | + * parameters do not hold | |
| 893 | + * | |
| 894 | + * @throws ReadOnlyBufferException | |
| 895 | + * If this buffer is read-only | |
| 896 | + */ | |
| 897 | + public CharBuffer put(String src, int start, int end) { | |
| 898 | + // [Inferno] < | |
| 899 | + //checkBounds(start, end - start, src.length()); | |
| 900 | + // [Inferno] = | |
| 901 | + Buffer.checkBounds(start, end - start, src.length()); | |
| 902 | + // [Inferno] > | |
| 903 | + for (int i = start; i < end; i++) | |
| 904 | + this.put(src.charAt(i)); | |
| 905 | + return this; | |
| 906 | + } | |
| 907 | + | |
| 908 | + /** | |
| 909 | + * Relative bulk <i>put</i> method <i>(optional operation)</i>. | |
| 910 | + * | |
| 911 | + * <p> This method transfers the entire content of the given source string | |
| 912 | + * into this buffer. An invocation of this method of the form | |
| 913 | + * <tt>dst.put(s)</tt> behaves in exactly the same way as the invocation | |
| 914 | + * | |
| 915 | + * <pre> | |
| 916 | + * dst.put(s, 0, s.length()) </pre> | |
| 917 | + * | |
| 918 | + * @return This buffer | |
| 919 | + * | |
| 920 | + * @throws BufferOverflowException | |
| 921 | + * If there is insufficient space in this buffer | |
| 922 | + * | |
| 923 | + * @throws ReadOnlyBufferException | |
| 924 | + * If this buffer is read-only | |
| 925 | + */ | |
| 926 | + public final CharBuffer put(String src) { | |
| 927 | + return put(src, 0, src.length()); | |
| 928 | + } | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + // -- Other stuff -- | |
| 934 | + | |
| 935 | + /** | |
| 936 | + * Tells whether or not this buffer is backed by an accessible char | |
| 937 | + * array. | |
| 938 | + * | |
| 939 | + * <p> If this method returns <tt>true</tt> then the {@link #array() array} | |
| 940 | + * and {@link #arrayOffset() arrayOffset} methods may safely be invoked. | |
| 941 | + * </p> | |
| 942 | + * | |
| 943 | + * @return <tt>true</tt> if, and only if, this buffer | |
| 944 | + * is backed by an array and is not read-only | |
| 945 | + */ | |
| 946 | + public final boolean hasArray() { | |
| 947 | + return (hb != null) && !isReadOnly; | |
| 948 | + } | |
| 949 | + | |
| 950 | + /** | |
| 951 | + * Returns the char array that backs this | |
| 952 | + * buffer <i>(optional operation)</i>. | |
| 953 | + * | |
| 954 | + * <p> Modifications to this buffer's content will cause the returned | |
| 955 | + * array's content to be modified, and vice versa. | |
| 956 | + * | |
| 957 | + * <p> Invoke the {@link #hasArray hasArray} method before invoking this | |
| 958 | + * method in order to ensure that this buffer has an accessible backing | |
| 959 | + * array. </p> | |
| 960 | + * | |
| 961 | + * @return The array that backs this buffer | |
| 962 | + * | |
| 963 | + * @throws ReadOnlyBufferException | |
| 964 | + * If this buffer is backed by an array but is read-only | |
| 965 | + * | |
| 966 | + * @throws UnsupportedOperationException | |
| 967 | + * If this buffer is not backed by an accessible array | |
| 968 | + */ | |
| 969 | + public final char[] array() { | |
| 970 | + if (hb == null) | |
| 971 | + throw new UnsupportedOperationException(); | |
| 972 | + if (isReadOnly) | |
| 973 | + throw new ReadOnlyBufferException(); | |
| 974 | + return hb; | |
| 975 | + } | |
| 976 | + | |
| 977 | + /** | |
| 978 | + * Returns the offset within this buffer's backing array of the first | |
| 979 | + * element of the buffer <i>(optional operation)</i>. | |
| 980 | + * | |
| 981 | + * <p> If this buffer is backed by an array then buffer position <i>p</i> | |
| 982 | + * corresponds to array index <i>p</i> + <tt>arrayOffset()</tt>. | |
| 983 | + * | |
| 984 | + * <p> Invoke the {@link #hasArray hasArray} method before invoking this | |
| 985 | + * method in order to ensure that this buffer has an accessible backing | |
| 986 | + * array. </p> | |
| 987 | + * | |
| 988 | + * @return The offset within this buffer's array | |
| 989 | + * of the first element of the buffer | |
| 990 | + * | |
| 991 | + * @throws ReadOnlyBufferException | |
| 992 | + * If this buffer is backed by an array but is read-only | |
| 993 | + * | |
| 994 | + * @throws UnsupportedOperationException | |
| 995 | + * If this buffer is not backed by an accessible array | |
| 996 | + */ | |
| 997 | + public final int arrayOffset() { | |
| 998 | + if (hb == null) | |
| 999 | + throw new UnsupportedOperationException(); | |
| 1000 | + if (isReadOnly) | |
| 1001 | + throw new ReadOnlyBufferException(); | |
| 1002 | + return offset; | |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + /** | |
| 1006 | + * Compacts this buffer <i>(optional operation)</i>. | |
| 1007 | + * | |
| 1008 | + * <p> The chars between the buffer's current position and its limit, | |
| 1009 | + * if any, are copied to the beginning of the buffer. That is, the | |
| 1010 | + * char at index <i>p</i> = <tt>position()</tt> is copied | |
| 1011 | + * to index zero, the char at index <i>p</i> + 1 is copied | |
| 1012 | + * to index one, and so forth until the char at index | |
| 1013 | + * <tt>limit()</tt> - 1 is copied to index | |
| 1014 | + * <i>n</i> = <tt>limit()</tt> - <tt>1</tt> - <i>p</i>. | |
| 1015 | + * The buffer's position is then set to <i>n+1</i> and its limit is set to | |
| 1016 | + * its capacity. The mark, if defined, is discarded. | |
| 1017 | + * | |
| 1018 | + * <p> The buffer's position is set to the number of chars copied, | |
| 1019 | + * rather than to zero, so that an invocation of this method can be | |
| 1020 | + * followed immediately by an invocation of another relative <i>put</i> | |
| 1021 | + * method. </p> | |
| 1022 | + * | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + * | |
| 1039 | + * @return This buffer | |
| 1040 | + * | |
| 1041 | + * @throws ReadOnlyBufferException | |
| 1042 | + * If this buffer is read-only | |
| 1043 | + */ | |
| 1044 | + public abstract CharBuffer compact(); | |
| 1045 | + | |
| 1046 | + /** | |
| 1047 | + * Tells whether or not this char buffer is direct. </p> | |
| 1048 | + * | |
| 1049 | + * @return <tt>true</tt> if, and only if, this buffer is direct | |
| 1050 | + */ | |
| 1051 | + public abstract boolean isDirect(); | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + /** | |
| 1079 | + * Returns the current hash code of this buffer. | |
| 1080 | + * | |
| 1081 | + * <p> The hash code of a char buffer depends only upon its remaining | |
| 1082 | + * elements; that is, upon the elements from <tt>position()</tt> up to, and | |
| 1083 | + * including, the element at <tt>limit()</tt> - <tt>1</tt>. | |
| 1084 | + * | |
| 1085 | + * <p> Because buffer hash codes are content-dependent, it is inadvisable | |
| 1086 | + * to use buffers as keys in hash maps or similar data structures unless it | |
| 1087 | + * is known that their contents will not change. </p> | |
| 1088 | + * | |
| 1089 | + * @return The current hash code of this buffer | |
| 1090 | + */ | |
| 1091 | + public int hashCode() { | |
| 1092 | + int h = 1; | |
| 1093 | + int p = position(); | |
| 1094 | + for (int i = limit() - 1; i >= p; i--) | |
| 1095 | + h = 31 * h + (int)get(i); | |
| 1096 | + return h; | |
| 1097 | + } | |
| 1098 | + | |
| 1099 | + /** | |
| 1100 | + * Tells whether or not this buffer is equal to another object. | |
| 1101 | + * | |
| 1102 | + * <p> Two char buffers are equal if, and only if, | |
| 1103 | + * | |
| 1104 | + * <p><ol> | |
| 1105 | + * | |
| 1106 | + * <li><p> They have the same element type, </p></li> | |
| 1107 | + * | |
| 1108 | + * <li><p> They have the same number of remaining elements, and | |
| 1109 | + * </p></li> | |
| 1110 | + * | |
| 1111 | + * <li><p> The two sequences of remaining elements, considered | |
| 1112 | + * independently of their starting positions, are pointwise equal. | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + * </p></li> | |
| 1121 | + * | |
| 1122 | + * </ol> | |
| 1123 | + * | |
| 1124 | + * <p> A char buffer is not equal to any other type of object. </p> | |
| 1125 | + * | |
| 1126 | + * @param ob The object to which this buffer is to be compared | |
| 1127 | + * | |
| 1128 | + * @return <tt>true</tt> if, and only if, this buffer is equal to the | |
| 1129 | + * given object | |
| 1130 | + */ | |
| 1131 | + public boolean equals(Object ob) { | |
| 1132 | + if (this == ob) | |
| 1133 | + return true; | |
| 1134 | + if (!(ob instanceof CharBuffer)) | |
| 1135 | + return false; | |
| 1136 | + CharBuffer that = (CharBuffer)ob; | |
| 1137 | + if (this.remaining() != that.remaining()) | |
| 1138 | + return false; | |
| 1139 | + int p = this.position(); | |
| 1140 | + for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) | |
| 1141 | + if (!equals(this.get(i), that.get(j))) | |
| 1142 | + return false; | |
| 1143 | + return true; | |
| 1144 | + } | |
| 1145 | + | |
| 1146 | + private static boolean equals(char x, char y) { | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + return x == y; | |
| 1151 | + | |
| 1152 | + } | |
| 1153 | + | |
| 1154 | + /** | |
| 1155 | + * Compares this buffer to another. | |
| 1156 | + * | |
| 1157 | + * <p> Two char buffers are compared by comparing their sequences of | |
| 1158 | + * remaining elements lexicographically, without regard to the starting | |
| 1159 | + * position of each sequence within its corresponding buffer. | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + * Pairs of {@code char} elements are compared as if by invoking | |
| 1169 | + * {@link Character#compare(char,char)}. | |
| 1170 | + | |
| 1171 | + * | |
| 1172 | + * <p> A char buffer is not comparable to any other type of object. | |
| 1173 | + * | |
| 1174 | + * @return A negative integer, zero, or a positive integer as this buffer | |
| 1175 | + * is less than, equal to, or greater than the given buffer | |
| 1176 | + */ | |
| 1177 | + public int compareTo(CharBuffer that) { | |
| 1178 | + int n = this.position() + Math.min(this.remaining(), that.remaining()); | |
| 1179 | + for (int i = this.position(), j = that.position(); i < n; i++, j++) { | |
| 1180 | + int cmp = compare(this.get(i), that.get(j)); | |
| 1181 | + if (cmp != 0) | |
| 1182 | + return cmp; | |
| 1183 | + } | |
| 1184 | + return this.remaining() - that.remaining(); | |
| 1185 | + } | |
| 1186 | + | |
| 1187 | + private static int compare(char x, char y) { | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + return Character.compare(x, y); | |
| 1195 | + | |
| 1196 | + } | |
| 1197 | + | |
| 1198 | + // -- Other char stuff -- | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + /** | |
| 1203 | + * Returns a string containing the characters in this buffer. | |
| 1204 | + * | |
| 1205 | + * <p> The first character of the resulting string will be the character at | |
| 1206 | + * this buffer's position, while the last character will be the character | |
| 1207 | + * at index <tt>limit()</tt> - 1. Invoking this method does not | |
| 1208 | + * change the buffer's position. </p> | |
| 1209 | + * | |
| 1210 | + * @return The specified string | |
| 1211 | + */ | |
| 1212 | + public String toString() { | |
| 1213 | + return toString(position(), limit()); | |
| 1214 | + } | |
| 1215 | + | |
| 1216 | + abstract String toString(int start, int end); // package-private | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + // --- Methods to support CharSequence --- | |
| 1220 | + | |
| 1221 | + /** | |
| 1222 | + * Returns the length of this character buffer. | |
| 1223 | + * | |
| 1224 | + * <p> When viewed as a character sequence, the length of a character | |
| 1225 | + * buffer is simply the number of characters between the position | |
| 1226 | + * (inclusive) and the limit (exclusive); that is, it is equivalent to | |
| 1227 | + * <tt>remaining()</tt>. </p> | |
| 1228 | + * | |
| 1229 | + * @return The length of this character buffer | |
| 1230 | + */ | |
| 1231 | + public final int length() { | |
| 1232 | + return remaining(); | |
| 1233 | + } | |
| 1234 | + | |
| 1235 | + /** | |
| 1236 | + * Reads the character at the given index relative to the current | |
| 1237 | + * position. </p> | |
| 1238 | + * | |
| 1239 | + * @param index | |
| 1240 | + * The index of the character to be read, relative to the position; | |
| 1241 | + * must be non-negative and smaller than <tt>remaining()</tt> | |
| 1242 | + * | |
| 1243 | + * @return The character at index | |
| 1244 | + * <tt>position() + index</tt> | |
| 1245 | + * | |
| 1246 | + * @throws IndexOutOfBoundsException | |
| 1247 | + * If the preconditions on <tt>index</tt> do not hold | |
| 1248 | + */ | |
| 1249 | + public final char charAt(int index) { | |
| 1250 | + return get(position() + checkIndex(index, 1)); | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + /** | |
| 1254 | + * Creates a new character buffer that represents the specified subsequence | |
| 1255 | + * of this buffer, relative to the current position. | |
| 1256 | + * | |
| 1257 | + * <p> The new buffer will share this buffer's content; that is, if the | |
| 1258 | + * content of this buffer is mutable then modifications to one buffer will | |
| 1259 | + * cause the other to be modified. The new buffer's capacity will be that | |
| 1260 | + * of this buffer, its position will be | |
| 1261 | + * <tt>position()</tt> + <tt>start</tt>, and its limit will be | |
| 1262 | + * <tt>position()</tt> + <tt>end</tt>. The new buffer will be | |
| 1263 | + * direct if, and only if, this buffer is direct, and it will be read-only | |
| 1264 | + * if, and only if, this buffer is read-only. </p> | |
| 1265 | + * | |
| 1266 | + * @param start | |
| 1267 | + * The index, relative to the current position, of the first | |
| 1268 | + * character in the subsequence; must be non-negative and no larger | |
| 1269 | + * than <tt>remaining()</tt> | |
| 1270 | + * | |
| 1271 | + * @param end | |
| 1272 | + * The index, relative to the current position, of the character | |
| 1273 | + * following the last character in the subsequence; must be no | |
| 1274 | + * smaller than <tt>start</tt> and no larger than | |
| 1275 | + * <tt>remaining()</tt> | |
| 1276 | + * | |
| 1277 | + * @return The new character buffer | |
| 1278 | + * | |
| 1279 | + * @throws IndexOutOfBoundsException | |
| 1280 | + * If the preconditions on <tt>start</tt> and <tt>end</tt> | |
| 1281 | + * do not hold | |
| 1282 | + */ | |
| 1283 | + public abstract CharBuffer subSequence(int start, int end); | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + // --- Methods to support Appendable --- | |
| 1287 | + | |
| 1288 | + /** | |
| 1289 | + * Appends the specified character sequence to this | |
| 1290 | + * buffer <i>(optional operation)</i>. | |
| 1291 | + * | |
| 1292 | + * <p> An invocation of this method of the form <tt>dst.append(csq)</tt> | |
| 1293 | + * behaves in exactly the same way as the invocation | |
| 1294 | + * | |
| 1295 | + * <pre> | |
| 1296 | + * dst.put(csq.toString()) </pre> | |
| 1297 | + * | |
| 1298 | + * <p> Depending on the specification of <tt>toString</tt> for the | |
| 1299 | + * character sequence <tt>csq</tt>, the entire sequence may not be | |
| 1300 | + * appended. For instance, invoking the {@link CharBuffer#toString() | |
| 1301 | + * toString} method of a character buffer will return a subsequence whose | |
| 1302 | + * content depends upon the buffer's position and limit. | |
| 1303 | + * | |
| 1304 | + * @param csq | |
| 1305 | + * The character sequence to append. If <tt>csq</tt> is | |
| 1306 | + * <tt>null</tt>, then the four characters <tt>"null"</tt> are | |
| 1307 | + * appended to this character buffer. | |
| 1308 | + * | |
| 1309 | + * @return This buffer | |
| 1310 | + * | |
| 1311 | + * @throws BufferOverflowException | |
| 1312 | + * If there is insufficient space in this buffer | |
| 1313 | + * | |
| 1314 | + * @throws ReadOnlyBufferException | |
| 1315 | + * If this buffer is read-only | |
| 1316 | + * | |
| 1317 | + * @since 1.5 | |
| 1318 | + */ | |
| 1319 | + public CharBuffer append(CharSequence csq) { | |
| 1320 | + if (csq == null) | |
| 1321 | + return put("null"); | |
| 1322 | + else | |
| 1323 | + return put(csq.toString()); | |
| 1324 | + } | |
| 1325 | + | |
| 1326 | + /** | |
| 1327 | + * Appends a subsequence of the specified character sequence to this | |
| 1328 | + * buffer <i>(optional operation)</i>. | |
| 1329 | + * | |
| 1330 | + * <p> An invocation of this method of the form <tt>dst.append(csq, start, | |
| 1331 | + * end)</tt> when <tt>csq</tt> is not <tt>null</tt>, behaves in exactly the | |
| 1332 | + * same way as the invocation | |
| 1333 | + * | |
| 1334 | + * <pre> | |
| 1335 | + * dst.put(csq.subSequence(start, end).toString()) </pre> | |
| 1336 | + * | |
| 1337 | + * @param csq | |
| 1338 | + * The character sequence from which a subsequence will be | |
| 1339 | + * appended. If <tt>csq</tt> is <tt>null</tt>, then characters | |
| 1340 | + * will be appended as if <tt>csq</tt> contained the four | |
| 1341 | + * characters <tt>"null"</tt>. | |
| 1342 | + * | |
| 1343 | + * @return This buffer | |
| 1344 | + * | |
| 1345 | + * @throws BufferOverflowException | |
| 1346 | + * If there is insufficient space in this buffer | |
| 1347 | + * | |
| 1348 | + * @throws IndexOutOfBoundsException | |
| 1349 | + * If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt> | |
| 1350 | + * is greater than <tt>end</tt>, or <tt>end</tt> is greater than | |
| 1351 | + * <tt>csq.length()</tt> | |
| 1352 | + * | |
| 1353 | + * @throws ReadOnlyBufferException | |
| 1354 | + * If this buffer is read-only | |
| 1355 | + * | |
| 1356 | + * @since 1.5 | |
| 1357 | + */ | |
| 1358 | + public CharBuffer append(CharSequence csq, int start, int end) { | |
| 1359 | + CharSequence cs = (csq == null ? "null" : csq); | |
| 1360 | + return put(cs.subSequence(start, end).toString()); | |
| 1361 | + } | |
| 1362 | + | |
| 1363 | + /** | |
| 1364 | + * Appends the specified char to this | |
| 1365 | + * buffer <i>(optional operation)</i>. | |
| 1366 | + * | |
| 1367 | + * <p> An invocation of this method of the form <tt>dst.append(c)</tt> | |
| 1368 | + * behaves in exactly the same way as the invocation | |
| 1369 | + * | |
| 1370 | + * <pre> | |
| 1371 | + * dst.put(c) </pre> | |
| 1372 | + * | |
| 1373 | + * @param c | |
| 1374 | + * The 16-bit char to append | |
| 1375 | + * | |
| 1376 | + * @return This buffer | |
| 1377 | + * | |
| 1378 | + * @throws BufferOverflowException | |
| 1379 | + * If there is insufficient space in this buffer | |
| 1380 | + * | |
| 1381 | + * @throws ReadOnlyBufferException | |
| 1382 | + * If this buffer is read-only | |
| 1383 | + * | |
| 1384 | + * @since 1.5 | |
| 1385 | + */ | |
| 1386 | + public CharBuffer append(char c) { | |
| 1387 | + return put(c); | |
| 1388 | + } | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + // -- Other byte stuff: Access to binary data -- | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + /** | |
| 1398 | + * Retrieves this buffer's byte order. | |
| 1399 | + * | |
| 1400 | + * <p> The byte order of a char buffer created by allocation or by | |
| 1401 | + * wrapping an existing <tt>char</tt> array is the {@link | |
| 1402 | + * ByteOrder#nativeOrder </code>native order<code>} of the underlying | |
| 1403 | + * hardware. The byte order of a char buffer created as a <a | |
| 1404 | + * href="ByteBuffer.html#views">view</a> of a byte buffer is that of the | |
| 1405 | + * byte buffer at the moment that the view is created. </p> | |
| 1406 | + * | |
| 1407 | + * @return This buffer's byte order | |
| 1408 | + */ | |
| 1409 | + public abstract ByteOrder order(); | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | +} | |
| @@ -0,0 +1,1009 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectByteBuffer | |
| 38 | + | |
| 39 | + extends MappedByteBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(byte[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + private static class Deallocator | |
| 72 | + implements Runnable | |
| 73 | + { | |
| 74 | + | |
| 75 | + private static Unsafe unsafe = Unsafe.getUnsafe(); | |
| 76 | + | |
| 77 | + private long address; | |
| 78 | + private long size; | |
| 79 | + private int capacity; | |
| 80 | + | |
| 81 | + private Deallocator(long address, long size, int capacity) { | |
| 82 | + assert (address != 0); | |
| 83 | + this.address = address; | |
| 84 | + this.size = size; | |
| 85 | + this.capacity = capacity; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void run() { | |
| 89 | + if (address == 0) { | |
| 90 | + // Paranoia | |
| 91 | + return; | |
| 92 | + } | |
| 93 | + unsafe.freeMemory(address); | |
| 94 | + address = 0; | |
| 95 | + Bits.unreserveMemory(size, capacity); | |
| 96 | + } | |
| 97 | + | |
| 98 | + } | |
| 99 | + | |
| 100 | + private final Cleaner cleaner; | |
| 101 | + | |
| 102 | + public Cleaner cleaner() { return cleaner; } | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + // Primary constructor | |
| 115 | + // | |
| 116 | + DirectByteBuffer(int cap) { // package-private | |
| 117 | + | |
| 118 | + super(-1, 0, cap, cap); | |
| 119 | + boolean pa = VM.isDirectMemoryPageAligned(); | |
| 120 | + int ps = Bits.pageSize(); | |
| 121 | + long size = Math.max(1L, (long)cap + (pa ? ps : 0)); | |
| 122 | + Bits.reserveMemory(size, cap); | |
| 123 | + | |
| 124 | + long base = 0; | |
| 125 | + try { | |
| 126 | + base = unsafe.allocateMemory(size); | |
| 127 | + } catch (OutOfMemoryError x) { | |
| 128 | + Bits.unreserveMemory(size, cap); | |
| 129 | + throw x; | |
| 130 | + } | |
| 131 | + unsafe.setMemory(base, size, (byte) 0); | |
| 132 | + if (pa && (base % ps != 0)) { | |
| 133 | + // Round up to page boundary | |
| 134 | + address = base + ps - (base & (ps - 1)); | |
| 135 | + } else { | |
| 136 | + address = base; | |
| 137 | + } | |
| 138 | + cleaner = Cleaner.create(this, new Deallocator(base, size, cap)); | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + } | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + // Invoked only by JNI: NewDirectByteBuffer(void*, long) | |
| 147 | + // | |
| 148 | + private DirectByteBuffer(long addr, int cap) { | |
| 149 | + super(-1, 0, cap, cap); | |
| 150 | + address = addr; | |
| 151 | + cleaner = null; | |
| 152 | + } | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + // For memory-mapped buffers -- invoked by FileChannelImpl via reflection | |
| 157 | + // | |
| 158 | + protected DirectByteBuffer(int cap, long addr, | |
| 159 | + FileDescriptor fd, | |
| 160 | + Runnable unmapper) | |
| 161 | + { | |
| 162 | + | |
| 163 | + super(-1, 0, cap, cap, fd); | |
| 164 | + address = addr; | |
| 165 | + viewedBuffer = null; | |
| 166 | + cleaner = Cleaner.create(this, unmapper); | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectByteBuffer(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + cleaner = null; | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public ByteBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 0); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectByteBuffer(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public ByteBuffer duplicate() { | |
| 203 | + return new DirectByteBuffer(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public ByteBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectByteBufferR(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 0); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public byte get() { | |
| 235 | + return ((unsafe.getByte(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public byte get(int i) { | |
| 239 | + return ((unsafe.getByte(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public ByteBuffer get(byte[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 0) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 0, | |
| 262 | + length << 0); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public ByteBuffer put(byte x) { | |
| 276 | + | |
| 277 | + unsafe.putByte(ix(nextPutIndex()), ((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public ByteBuffer put(int i, byte x) { | |
| 285 | + | |
| 286 | + unsafe.putByte(ix(checkIndex(i)), ((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public ByteBuffer put(ByteBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectByteBuffer) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectByteBuffer sb = (DirectByteBuffer)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 0); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public ByteBuffer put(byte[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 0) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 0, | |
| 352 | + ix(pos), length << 0); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public ByteBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 0); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + byte _get(int i) { // package-private | |
| 452 | + return unsafe.getByte(address + i); | |
| 453 | + } | |
| 454 | + | |
| 455 | + void _put(int i, byte b) { // package-private | |
| 456 | + | |
| 457 | + unsafe.putByte(address + i, b); | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + } | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + private char getChar(long a) { | |
| 467 | + if (unaligned) { | |
| 468 | + char x = unsafe.getChar(a); | |
| 469 | + return (nativeByteOrder ? x : Bits.swap(x)); | |
| 470 | + } | |
| 471 | + return Bits.getChar(a, bigEndian); | |
| 472 | + } | |
| 473 | + | |
| 474 | + public char getChar() { | |
| 475 | + return getChar(ix(nextGetIndex((1 << 1)))); | |
| 476 | + } | |
| 477 | + | |
| 478 | + public char getChar(int i) { | |
| 479 | + return getChar(ix(checkIndex(i, (1 << 1)))); | |
| 480 | + } | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + private ByteBuffer putChar(long a, char x) { | |
| 485 | + | |
| 486 | + if (unaligned) { | |
| 487 | + char y = (x); | |
| 488 | + unsafe.putChar(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 489 | + } else { | |
| 490 | + Bits.putChar(a, x, bigEndian); | |
| 491 | + } | |
| 492 | + return this; | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + } | |
| 497 | + | |
| 498 | + public ByteBuffer putChar(char x) { | |
| 499 | + | |
| 500 | + putChar(ix(nextPutIndex((1 << 1))), x); | |
| 501 | + return this; | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + } | |
| 506 | + | |
| 507 | + public ByteBuffer putChar(int i, char x) { | |
| 508 | + | |
| 509 | + putChar(ix(checkIndex(i, (1 << 1))), x); | |
| 510 | + return this; | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + } | |
| 515 | + | |
| 516 | + public CharBuffer asCharBuffer() { | |
| 517 | + int off = this.position(); | |
| 518 | + int lim = this.limit(); | |
| 519 | + assert (off <= lim); | |
| 520 | + int rem = (off <= lim ? lim - off : 0); | |
| 521 | + | |
| 522 | + int size = rem >> 1; | |
| 523 | + if (!unaligned && ((address + off) % (1 << 1) != 0)) { | |
| 524 | + return (bigEndian | |
| 525 | + ? (CharBuffer)(new ByteBufferAsCharBufferB(this, | |
| 526 | + -1, | |
| 527 | + 0, | |
| 528 | + size, | |
| 529 | + size, | |
| 530 | + off)) | |
| 531 | + : (CharBuffer)(new ByteBufferAsCharBufferL(this, | |
| 532 | + -1, | |
| 533 | + 0, | |
| 534 | + size, | |
| 535 | + size, | |
| 536 | + off))); | |
| 537 | + } else { | |
| 538 | + return (nativeByteOrder | |
| 539 | + ? (CharBuffer)(new DirectCharBufferU(this, | |
| 540 | + -1, | |
| 541 | + 0, | |
| 542 | + size, | |
| 543 | + size, | |
| 544 | + off)) | |
| 545 | + : (CharBuffer)(new DirectCharBufferS(this, | |
| 546 | + -1, | |
| 547 | + 0, | |
| 548 | + size, | |
| 549 | + size, | |
| 550 | + off))); | |
| 551 | + } | |
| 552 | + } | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + private short getShort(long a) { | |
| 558 | + if (unaligned) { | |
| 559 | + short x = unsafe.getShort(a); | |
| 560 | + return (nativeByteOrder ? x : Bits.swap(x)); | |
| 561 | + } | |
| 562 | + return Bits.getShort(a, bigEndian); | |
| 563 | + } | |
| 564 | + | |
| 565 | + public short getShort() { | |
| 566 | + return getShort(ix(nextGetIndex((1 << 1)))); | |
| 567 | + } | |
| 568 | + | |
| 569 | + public short getShort(int i) { | |
| 570 | + return getShort(ix(checkIndex(i, (1 << 1)))); | |
| 571 | + } | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + private ByteBuffer putShort(long a, short x) { | |
| 576 | + | |
| 577 | + if (unaligned) { | |
| 578 | + short y = (x); | |
| 579 | + unsafe.putShort(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 580 | + } else { | |
| 581 | + Bits.putShort(a, x, bigEndian); | |
| 582 | + } | |
| 583 | + return this; | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + } | |
| 588 | + | |
| 589 | + public ByteBuffer putShort(short x) { | |
| 590 | + | |
| 591 | + putShort(ix(nextPutIndex((1 << 1))), x); | |
| 592 | + return this; | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + } | |
| 597 | + | |
| 598 | + public ByteBuffer putShort(int i, short x) { | |
| 599 | + | |
| 600 | + putShort(ix(checkIndex(i, (1 << 1))), x); | |
| 601 | + return this; | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + } | |
| 606 | + | |
| 607 | + public ShortBuffer asShortBuffer() { | |
| 608 | + int off = this.position(); | |
| 609 | + int lim = this.limit(); | |
| 610 | + assert (off <= lim); | |
| 611 | + int rem = (off <= lim ? lim - off : 0); | |
| 612 | + | |
| 613 | + int size = rem >> 1; | |
| 614 | + if (!unaligned && ((address + off) % (1 << 1) != 0)) { | |
| 615 | + return (bigEndian | |
| 616 | + ? (ShortBuffer)(new ByteBufferAsShortBufferB(this, | |
| 617 | + -1, | |
| 618 | + 0, | |
| 619 | + size, | |
| 620 | + size, | |
| 621 | + off)) | |
| 622 | + : (ShortBuffer)(new ByteBufferAsShortBufferL(this, | |
| 623 | + -1, | |
| 624 | + 0, | |
| 625 | + size, | |
| 626 | + size, | |
| 627 | + off))); | |
| 628 | + } else { | |
| 629 | + return (nativeByteOrder | |
| 630 | + ? (ShortBuffer)(new DirectShortBufferU(this, | |
| 631 | + -1, | |
| 632 | + 0, | |
| 633 | + size, | |
| 634 | + size, | |
| 635 | + off)) | |
| 636 | + : (ShortBuffer)(new DirectShortBufferS(this, | |
| 637 | + -1, | |
| 638 | + 0, | |
| 639 | + size, | |
| 640 | + size, | |
| 641 | + off))); | |
| 642 | + } | |
| 643 | + } | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + private int getInt(long a) { | |
| 649 | + if (unaligned) { | |
| 650 | + int x = unsafe.getInt(a); | |
| 651 | + return (nativeByteOrder ? x : Bits.swap(x)); | |
| 652 | + } | |
| 653 | + return Bits.getInt(a, bigEndian); | |
| 654 | + } | |
| 655 | + | |
| 656 | + public int getInt() { | |
| 657 | + return getInt(ix(nextGetIndex((1 << 2)))); | |
| 658 | + } | |
| 659 | + | |
| 660 | + public int getInt(int i) { | |
| 661 | + return getInt(ix(checkIndex(i, (1 << 2)))); | |
| 662 | + } | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + private ByteBuffer putInt(long a, int x) { | |
| 667 | + | |
| 668 | + if (unaligned) { | |
| 669 | + int y = (x); | |
| 670 | + unsafe.putInt(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 671 | + } else { | |
| 672 | + Bits.putInt(a, x, bigEndian); | |
| 673 | + } | |
| 674 | + return this; | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + } | |
| 679 | + | |
| 680 | + public ByteBuffer putInt(int x) { | |
| 681 | + | |
| 682 | + putInt(ix(nextPutIndex((1 << 2))), x); | |
| 683 | + return this; | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + } | |
| 688 | + | |
| 689 | + public ByteBuffer putInt(int i, int x) { | |
| 690 | + | |
| 691 | + putInt(ix(checkIndex(i, (1 << 2))), x); | |
| 692 | + return this; | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + } | |
| 697 | + | |
| 698 | + public IntBuffer asIntBuffer() { | |
| 699 | + int off = this.position(); | |
| 700 | + int lim = this.limit(); | |
| 701 | + assert (off <= lim); | |
| 702 | + int rem = (off <= lim ? lim - off : 0); | |
| 703 | + | |
| 704 | + int size = rem >> 2; | |
| 705 | + if (!unaligned && ((address + off) % (1 << 2) != 0)) { | |
| 706 | + return (bigEndian | |
| 707 | + ? (IntBuffer)(new ByteBufferAsIntBufferB(this, | |
| 708 | + -1, | |
| 709 | + 0, | |
| 710 | + size, | |
| 711 | + size, | |
| 712 | + off)) | |
| 713 | + : (IntBuffer)(new ByteBufferAsIntBufferL(this, | |
| 714 | + -1, | |
| 715 | + 0, | |
| 716 | + size, | |
| 717 | + size, | |
| 718 | + off))); | |
| 719 | + } else { | |
| 720 | + return (nativeByteOrder | |
| 721 | + ? (IntBuffer)(new DirectIntBufferU(this, | |
| 722 | + -1, | |
| 723 | + 0, | |
| 724 | + size, | |
| 725 | + size, | |
| 726 | + off)) | |
| 727 | + : (IntBuffer)(new DirectIntBufferS(this, | |
| 728 | + -1, | |
| 729 | + 0, | |
| 730 | + size, | |
| 731 | + size, | |
| 732 | + off))); | |
| 733 | + } | |
| 734 | + } | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + private long getLong(long a) { | |
| 740 | + if (unaligned) { | |
| 741 | + long x = unsafe.getLong(a); | |
| 742 | + return (nativeByteOrder ? x : Bits.swap(x)); | |
| 743 | + } | |
| 744 | + return Bits.getLong(a, bigEndian); | |
| 745 | + } | |
| 746 | + | |
| 747 | + public long getLong() { | |
| 748 | + return getLong(ix(nextGetIndex((1 << 3)))); | |
| 749 | + } | |
| 750 | + | |
| 751 | + public long getLong(int i) { | |
| 752 | + return getLong(ix(checkIndex(i, (1 << 3)))); | |
| 753 | + } | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + private ByteBuffer putLong(long a, long x) { | |
| 758 | + | |
| 759 | + if (unaligned) { | |
| 760 | + long y = (x); | |
| 761 | + unsafe.putLong(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 762 | + } else { | |
| 763 | + Bits.putLong(a, x, bigEndian); | |
| 764 | + } | |
| 765 | + return this; | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + } | |
| 770 | + | |
| 771 | + public ByteBuffer putLong(long x) { | |
| 772 | + | |
| 773 | + putLong(ix(nextPutIndex((1 << 3))), x); | |
| 774 | + return this; | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + } | |
| 779 | + | |
| 780 | + public ByteBuffer putLong(int i, long x) { | |
| 781 | + | |
| 782 | + putLong(ix(checkIndex(i, (1 << 3))), x); | |
| 783 | + return this; | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + } | |
| 788 | + | |
| 789 | + public LongBuffer asLongBuffer() { | |
| 790 | + int off = this.position(); | |
| 791 | + int lim = this.limit(); | |
| 792 | + assert (off <= lim); | |
| 793 | + int rem = (off <= lim ? lim - off : 0); | |
| 794 | + | |
| 795 | + int size = rem >> 3; | |
| 796 | + if (!unaligned && ((address + off) % (1 << 3) != 0)) { | |
| 797 | + return (bigEndian | |
| 798 | + ? (LongBuffer)(new ByteBufferAsLongBufferB(this, | |
| 799 | + -1, | |
| 800 | + 0, | |
| 801 | + size, | |
| 802 | + size, | |
| 803 | + off)) | |
| 804 | + : (LongBuffer)(new ByteBufferAsLongBufferL(this, | |
| 805 | + -1, | |
| 806 | + 0, | |
| 807 | + size, | |
| 808 | + size, | |
| 809 | + off))); | |
| 810 | + } else { | |
| 811 | + return (nativeByteOrder | |
| 812 | + ? (LongBuffer)(new DirectLongBufferU(this, | |
| 813 | + -1, | |
| 814 | + 0, | |
| 815 | + size, | |
| 816 | + size, | |
| 817 | + off)) | |
| 818 | + : (LongBuffer)(new DirectLongBufferS(this, | |
| 819 | + -1, | |
| 820 | + 0, | |
| 821 | + size, | |
| 822 | + size, | |
| 823 | + off))); | |
| 824 | + } | |
| 825 | + } | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + private float getFloat(long a) { | |
| 831 | + if (unaligned) { | |
| 832 | + int x = unsafe.getInt(a); | |
| 833 | + return Float.intBitsToFloat(nativeByteOrder ? x : Bits.swap(x)); | |
| 834 | + } | |
| 835 | + return Bits.getFloat(a, bigEndian); | |
| 836 | + } | |
| 837 | + | |
| 838 | + public float getFloat() { | |
| 839 | + return getFloat(ix(nextGetIndex((1 << 2)))); | |
| 840 | + } | |
| 841 | + | |
| 842 | + public float getFloat(int i) { | |
| 843 | + return getFloat(ix(checkIndex(i, (1 << 2)))); | |
| 844 | + } | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + private ByteBuffer putFloat(long a, float x) { | |
| 849 | + | |
| 850 | + if (unaligned) { | |
| 851 | + int y = Float.floatToRawIntBits(x); | |
| 852 | + unsafe.putInt(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 853 | + } else { | |
| 854 | + Bits.putFloat(a, x, bigEndian); | |
| 855 | + } | |
| 856 | + return this; | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + } | |
| 861 | + | |
| 862 | + public ByteBuffer putFloat(float x) { | |
| 863 | + | |
| 864 | + putFloat(ix(nextPutIndex((1 << 2))), x); | |
| 865 | + return this; | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + } | |
| 870 | + | |
| 871 | + public ByteBuffer putFloat(int i, float x) { | |
| 872 | + | |
| 873 | + putFloat(ix(checkIndex(i, (1 << 2))), x); | |
| 874 | + return this; | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + } | |
| 879 | + | |
| 880 | + public FloatBuffer asFloatBuffer() { | |
| 881 | + int off = this.position(); | |
| 882 | + int lim = this.limit(); | |
| 883 | + assert (off <= lim); | |
| 884 | + int rem = (off <= lim ? lim - off : 0); | |
| 885 | + | |
| 886 | + int size = rem >> 2; | |
| 887 | + if (!unaligned && ((address + off) % (1 << 2) != 0)) { | |
| 888 | + return (bigEndian | |
| 889 | + ? (FloatBuffer)(new ByteBufferAsFloatBufferB(this, | |
| 890 | + -1, | |
| 891 | + 0, | |
| 892 | + size, | |
| 893 | + size, | |
| 894 | + off)) | |
| 895 | + : (FloatBuffer)(new ByteBufferAsFloatBufferL(this, | |
| 896 | + -1, | |
| 897 | + 0, | |
| 898 | + size, | |
| 899 | + size, | |
| 900 | + off))); | |
| 901 | + } else { | |
| 902 | + return (nativeByteOrder | |
| 903 | + ? (FloatBuffer)(new DirectFloatBufferU(this, | |
| 904 | + -1, | |
| 905 | + 0, | |
| 906 | + size, | |
| 907 | + size, | |
| 908 | + off)) | |
| 909 | + : (FloatBuffer)(new DirectFloatBufferS(this, | |
| 910 | + -1, | |
| 911 | + 0, | |
| 912 | + size, | |
| 913 | + size, | |
| 914 | + off))); | |
| 915 | + } | |
| 916 | + } | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + private double getDouble(long a) { | |
| 922 | + if (unaligned) { | |
| 923 | + long x = unsafe.getLong(a); | |
| 924 | + return Double.longBitsToDouble(nativeByteOrder ? x : Bits.swap(x)); | |
| 925 | + } | |
| 926 | + return Bits.getDouble(a, bigEndian); | |
| 927 | + } | |
| 928 | + | |
| 929 | + public double getDouble() { | |
| 930 | + return getDouble(ix(nextGetIndex((1 << 3)))); | |
| 931 | + } | |
| 932 | + | |
| 933 | + public double getDouble(int i) { | |
| 934 | + return getDouble(ix(checkIndex(i, (1 << 3)))); | |
| 935 | + } | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + private ByteBuffer putDouble(long a, double x) { | |
| 940 | + | |
| 941 | + if (unaligned) { | |
| 942 | + long y = Double.doubleToRawLongBits(x); | |
| 943 | + unsafe.putLong(a, (nativeByteOrder ? y : Bits.swap(y))); | |
| 944 | + } else { | |
| 945 | + Bits.putDouble(a, x, bigEndian); | |
| 946 | + } | |
| 947 | + return this; | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + } | |
| 952 | + | |
| 953 | + public ByteBuffer putDouble(double x) { | |
| 954 | + | |
| 955 | + putDouble(ix(nextPutIndex((1 << 3))), x); | |
| 956 | + return this; | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + } | |
| 961 | + | |
| 962 | + public ByteBuffer putDouble(int i, double x) { | |
| 963 | + | |
| 964 | + putDouble(ix(checkIndex(i, (1 << 3))), x); | |
| 965 | + return this; | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + } | |
| 970 | + | |
| 971 | + public DoubleBuffer asDoubleBuffer() { | |
| 972 | + int off = this.position(); | |
| 973 | + int lim = this.limit(); | |
| 974 | + assert (off <= lim); | |
| 975 | + int rem = (off <= lim ? lim - off : 0); | |
| 976 | + | |
| 977 | + int size = rem >> 3; | |
| 978 | + if (!unaligned && ((address + off) % (1 << 3) != 0)) { | |
| 979 | + return (bigEndian | |
| 980 | + ? (DoubleBuffer)(new ByteBufferAsDoubleBufferB(this, | |
| 981 | + -1, | |
| 982 | + 0, | |
| 983 | + size, | |
| 984 | + size, | |
| 985 | + off)) | |
| 986 | + : (DoubleBuffer)(new ByteBufferAsDoubleBufferL(this, | |
| 987 | + -1, | |
| 988 | + 0, | |
| 989 | + size, | |
| 990 | + size, | |
| 991 | + off))); | |
| 992 | + } else { | |
| 993 | + return (nativeByteOrder | |
| 994 | + ? (DoubleBuffer)(new DirectDoubleBufferU(this, | |
| 995 | + -1, | |
| 996 | + 0, | |
| 997 | + size, | |
| 998 | + size, | |
| 999 | + off)) | |
| 1000 | + : (DoubleBuffer)(new DirectDoubleBufferS(this, | |
| 1001 | + -1, | |
| 1002 | + 0, | |
| 1003 | + size, | |
| 1004 | + size, | |
| 1005 | + off))); | |
| 1006 | + } | |
| 1007 | + } | |
| 1008 | + | |
| 1009 | +} | |
| @@ -0,0 +1,1009 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectByteBufferR | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectByteBuffer | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + // Primary constructor | |
| 115 | + // | |
| 116 | + DirectByteBufferR(int cap) { // package-private | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + super(cap); | |
| 141 | + | |
| 142 | + } | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + // For memory-mapped buffers -- invoked by FileChannelImpl via reflection | |
| 157 | + // | |
| 158 | + protected DirectByteBufferR(int cap, long addr, | |
| 159 | + FileDescriptor fd, | |
| 160 | + Runnable unmapper) | |
| 161 | + { | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + super(cap, addr, fd, unmapper); | |
| 169 | + | |
| 170 | + } | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectByteBufferR(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public ByteBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 0); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectByteBufferR(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public ByteBuffer duplicate() { | |
| 203 | + return new DirectByteBufferR(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public ByteBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public ByteBuffer put(byte x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public ByteBuffer put(int i, byte x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public ByteBuffer put(ByteBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public ByteBuffer put(byte[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public ByteBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + byte _get(int i) { // package-private | |
| 452 | + return unsafe.getByte(address + i); | |
| 453 | + } | |
| 454 | + | |
| 455 | + void _put(int i, byte b) { // package-private | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + throw new ReadOnlyBufferException(); | |
| 460 | + | |
| 461 | + } | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + private ByteBuffer putChar(long a, char x) { | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + throw new ReadOnlyBufferException(); | |
| 495 | + | |
| 496 | + } | |
| 497 | + | |
| 498 | + public ByteBuffer putChar(char x) { | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + throw new ReadOnlyBufferException(); | |
| 504 | + | |
| 505 | + } | |
| 506 | + | |
| 507 | + public ByteBuffer putChar(int i, char x) { | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + throw new ReadOnlyBufferException(); | |
| 513 | + | |
| 514 | + } | |
| 515 | + | |
| 516 | + public CharBuffer asCharBuffer() { | |
| 517 | + int off = this.position(); | |
| 518 | + int lim = this.limit(); | |
| 519 | + assert (off <= lim); | |
| 520 | + int rem = (off <= lim ? lim - off : 0); | |
| 521 | + | |
| 522 | + int size = rem >> 1; | |
| 523 | + if (!unaligned && ((address + off) % (1 << 1) != 0)) { | |
| 524 | + return (bigEndian | |
| 525 | + ? (CharBuffer)(new ByteBufferAsCharBufferRB(this, | |
| 526 | + -1, | |
| 527 | + 0, | |
| 528 | + size, | |
| 529 | + size, | |
| 530 | + off)) | |
| 531 | + : (CharBuffer)(new ByteBufferAsCharBufferRL(this, | |
| 532 | + -1, | |
| 533 | + 0, | |
| 534 | + size, | |
| 535 | + size, | |
| 536 | + off))); | |
| 537 | + } else { | |
| 538 | + return (nativeByteOrder | |
| 539 | + ? (CharBuffer)(new DirectCharBufferRU(this, | |
| 540 | + -1, | |
| 541 | + 0, | |
| 542 | + size, | |
| 543 | + size, | |
| 544 | + off)) | |
| 545 | + : (CharBuffer)(new DirectCharBufferRS(this, | |
| 546 | + -1, | |
| 547 | + 0, | |
| 548 | + size, | |
| 549 | + size, | |
| 550 | + off))); | |
| 551 | + } | |
| 552 | + } | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + private ByteBuffer putShort(long a, short x) { | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + throw new ReadOnlyBufferException(); | |
| 586 | + | |
| 587 | + } | |
| 588 | + | |
| 589 | + public ByteBuffer putShort(short x) { | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + throw new ReadOnlyBufferException(); | |
| 595 | + | |
| 596 | + } | |
| 597 | + | |
| 598 | + public ByteBuffer putShort(int i, short x) { | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + throw new ReadOnlyBufferException(); | |
| 604 | + | |
| 605 | + } | |
| 606 | + | |
| 607 | + public ShortBuffer asShortBuffer() { | |
| 608 | + int off = this.position(); | |
| 609 | + int lim = this.limit(); | |
| 610 | + assert (off <= lim); | |
| 611 | + int rem = (off <= lim ? lim - off : 0); | |
| 612 | + | |
| 613 | + int size = rem >> 1; | |
| 614 | + if (!unaligned && ((address + off) % (1 << 1) != 0)) { | |
| 615 | + return (bigEndian | |
| 616 | + ? (ShortBuffer)(new ByteBufferAsShortBufferRB(this, | |
| 617 | + -1, | |
| 618 | + 0, | |
| 619 | + size, | |
| 620 | + size, | |
| 621 | + off)) | |
| 622 | + : (ShortBuffer)(new ByteBufferAsShortBufferRL(this, | |
| 623 | + -1, | |
| 624 | + 0, | |
| 625 | + size, | |
| 626 | + size, | |
| 627 | + off))); | |
| 628 | + } else { | |
| 629 | + return (nativeByteOrder | |
| 630 | + ? (ShortBuffer)(new DirectShortBufferRU(this, | |
| 631 | + -1, | |
| 632 | + 0, | |
| 633 | + size, | |
| 634 | + size, | |
| 635 | + off)) | |
| 636 | + : (ShortBuffer)(new DirectShortBufferRS(this, | |
| 637 | + -1, | |
| 638 | + 0, | |
| 639 | + size, | |
| 640 | + size, | |
| 641 | + off))); | |
| 642 | + } | |
| 643 | + } | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + private ByteBuffer putInt(long a, int x) { | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + throw new ReadOnlyBufferException(); | |
| 677 | + | |
| 678 | + } | |
| 679 | + | |
| 680 | + public ByteBuffer putInt(int x) { | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + throw new ReadOnlyBufferException(); | |
| 686 | + | |
| 687 | + } | |
| 688 | + | |
| 689 | + public ByteBuffer putInt(int i, int x) { | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + throw new ReadOnlyBufferException(); | |
| 695 | + | |
| 696 | + } | |
| 697 | + | |
| 698 | + public IntBuffer asIntBuffer() { | |
| 699 | + int off = this.position(); | |
| 700 | + int lim = this.limit(); | |
| 701 | + assert (off <= lim); | |
| 702 | + int rem = (off <= lim ? lim - off : 0); | |
| 703 | + | |
| 704 | + int size = rem >> 2; | |
| 705 | + if (!unaligned && ((address + off) % (1 << 2) != 0)) { | |
| 706 | + return (bigEndian | |
| 707 | + ? (IntBuffer)(new ByteBufferAsIntBufferRB(this, | |
| 708 | + -1, | |
| 709 | + 0, | |
| 710 | + size, | |
| 711 | + size, | |
| 712 | + off)) | |
| 713 | + : (IntBuffer)(new ByteBufferAsIntBufferRL(this, | |
| 714 | + -1, | |
| 715 | + 0, | |
| 716 | + size, | |
| 717 | + size, | |
| 718 | + off))); | |
| 719 | + } else { | |
| 720 | + return (nativeByteOrder | |
| 721 | + ? (IntBuffer)(new DirectIntBufferRU(this, | |
| 722 | + -1, | |
| 723 | + 0, | |
| 724 | + size, | |
| 725 | + size, | |
| 726 | + off)) | |
| 727 | + : (IntBuffer)(new DirectIntBufferRS(this, | |
| 728 | + -1, | |
| 729 | + 0, | |
| 730 | + size, | |
| 731 | + size, | |
| 732 | + off))); | |
| 733 | + } | |
| 734 | + } | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + private ByteBuffer putLong(long a, long x) { | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + throw new ReadOnlyBufferException(); | |
| 768 | + | |
| 769 | + } | |
| 770 | + | |
| 771 | + public ByteBuffer putLong(long x) { | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + throw new ReadOnlyBufferException(); | |
| 777 | + | |
| 778 | + } | |
| 779 | + | |
| 780 | + public ByteBuffer putLong(int i, long x) { | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + throw new ReadOnlyBufferException(); | |
| 786 | + | |
| 787 | + } | |
| 788 | + | |
| 789 | + public LongBuffer asLongBuffer() { | |
| 790 | + int off = this.position(); | |
| 791 | + int lim = this.limit(); | |
| 792 | + assert (off <= lim); | |
| 793 | + int rem = (off <= lim ? lim - off : 0); | |
| 794 | + | |
| 795 | + int size = rem >> 3; | |
| 796 | + if (!unaligned && ((address + off) % (1 << 3) != 0)) { | |
| 797 | + return (bigEndian | |
| 798 | + ? (LongBuffer)(new ByteBufferAsLongBufferRB(this, | |
| 799 | + -1, | |
| 800 | + 0, | |
| 801 | + size, | |
| 802 | + size, | |
| 803 | + off)) | |
| 804 | + : (LongBuffer)(new ByteBufferAsLongBufferRL(this, | |
| 805 | + -1, | |
| 806 | + 0, | |
| 807 | + size, | |
| 808 | + size, | |
| 809 | + off))); | |
| 810 | + } else { | |
| 811 | + return (nativeByteOrder | |
| 812 | + ? (LongBuffer)(new DirectLongBufferRU(this, | |
| 813 | + -1, | |
| 814 | + 0, | |
| 815 | + size, | |
| 816 | + size, | |
| 817 | + off)) | |
| 818 | + : (LongBuffer)(new DirectLongBufferRS(this, | |
| 819 | + -1, | |
| 820 | + 0, | |
| 821 | + size, | |
| 822 | + size, | |
| 823 | + off))); | |
| 824 | + } | |
| 825 | + } | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + private ByteBuffer putFloat(long a, float x) { | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + throw new ReadOnlyBufferException(); | |
| 859 | + | |
| 860 | + } | |
| 861 | + | |
| 862 | + public ByteBuffer putFloat(float x) { | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + throw new ReadOnlyBufferException(); | |
| 868 | + | |
| 869 | + } | |
| 870 | + | |
| 871 | + public ByteBuffer putFloat(int i, float x) { | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + throw new ReadOnlyBufferException(); | |
| 877 | + | |
| 878 | + } | |
| 879 | + | |
| 880 | + public FloatBuffer asFloatBuffer() { | |
| 881 | + int off = this.position(); | |
| 882 | + int lim = this.limit(); | |
| 883 | + assert (off <= lim); | |
| 884 | + int rem = (off <= lim ? lim - off : 0); | |
| 885 | + | |
| 886 | + int size = rem >> 2; | |
| 887 | + if (!unaligned && ((address + off) % (1 << 2) != 0)) { | |
| 888 | + return (bigEndian | |
| 889 | + ? (FloatBuffer)(new ByteBufferAsFloatBufferRB(this, | |
| 890 | + -1, | |
| 891 | + 0, | |
| 892 | + size, | |
| 893 | + size, | |
| 894 | + off)) | |
| 895 | + : (FloatBuffer)(new ByteBufferAsFloatBufferRL(this, | |
| 896 | + -1, | |
| 897 | + 0, | |
| 898 | + size, | |
| 899 | + size, | |
| 900 | + off))); | |
| 901 | + } else { | |
| 902 | + return (nativeByteOrder | |
| 903 | + ? (FloatBuffer)(new DirectFloatBufferRU(this, | |
| 904 | + -1, | |
| 905 | + 0, | |
| 906 | + size, | |
| 907 | + size, | |
| 908 | + off)) | |
| 909 | + : (FloatBuffer)(new DirectFloatBufferRS(this, | |
| 910 | + -1, | |
| 911 | + 0, | |
| 912 | + size, | |
| 913 | + size, | |
| 914 | + off))); | |
| 915 | + } | |
| 916 | + } | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + private ByteBuffer putDouble(long a, double x) { | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + throw new ReadOnlyBufferException(); | |
| 950 | + | |
| 951 | + } | |
| 952 | + | |
| 953 | + public ByteBuffer putDouble(double x) { | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + throw new ReadOnlyBufferException(); | |
| 959 | + | |
| 960 | + } | |
| 961 | + | |
| 962 | + public ByteBuffer putDouble(int i, double x) { | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + throw new ReadOnlyBufferException(); | |
| 968 | + | |
| 969 | + } | |
| 970 | + | |
| 971 | + public DoubleBuffer asDoubleBuffer() { | |
| 972 | + int off = this.position(); | |
| 973 | + int lim = this.limit(); | |
| 974 | + assert (off <= lim); | |
| 975 | + int rem = (off <= lim ? lim - off : 0); | |
| 976 | + | |
| 977 | + int size = rem >> 3; | |
| 978 | + if (!unaligned && ((address + off) % (1 << 3) != 0)) { | |
| 979 | + return (bigEndian | |
| 980 | + ? (DoubleBuffer)(new ByteBufferAsDoubleBufferRB(this, | |
| 981 | + -1, | |
| 982 | + 0, | |
| 983 | + size, | |
| 984 | + size, | |
| 985 | + off)) | |
| 986 | + : (DoubleBuffer)(new ByteBufferAsDoubleBufferRL(this, | |
| 987 | + -1, | |
| 988 | + 0, | |
| 989 | + size, | |
| 990 | + size, | |
| 991 | + off))); | |
| 992 | + } else { | |
| 993 | + return (nativeByteOrder | |
| 994 | + ? (DoubleBuffer)(new DirectDoubleBufferRU(this, | |
| 995 | + -1, | |
| 996 | + 0, | |
| 997 | + size, | |
| 998 | + size, | |
| 999 | + off)) | |
| 1000 | + : (DoubleBuffer)(new DirectDoubleBufferRS(this, | |
| 1001 | + -1, | |
| 1002 | + 0, | |
| 1003 | + size, | |
| 1004 | + size, | |
| 1005 | + off))); | |
| 1006 | + } | |
| 1007 | + } | |
| 1008 | + | |
| 1009 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectCharBufferRS | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectCharBufferS | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectCharBufferRS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public CharBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 1); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectCharBufferRS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public CharBuffer duplicate() { | |
| 203 | + return new DirectCharBufferRS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public CharBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public CharBuffer put(char x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public CharBuffer put(int i, char x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public CharBuffer put(CharBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public CharBuffer put(char[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public CharBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + public String toString(int start, int end) { | |
| 392 | + if ((end > limit()) || (start > end)) | |
| 393 | + throw new IndexOutOfBoundsException(); | |
| 394 | + try { | |
| 395 | + int len = end - start; | |
| 396 | + char[] ca = new char[len]; | |
| 397 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 398 | + CharBuffer db = this.duplicate(); | |
| 399 | + db.position(start); | |
| 400 | + db.limit(end); | |
| 401 | + cb.put(db); | |
| 402 | + return new String(ca); | |
| 403 | + } catch (StringIndexOutOfBoundsException x) { | |
| 404 | + throw new IndexOutOfBoundsException(); | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + | |
| 409 | + // --- Methods to support CharSequence --- | |
| 410 | + | |
| 411 | + public CharBuffer subSequence(int start, int end) { | |
| 412 | + int pos = position(); | |
| 413 | + int lim = limit(); | |
| 414 | + assert (pos <= lim); | |
| 415 | + pos = (pos <= lim ? pos : lim); | |
| 416 | + int len = lim - pos; | |
| 417 | + | |
| 418 | + if ((start < 0) || (end > len) || (start > end)) | |
| 419 | + throw new IndexOutOfBoundsException(); | |
| 420 | + return new DirectCharBufferRS(this, | |
| 421 | + -1, | |
| 422 | + pos + start, | |
| 423 | + pos + end, | |
| 424 | + capacity(), | |
| 425 | + offset); | |
| 426 | + } | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectCharBufferRU | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectCharBufferU | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectCharBufferRU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public CharBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 1); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectCharBufferRU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public CharBuffer duplicate() { | |
| 203 | + return new DirectCharBufferRU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public CharBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public CharBuffer put(char x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public CharBuffer put(int i, char x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public CharBuffer put(CharBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public CharBuffer put(char[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public CharBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + public String toString(int start, int end) { | |
| 392 | + if ((end > limit()) || (start > end)) | |
| 393 | + throw new IndexOutOfBoundsException(); | |
| 394 | + try { | |
| 395 | + int len = end - start; | |
| 396 | + char[] ca = new char[len]; | |
| 397 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 398 | + CharBuffer db = this.duplicate(); | |
| 399 | + db.position(start); | |
| 400 | + db.limit(end); | |
| 401 | + cb.put(db); | |
| 402 | + return new String(ca); | |
| 403 | + } catch (StringIndexOutOfBoundsException x) { | |
| 404 | + throw new IndexOutOfBoundsException(); | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + | |
| 409 | + // --- Methods to support CharSequence --- | |
| 410 | + | |
| 411 | + public CharBuffer subSequence(int start, int end) { | |
| 412 | + int pos = position(); | |
| 413 | + int lim = limit(); | |
| 414 | + assert (pos <= lim); | |
| 415 | + pos = (pos <= lim ? pos : lim); | |
| 416 | + int len = lim - pos; | |
| 417 | + | |
| 418 | + if ((start < 0) || (end > len) || (start > end)) | |
| 419 | + throw new IndexOutOfBoundsException(); | |
| 420 | + return new DirectCharBufferRU(this, | |
| 421 | + -1, | |
| 422 | + pos + start, | |
| 423 | + pos + end, | |
| 424 | + capacity(), | |
| 425 | + offset); | |
| 426 | + } | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectCharBufferS | |
| 38 | + | |
| 39 | + extends CharBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(char[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectCharBufferS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public CharBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 1); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectCharBufferS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public CharBuffer duplicate() { | |
| 203 | + return new DirectCharBufferS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public CharBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectCharBufferRS(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 1); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public char get() { | |
| 235 | + return (Bits.swap(unsafe.getChar(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public char get(int i) { | |
| 239 | + return (Bits.swap(unsafe.getChar(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public CharBuffer get(char[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToCharArray(ix(pos), dst, | |
| 256 | + offset << 1, | |
| 257 | + length << 1); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 1, | |
| 262 | + length << 1); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public CharBuffer put(char x) { | |
| 276 | + | |
| 277 | + unsafe.putChar(ix(nextPutIndex()), Bits.swap((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public CharBuffer put(int i, char x) { | |
| 285 | + | |
| 286 | + unsafe.putChar(ix(checkIndex(i)), Bits.swap((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public CharBuffer put(CharBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectCharBufferS) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectCharBufferS sb = (DirectCharBufferS)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public CharBuffer put(char[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromCharArray(src, offset << 1, | |
| 348 | + ix(pos), length << 1); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 1, | |
| 352 | + ix(pos), length << 1); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public CharBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 1); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + public String toString(int start, int end) { | |
| 392 | + if ((end > limit()) || (start > end)) | |
| 393 | + throw new IndexOutOfBoundsException(); | |
| 394 | + try { | |
| 395 | + int len = end - start; | |
| 396 | + char[] ca = new char[len]; | |
| 397 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 398 | + CharBuffer db = this.duplicate(); | |
| 399 | + db.position(start); | |
| 400 | + db.limit(end); | |
| 401 | + cb.put(db); | |
| 402 | + return new String(ca); | |
| 403 | + } catch (StringIndexOutOfBoundsException x) { | |
| 404 | + throw new IndexOutOfBoundsException(); | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + | |
| 409 | + // --- Methods to support CharSequence --- | |
| 410 | + | |
| 411 | + public CharBuffer subSequence(int start, int end) { | |
| 412 | + int pos = position(); | |
| 413 | + int lim = limit(); | |
| 414 | + assert (pos <= lim); | |
| 415 | + pos = (pos <= lim ? pos : lim); | |
| 416 | + int len = lim - pos; | |
| 417 | + | |
| 418 | + if ((start < 0) || (end > len) || (start > end)) | |
| 419 | + throw new IndexOutOfBoundsException(); | |
| 420 | + return new DirectCharBufferS(this, | |
| 421 | + -1, | |
| 422 | + pos + start, | |
| 423 | + pos + end, | |
| 424 | + capacity(), | |
| 425 | + offset); | |
| 426 | + } | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectCharBufferU | |
| 38 | + | |
| 39 | + extends CharBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(char[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectCharBufferU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public CharBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 1); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectCharBufferU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public CharBuffer duplicate() { | |
| 203 | + return new DirectCharBufferU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public CharBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectCharBufferRU(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 1); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public char get() { | |
| 235 | + return ((unsafe.getChar(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public char get(int i) { | |
| 239 | + return ((unsafe.getChar(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public CharBuffer get(char[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToCharArray(ix(pos), dst, | |
| 256 | + offset << 1, | |
| 257 | + length << 1); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 1, | |
| 262 | + length << 1); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public CharBuffer put(char x) { | |
| 276 | + | |
| 277 | + unsafe.putChar(ix(nextPutIndex()), ((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public CharBuffer put(int i, char x) { | |
| 285 | + | |
| 286 | + unsafe.putChar(ix(checkIndex(i)), ((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public CharBuffer put(CharBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectCharBufferU) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectCharBufferU sb = (DirectCharBufferU)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public CharBuffer put(char[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromCharArray(src, offset << 1, | |
| 348 | + ix(pos), length << 1); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 1, | |
| 352 | + ix(pos), length << 1); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public CharBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 1); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + public String toString(int start, int end) { | |
| 392 | + if ((end > limit()) || (start > end)) | |
| 393 | + throw new IndexOutOfBoundsException(); | |
| 394 | + try { | |
| 395 | + int len = end - start; | |
| 396 | + char[] ca = new char[len]; | |
| 397 | + CharBuffer cb = CharBuffer.wrap(ca); | |
| 398 | + CharBuffer db = this.duplicate(); | |
| 399 | + db.position(start); | |
| 400 | + db.limit(end); | |
| 401 | + cb.put(db); | |
| 402 | + return new String(ca); | |
| 403 | + } catch (StringIndexOutOfBoundsException x) { | |
| 404 | + throw new IndexOutOfBoundsException(); | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + | |
| 409 | + // --- Methods to support CharSequence --- | |
| 410 | + | |
| 411 | + public CharBuffer subSequence(int start, int end) { | |
| 412 | + int pos = position(); | |
| 413 | + int lim = limit(); | |
| 414 | + assert (pos <= lim); | |
| 415 | + pos = (pos <= lim ? pos : lim); | |
| 416 | + int len = lim - pos; | |
| 417 | + | |
| 418 | + if ((start < 0) || (end > len) || (start > end)) | |
| 419 | + throw new IndexOutOfBoundsException(); | |
| 420 | + return new DirectCharBufferU(this, | |
| 421 | + -1, | |
| 422 | + pos + start, | |
| 423 | + pos + end, | |
| 424 | + capacity(), | |
| 425 | + offset); | |
| 426 | + } | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectDoubleBufferRS | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectDoubleBufferS | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectDoubleBufferRS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public DoubleBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectDoubleBufferRS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public DoubleBuffer duplicate() { | |
| 203 | + return new DirectDoubleBufferRS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public DoubleBuffer put(double x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public DoubleBuffer put(int i, double x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public DoubleBuffer put(DoubleBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public DoubleBuffer put(double[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public DoubleBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectDoubleBufferRU | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectDoubleBufferU | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectDoubleBufferRU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public DoubleBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectDoubleBufferRU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public DoubleBuffer duplicate() { | |
| 203 | + return new DirectDoubleBufferRU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public DoubleBuffer put(double x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public DoubleBuffer put(int i, double x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public DoubleBuffer put(DoubleBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public DoubleBuffer put(double[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public DoubleBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectDoubleBufferS | |
| 38 | + | |
| 39 | + extends DoubleBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(double[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectDoubleBufferS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public DoubleBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectDoubleBufferS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public DoubleBuffer duplicate() { | |
| 203 | + return new DirectDoubleBufferS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectDoubleBufferRS(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 3); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public double get() { | |
| 235 | + return Double.longBitsToDouble(Bits.swap(unsafe.getLong(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public double get(int i) { | |
| 239 | + return Double.longBitsToDouble(Bits.swap(unsafe.getLong(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public DoubleBuffer get(double[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToLongArray(ix(pos), dst, | |
| 256 | + offset << 3, | |
| 257 | + length << 3); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 3, | |
| 262 | + length << 3); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public DoubleBuffer put(double x) { | |
| 276 | + | |
| 277 | + unsafe.putLong(ix(nextPutIndex()), Bits.swap(Double.doubleToRawLongBits(x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public DoubleBuffer put(int i, double x) { | |
| 285 | + | |
| 286 | + unsafe.putLong(ix(checkIndex(i)), Bits.swap(Double.doubleToRawLongBits(x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public DoubleBuffer put(DoubleBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectDoubleBufferS) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectDoubleBufferS sb = (DirectDoubleBufferS)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public DoubleBuffer put(double[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromLongArray(src, offset << 3, | |
| 348 | + ix(pos), length << 3); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 3, | |
| 352 | + ix(pos), length << 3); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public DoubleBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 3); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectDoubleBufferU | |
| 38 | + | |
| 39 | + extends DoubleBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(double[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectDoubleBufferU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public DoubleBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectDoubleBufferU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public DoubleBuffer duplicate() { | |
| 203 | + return new DirectDoubleBufferU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public DoubleBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectDoubleBufferRU(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 3); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public double get() { | |
| 235 | + return ((unsafe.getDouble(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public double get(int i) { | |
| 239 | + return ((unsafe.getDouble(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public DoubleBuffer get(double[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToLongArray(ix(pos), dst, | |
| 256 | + offset << 3, | |
| 257 | + length << 3); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 3, | |
| 262 | + length << 3); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public DoubleBuffer put(double x) { | |
| 276 | + | |
| 277 | + unsafe.putDouble(ix(nextPutIndex()), ((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public DoubleBuffer put(int i, double x) { | |
| 285 | + | |
| 286 | + unsafe.putDouble(ix(checkIndex(i)), ((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public DoubleBuffer put(DoubleBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectDoubleBufferU) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectDoubleBufferU sb = (DirectDoubleBufferU)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public DoubleBuffer put(double[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromLongArray(src, offset << 3, | |
| 348 | + ix(pos), length << 3); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 3, | |
| 352 | + ix(pos), length << 3); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public DoubleBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 3); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectFloatBufferRS | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectFloatBufferS | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectFloatBufferRS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public FloatBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectFloatBufferRS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public FloatBuffer duplicate() { | |
| 203 | + return new DirectFloatBufferRS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public FloatBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public FloatBuffer put(float x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public FloatBuffer put(int i, float x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public FloatBuffer put(FloatBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public FloatBuffer put(float[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public FloatBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectFloatBufferRU | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectFloatBufferU | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectFloatBufferRU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public FloatBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectFloatBufferRU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public FloatBuffer duplicate() { | |
| 203 | + return new DirectFloatBufferRU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public FloatBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public FloatBuffer put(float x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public FloatBuffer put(int i, float x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public FloatBuffer put(FloatBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public FloatBuffer put(float[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public FloatBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectFloatBufferS | |
| 38 | + | |
| 39 | + extends FloatBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(float[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectFloatBufferS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public FloatBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectFloatBufferS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public FloatBuffer duplicate() { | |
| 203 | + return new DirectFloatBufferS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public FloatBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectFloatBufferRS(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 2); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public float get() { | |
| 235 | + return Float.intBitsToFloat(Bits.swap(unsafe.getInt(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public float get(int i) { | |
| 239 | + return Float.intBitsToFloat(Bits.swap(unsafe.getInt(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public FloatBuffer get(float[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToIntArray(ix(pos), dst, | |
| 256 | + offset << 2, | |
| 257 | + length << 2); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 2, | |
| 262 | + length << 2); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public FloatBuffer put(float x) { | |
| 276 | + | |
| 277 | + unsafe.putInt(ix(nextPutIndex()), Bits.swap(Float.floatToRawIntBits(x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public FloatBuffer put(int i, float x) { | |
| 285 | + | |
| 286 | + unsafe.putInt(ix(checkIndex(i)), Bits.swap(Float.floatToRawIntBits(x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public FloatBuffer put(FloatBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectFloatBufferS) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectFloatBufferS sb = (DirectFloatBufferS)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public FloatBuffer put(float[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromIntArray(src, offset << 2, | |
| 348 | + ix(pos), length << 2); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 2, | |
| 352 | + ix(pos), length << 2); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public FloatBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 2); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectFloatBufferU | |
| 38 | + | |
| 39 | + extends FloatBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(float[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectFloatBufferU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public FloatBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectFloatBufferU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public FloatBuffer duplicate() { | |
| 203 | + return new DirectFloatBufferU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public FloatBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectFloatBufferRU(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 2); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public float get() { | |
| 235 | + return ((unsafe.getFloat(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public float get(int i) { | |
| 239 | + return ((unsafe.getFloat(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public FloatBuffer get(float[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToIntArray(ix(pos), dst, | |
| 256 | + offset << 2, | |
| 257 | + length << 2); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 2, | |
| 262 | + length << 2); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public FloatBuffer put(float x) { | |
| 276 | + | |
| 277 | + unsafe.putFloat(ix(nextPutIndex()), ((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public FloatBuffer put(int i, float x) { | |
| 285 | + | |
| 286 | + unsafe.putFloat(ix(checkIndex(i)), ((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public FloatBuffer put(FloatBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectFloatBufferU) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectFloatBufferU sb = (DirectFloatBufferU)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public FloatBuffer put(float[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromIntArray(src, offset << 2, | |
| 348 | + ix(pos), length << 2); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 2, | |
| 352 | + ix(pos), length << 2); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public FloatBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 2); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectIntBufferRS | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectIntBufferS | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectIntBufferRS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public IntBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectIntBufferRS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public IntBuffer duplicate() { | |
| 203 | + return new DirectIntBufferRS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public IntBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public IntBuffer put(int x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public IntBuffer put(int i, int x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public IntBuffer put(IntBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public IntBuffer put(int[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public IntBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectIntBufferRU | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectIntBufferU | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectIntBufferRU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public IntBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectIntBufferRU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public IntBuffer duplicate() { | |
| 203 | + return new DirectIntBufferRU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public IntBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public IntBuffer put(int x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public IntBuffer put(int i, int x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public IntBuffer put(IntBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public IntBuffer put(int[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public IntBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectIntBufferS | |
| 38 | + | |
| 39 | + extends IntBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(int[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectIntBufferS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public IntBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectIntBufferS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public IntBuffer duplicate() { | |
| 203 | + return new DirectIntBufferS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public IntBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectIntBufferRS(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 2); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public int get() { | |
| 235 | + return (Bits.swap(unsafe.getInt(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public int get(int i) { | |
| 239 | + return (Bits.swap(unsafe.getInt(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public IntBuffer get(int[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToIntArray(ix(pos), dst, | |
| 256 | + offset << 2, | |
| 257 | + length << 2); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 2, | |
| 262 | + length << 2); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public IntBuffer put(int x) { | |
| 276 | + | |
| 277 | + unsafe.putInt(ix(nextPutIndex()), Bits.swap((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public IntBuffer put(int i, int x) { | |
| 285 | + | |
| 286 | + unsafe.putInt(ix(checkIndex(i)), Bits.swap((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public IntBuffer put(IntBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectIntBufferS) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectIntBufferS sb = (DirectIntBufferS)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public IntBuffer put(int[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromIntArray(src, offset << 2, | |
| 348 | + ix(pos), length << 2); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 2, | |
| 352 | + ix(pos), length << 2); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public IntBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 2); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectIntBufferU | |
| 38 | + | |
| 39 | + extends IntBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(int[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectIntBufferU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public IntBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 2); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectIntBufferU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public IntBuffer duplicate() { | |
| 203 | + return new DirectIntBufferU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public IntBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectIntBufferRU(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 2); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public int get() { | |
| 235 | + return ((unsafe.getInt(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public int get(int i) { | |
| 239 | + return ((unsafe.getInt(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public IntBuffer get(int[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToIntArray(ix(pos), dst, | |
| 256 | + offset << 2, | |
| 257 | + length << 2); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 2, | |
| 262 | + length << 2); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public IntBuffer put(int x) { | |
| 276 | + | |
| 277 | + unsafe.putInt(ix(nextPutIndex()), ((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public IntBuffer put(int i, int x) { | |
| 285 | + | |
| 286 | + unsafe.putInt(ix(checkIndex(i)), ((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public IntBuffer put(IntBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectIntBufferU) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectIntBufferU sb = (DirectIntBufferU)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public IntBuffer put(int[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromIntArray(src, offset << 2, | |
| 348 | + ix(pos), length << 2); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 2, | |
| 352 | + ix(pos), length << 2); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public IntBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 2); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectLongBufferRS | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectLongBufferS | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectLongBufferRS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public LongBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectLongBufferRS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public LongBuffer duplicate() { | |
| 203 | + return new DirectLongBufferRS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public LongBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public LongBuffer put(long x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public LongBuffer put(int i, long x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public LongBuffer put(LongBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public LongBuffer put(long[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public LongBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectLongBufferRU | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + extends DirectLongBufferU | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectLongBufferRU(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + super(db, mark, pos, lim, cap, off); | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public LongBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectLongBufferRU(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public LongBuffer duplicate() { | |
| 203 | + return new DirectLongBufferRU(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public LongBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + return duplicate(); | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public LongBuffer put(long x) { | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + throw new ReadOnlyBufferException(); | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public LongBuffer put(int i, long x) { | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + throw new ReadOnlyBufferException(); | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public LongBuffer put(LongBuffer src) { | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + throw new ReadOnlyBufferException(); | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public LongBuffer put(long[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + throw new ReadOnlyBufferException(); | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public LongBuffer compact() { | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + throw new ReadOnlyBufferException(); | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return true; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) | |
| 441 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 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 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +// -- This file was mechanically generated: Do not edit! -- // | |
| 27 | + | |
| 28 | +package java.nio; | |
| 29 | + | |
| 30 | +import java.io.FileDescriptor; | |
| 31 | +import sun.misc.Cleaner; | |
| 32 | +import sun.misc.Unsafe; | |
| 33 | +import sun.misc.VM; | |
| 34 | +import sun.nio.ch.DirectBuffer; | |
| 35 | + | |
| 36 | + | |
| 37 | +class DirectLongBufferS | |
| 38 | + | |
| 39 | + extends LongBuffer | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + implements DirectBuffer | |
| 44 | +{ | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + // Cached unsafe-access object | |
| 49 | + protected static final Unsafe unsafe = Bits.unsafe(); | |
| 50 | + | |
| 51 | + // Cached array base offset | |
| 52 | + private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(long[].class); | |
| 53 | + | |
| 54 | + // Cached unaligned-access capability | |
| 55 | + protected static final boolean unaligned = Bits.unaligned(); | |
| 56 | + | |
| 57 | + // Base address, used in all indexing calculations | |
| 58 | + // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress | |
| 59 | + // protected long address; | |
| 60 | + | |
| 61 | + // If this buffer is a view of another buffer then we keep a reference to | |
| 62 | + // that buffer so that its memory isn't freed before we're done with it | |
| 63 | + protected Object viewedBuffer = null; | |
| 64 | + | |
| 65 | + public Object viewedBuffer() { | |
| 66 | + return viewedBuffer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + public Cleaner cleaner() { return null; } | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + // For duplicates and slices | |
| 175 | + // | |
| 176 | + DirectLongBufferS(DirectBuffer db, // package-private | |
| 177 | + int mark, int pos, int lim, int cap, | |
| 178 | + int off) | |
| 179 | + { | |
| 180 | + | |
| 181 | + super(mark, pos, lim, cap); | |
| 182 | + address = db.address() + off; | |
| 183 | + viewedBuffer = db; | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + public LongBuffer slice() { | |
| 193 | + int pos = this.position(); | |
| 194 | + int lim = this.limit(); | |
| 195 | + assert (pos <= lim); | |
| 196 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 197 | + int off = (pos << 3); | |
| 198 | + assert (off >= 0); | |
| 199 | + return new DirectLongBufferS(this, -1, 0, rem, rem, off); | |
| 200 | + } | |
| 201 | + | |
| 202 | + public LongBuffer duplicate() { | |
| 203 | + return new DirectLongBufferS(this, | |
| 204 | + this.markValue(), | |
| 205 | + this.position(), | |
| 206 | + this.limit(), | |
| 207 | + this.capacity(), | |
| 208 | + 0); | |
| 209 | + } | |
| 210 | + | |
| 211 | + public LongBuffer asReadOnlyBuffer() { | |
| 212 | + | |
| 213 | + return new DirectLongBufferRS(this, | |
| 214 | + this.markValue(), | |
| 215 | + this.position(), | |
| 216 | + this.limit(), | |
| 217 | + this.capacity(), | |
| 218 | + 0); | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + } | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + public long address() { | |
| 227 | + return address; | |
| 228 | + } | |
| 229 | + | |
| 230 | + private long ix(int i) { | |
| 231 | + return address + (i << 3); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public long get() { | |
| 235 | + return (Bits.swap(unsafe.getLong(ix(nextGetIndex())))); | |
| 236 | + } | |
| 237 | + | |
| 238 | + public long get(int i) { | |
| 239 | + return (Bits.swap(unsafe.getLong(ix(checkIndex(i))))); | |
| 240 | + } | |
| 241 | + | |
| 242 | + public LongBuffer get(long[] dst, int offset, int length) { | |
| 243 | + | |
| 244 | + if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { | |
| 245 | + checkBounds(offset, length, dst.length); | |
| 246 | + int pos = position(); | |
| 247 | + int lim = limit(); | |
| 248 | + assert (pos <= lim); | |
| 249 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 250 | + if (length > rem) | |
| 251 | + throw new BufferUnderflowException(); | |
| 252 | + | |
| 253 | + | |
| 254 | + if (order() != ByteOrder.nativeOrder()) | |
| 255 | + Bits.copyToLongArray(ix(pos), dst, | |
| 256 | + offset << 3, | |
| 257 | + length << 3); | |
| 258 | + else | |
| 259 | + | |
| 260 | + Bits.copyToArray(ix(pos), dst, arrayBaseOffset, | |
| 261 | + offset << 3, | |
| 262 | + length << 3); | |
| 263 | + position(pos + length); | |
| 264 | + } else { | |
| 265 | + super.get(dst, offset, length); | |
| 266 | + } | |
| 267 | + return this; | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + } | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + public LongBuffer put(long x) { | |
| 276 | + | |
| 277 | + unsafe.putLong(ix(nextPutIndex()), Bits.swap((x))); | |
| 278 | + return this; | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + } | |
| 283 | + | |
| 284 | + public LongBuffer put(int i, long x) { | |
| 285 | + | |
| 286 | + unsafe.putLong(ix(checkIndex(i)), Bits.swap((x))); | |
| 287 | + return this; | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + } | |
| 292 | + | |
| 293 | + public LongBuffer put(LongBuffer src) { | |
| 294 | + | |
| 295 | + if (src instanceof DirectLongBufferS) { | |
| 296 | + if (src == this) | |
| 297 | + throw new IllegalArgumentException(); | |
| 298 | + DirectLongBufferS sb = (DirectLongBufferS)src; | |
| 299 | + | |
| 300 | + int spos = sb.position(); | |
| 301 | + int slim = sb.limit(); | |
| 302 | + assert (spos <= slim); | |
| 303 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 304 | + | |
| 305 | + int pos = position(); | |
| 306 | + int lim = limit(); | |
| 307 | + assert (pos <= lim); | |
| 308 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 309 | + | |
| 310 | + if (srem > rem) | |
| 311 | + throw new BufferOverflowException(); | |
| 312 | + unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); | |
| 313 | + sb.position(spos + srem); | |
| 314 | + position(pos + srem); | |
| 315 | + } else if (src.hb != null) { | |
| 316 | + | |
| 317 | + int spos = src.position(); | |
| 318 | + int slim = src.limit(); | |
| 319 | + assert (spos <= slim); | |
| 320 | + int srem = (spos <= slim ? slim - spos : 0); | |
| 321 | + | |
| 322 | + put(src.hb, src.offset + spos, srem); | |
| 323 | + src.position(spos + srem); | |
| 324 | + | |
| 325 | + } else { | |
| 326 | + super.put(src); | |
| 327 | + } | |
| 328 | + return this; | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + } | |
| 333 | + | |
| 334 | + public LongBuffer put(long[] src, int offset, int length) { | |
| 335 | + | |
| 336 | + if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { | |
| 337 | + checkBounds(offset, length, src.length); | |
| 338 | + int pos = position(); | |
| 339 | + int lim = limit(); | |
| 340 | + assert (pos <= lim); | |
| 341 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 342 | + if (length > rem) | |
| 343 | + throw new BufferOverflowException(); | |
| 344 | + | |
| 345 | + | |
| 346 | + if (order() != ByteOrder.nativeOrder()) | |
| 347 | + Bits.copyFromLongArray(src, offset << 3, | |
| 348 | + ix(pos), length << 3); | |
| 349 | + else | |
| 350 | + | |
| 351 | + Bits.copyFromArray(src, arrayBaseOffset, offset << 3, | |
| 352 | + ix(pos), length << 3); | |
| 353 | + position(pos + length); | |
| 354 | + } else { | |
| 355 | + super.put(src, offset, length); | |
| 356 | + } | |
| 357 | + return this; | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + } | |
| 362 | + | |
| 363 | + public LongBuffer compact() { | |
| 364 | + | |
| 365 | + int pos = position(); | |
| 366 | + int lim = limit(); | |
| 367 | + assert (pos <= lim); | |
| 368 | + int rem = (pos <= lim ? lim - pos : 0); | |
| 369 | + | |
| 370 | + unsafe.copyMemory(ix(pos), ix(0), rem << 3); | |
| 371 | + position(rem); | |
| 372 | + limit(capacity()); | |
| 373 | + discardMark(); | |
| 374 | + return this; | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + } | |
| 379 | + | |
| 380 | + public boolean isDirect() { | |
| 381 | + return true; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public boolean isReadOnly() { | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + public ByteOrder order() { | |
| 435 | + | |
| 436 | + return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) | |
| 437 | + ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | +} | |
| @@ -0,0 +1,470 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. | |
| 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 | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
459 more lines aren’t shown here.
This diff is large: its 471 lines aren’t shown here.
This diff is large: its 471 lines aren’t shown here.
This diff is large: its 471 lines aren’t shown here.
This diff is large: its 471 lines aren’t shown here.
This diff is large: its 1452 lines aren’t shown here.
This diff is large: its 1452 lines aren’t shown here.
This diff is large: its 603 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 603 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 596 lines aren’t shown here.
This diff is large: its 1452 lines aren’t shown here.
This diff is large: its 52 lines aren’t shown here.
This diff is large: its 1452 lines aren’t shown here.
This diff is large: its 52 lines aren’t shown here.
This diff is large: its 1452 lines aren’t shown here.
This diff is large: its 52 lines aren’t shown here.
This diff is large: its 29 lines aren’t shown here.
This diff is large: its 973 lines aren’t shown here.
This diff is large: its 973 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.
This diff is large: its 69 lines aren’t shown here.