feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
1026
jdkSrc/jdk8/java/nio/Bits.java
Normal file
1026
jdkSrc/jdk8/java/nio/Bits.java
Normal file
File diff suppressed because it is too large
Load Diff
575
jdkSrc/jdk8/java/nio/Buffer.java
Normal file
575
jdkSrc/jdk8/java/nio/Buffer.java
Normal file
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.util.Spliterator;
|
||||
|
||||
/**
|
||||
* A container for data of a specific primitive type.
|
||||
*
|
||||
* <p> A buffer is a linear, finite sequence of elements of a specific
|
||||
* primitive type. Aside from its content, the essential properties of a
|
||||
* buffer are its capacity, limit, and position: </p>
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <p> A buffer's <i>capacity</i> is the number of elements it contains. The
|
||||
* capacity of a buffer is never negative and never changes. </p>
|
||||
*
|
||||
* <p> A buffer's <i>limit</i> is the index of the first element that should
|
||||
* not be read or written. A buffer's limit is never negative and is never
|
||||
* greater than its capacity. </p>
|
||||
*
|
||||
* <p> A buffer's <i>position</i> is the index of the next element to be
|
||||
* read or written. A buffer's position is never negative and is never
|
||||
* greater than its limit. </p>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> There is one subclass of this class for each non-boolean primitive type.
|
||||
*
|
||||
*
|
||||
* <h2> Transferring data </h2>
|
||||
*
|
||||
* <p> Each subclass of this class defines two categories of <i>get</i> and
|
||||
* <i>put</i> operations: </p>
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <p> <i>Relative</i> operations read or write one or more elements starting
|
||||
* at the current position and then increment the position by the number of
|
||||
* elements transferred. If the requested transfer exceeds the limit then a
|
||||
* relative <i>get</i> operation throws a {@link BufferUnderflowException}
|
||||
* and a relative <i>put</i> operation throws a {@link
|
||||
* BufferOverflowException}; in either case, no data is transferred. </p>
|
||||
*
|
||||
* <p> <i>Absolute</i> operations take an explicit element index and do not
|
||||
* affect the position. Absolute <i>get</i> and <i>put</i> operations throw
|
||||
* an {@link IndexOutOfBoundsException} if the index argument exceeds the
|
||||
* limit. </p>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> Data may also, of course, be transferred in to or out of a buffer by the
|
||||
* I/O operations of an appropriate channel, which are always relative to the
|
||||
* current position.
|
||||
*
|
||||
*
|
||||
* <h2> Marking and resetting </h2>
|
||||
*
|
||||
* <p> A buffer's <i>mark</i> is the index to which its position will be reset
|
||||
* when the {@link #reset reset} method is invoked. The mark is not always
|
||||
* defined, but when it is defined it is never negative and is never greater
|
||||
* than the position. If the mark is defined then it is discarded when the
|
||||
* position or the limit is adjusted to a value smaller than the mark. If the
|
||||
* mark is not defined then invoking the {@link #reset reset} method causes an
|
||||
* {@link InvalidMarkException} to be thrown.
|
||||
*
|
||||
*
|
||||
* <h2> Invariants </h2>
|
||||
*
|
||||
* <p> The following invariant holds for the mark, position, limit, and
|
||||
* capacity values:
|
||||
*
|
||||
* <blockquote>
|
||||
* <tt>0</tt> <tt><=</tt>
|
||||
* <i>mark</i> <tt><=</tt>
|
||||
* <i>position</i> <tt><=</tt>
|
||||
* <i>limit</i> <tt><=</tt>
|
||||
* <i>capacity</i>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> A newly-created buffer always has a position of zero and a mark that is
|
||||
* undefined. The initial limit may be zero, or it may be some other value
|
||||
* that depends upon the type of the buffer and the manner in which it is
|
||||
* constructed. Each element of a newly-allocated buffer is initialized
|
||||
* to zero.
|
||||
*
|
||||
*
|
||||
* <h2> Clearing, flipping, and rewinding </h2>
|
||||
*
|
||||
* <p> In addition to methods for accessing the position, limit, and capacity
|
||||
* values and for marking and resetting, this class also defines the following
|
||||
* operations upon buffers:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p> {@link #clear} makes a buffer ready for a new sequence of
|
||||
* channel-read or relative <i>put</i> operations: It sets the limit to the
|
||||
* capacity and the position to zero. </p></li>
|
||||
*
|
||||
* <li><p> {@link #flip} makes a buffer ready for a new sequence of
|
||||
* channel-write or relative <i>get</i> operations: It sets the limit to the
|
||||
* current position and then sets the position to zero. </p></li>
|
||||
*
|
||||
* <li><p> {@link #rewind} makes a buffer ready for re-reading the data that
|
||||
* it already contains: It leaves the limit unchanged and sets the position
|
||||
* to zero. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <h2> Read-only buffers </h2>
|
||||
*
|
||||
* <p> Every buffer is readable, but not every buffer is writable. The
|
||||
* mutation methods of each buffer class are specified as <i>optional
|
||||
* operations</i> that will throw a {@link ReadOnlyBufferException} when
|
||||
* invoked upon a read-only buffer. A read-only buffer does not allow its
|
||||
* content to be changed, but its mark, position, and limit values are mutable.
|
||||
* Whether or not a buffer is read-only may be determined by invoking its
|
||||
* {@link #isReadOnly isReadOnly} method.
|
||||
*
|
||||
*
|
||||
* <h2> Thread safety </h2>
|
||||
*
|
||||
* <p> Buffers are not safe for use by multiple concurrent threads. If a
|
||||
* buffer is to be used by more than one thread then access to the buffer
|
||||
* should be controlled by appropriate synchronization.
|
||||
*
|
||||
*
|
||||
* <h2> Invocation chaining </h2>
|
||||
*
|
||||
* <p> Methods in this class that do not otherwise have a value to return are
|
||||
* specified to return the buffer upon which they are invoked. This allows
|
||||
* method invocations to be chained; for example, the sequence of statements
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* b.flip();
|
||||
* b.position(23);
|
||||
* b.limit(42);</pre></blockquote>
|
||||
*
|
||||
* can be replaced by the single, more compact statement
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* b.flip().position(23).limit(42);</pre></blockquote>
|
||||
*
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public abstract class Buffer {
|
||||
|
||||
/**
|
||||
* The characteristics of Spliterators that traverse and split elements
|
||||
* maintained in Buffers.
|
||||
*/
|
||||
static final int SPLITERATOR_CHARACTERISTICS =
|
||||
Spliterator.SIZED | Spliterator.SUBSIZED | Spliterator.ORDERED;
|
||||
|
||||
// Invariants: mark <= position <= limit <= capacity
|
||||
private int mark = -1;
|
||||
private int position = 0;
|
||||
private int limit;
|
||||
private int capacity;
|
||||
|
||||
// Used only by direct buffers
|
||||
// NOTE: hoisted here for speed in JNI GetDirectBufferAddress
|
||||
long address;
|
||||
|
||||
// Creates a new buffer with the given mark, position, limit, and capacity,
|
||||
// after checking invariants.
|
||||
//
|
||||
Buffer(int mark, int pos, int lim, int cap) { // package-private
|
||||
if (cap < 0)
|
||||
throw new IllegalArgumentException("Negative capacity: " + cap);
|
||||
this.capacity = cap;
|
||||
limit(lim);
|
||||
position(pos);
|
||||
if (mark >= 0) {
|
||||
if (mark > pos)
|
||||
throw new IllegalArgumentException("mark > position: ("
|
||||
+ mark + " > " + pos + ")");
|
||||
this.mark = mark;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this buffer's capacity.
|
||||
*
|
||||
* @return The capacity of this buffer
|
||||
*/
|
||||
public final int capacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this buffer's position.
|
||||
*
|
||||
* @return The position of this buffer
|
||||
*/
|
||||
public final int position() {
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this buffer's position. If the mark is defined and larger than the
|
||||
* new position then it is discarded.
|
||||
*
|
||||
* @param newPosition
|
||||
* The new position value; must be non-negative
|
||||
* and no larger than the current limit
|
||||
*
|
||||
* @return This buffer
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the preconditions on <tt>newPosition</tt> do not hold
|
||||
*/
|
||||
public final Buffer position(int newPosition) {
|
||||
if ((newPosition > limit) || (newPosition < 0))
|
||||
throw new IllegalArgumentException();
|
||||
if (mark > newPosition) mark = -1;
|
||||
position = newPosition;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this buffer's limit.
|
||||
*
|
||||
* @return The limit of this buffer
|
||||
*/
|
||||
public final int limit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this buffer's limit. If the position is larger than the new limit
|
||||
* then it is set to the new limit. If the mark is defined and larger than
|
||||
* the new limit then it is discarded.
|
||||
*
|
||||
* @param newLimit
|
||||
* The new limit value; must be non-negative
|
||||
* and no larger than this buffer's capacity
|
||||
*
|
||||
* @return This buffer
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the preconditions on <tt>newLimit</tt> do not hold
|
||||
*/
|
||||
public final Buffer limit(int newLimit) {
|
||||
if ((newLimit > capacity) || (newLimit < 0))
|
||||
throw new IllegalArgumentException();
|
||||
limit = newLimit;
|
||||
if (position > newLimit) position = newLimit;
|
||||
if (mark > newLimit) mark = -1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this buffer's mark at its position.
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final Buffer mark() {
|
||||
mark = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this buffer's position to the previously-marked position.
|
||||
*
|
||||
* <p> Invoking this method neither changes nor discards the mark's
|
||||
* value. </p>
|
||||
*
|
||||
* @return This buffer
|
||||
*
|
||||
* @throws InvalidMarkException
|
||||
* If the mark has not been set
|
||||
*/
|
||||
public final Buffer reset() {
|
||||
int m = mark;
|
||||
if (m < 0)
|
||||
throw new InvalidMarkException();
|
||||
position = m;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears this buffer. The position is set to zero, the limit is set to
|
||||
* the capacity, and the mark is discarded.
|
||||
*
|
||||
* <p> Invoke this method before using a sequence of channel-read or
|
||||
* <i>put</i> operations to fill this buffer. For example:
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* buf.clear(); // Prepare buffer for reading
|
||||
* in.read(buf); // Read data</pre></blockquote>
|
||||
*
|
||||
* <p> This method does not actually erase the data in the buffer, but it
|
||||
* is named as if it did because it will most often be used in situations
|
||||
* in which that might as well be the case. </p>
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final Buffer clear() {
|
||||
position = 0;
|
||||
limit = capacity;
|
||||
mark = -1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips this buffer. The limit is set to the current position and then
|
||||
* the position is set to zero. If the mark is defined then it is
|
||||
* discarded.
|
||||
*
|
||||
* <p> After a sequence of channel-read or <i>put</i> operations, invoke
|
||||
* this method to prepare for a sequence of channel-write or relative
|
||||
* <i>get</i> operations. For example:
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* buf.put(magic); // Prepend header
|
||||
* in.read(buf); // Read data into rest of buffer
|
||||
* buf.flip(); // Flip buffer
|
||||
* out.write(buf); // Write header + data to channel</pre></blockquote>
|
||||
*
|
||||
* <p> This method is often used in conjunction with the {@link
|
||||
* java.nio.ByteBuffer#compact compact} method when transferring data from
|
||||
* one place to another. </p>
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final Buffer flip() {
|
||||
limit = position;
|
||||
position = 0;
|
||||
mark = -1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewinds this buffer. The position is set to zero and the mark is
|
||||
* discarded.
|
||||
*
|
||||
* <p> Invoke this method before a sequence of channel-write or <i>get</i>
|
||||
* operations, assuming that the limit has already been set
|
||||
* appropriately. For example:
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* out.write(buf); // Write remaining data
|
||||
* buf.rewind(); // Rewind buffer
|
||||
* buf.get(array); // Copy data into array</pre></blockquote>
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final Buffer rewind() {
|
||||
position = 0;
|
||||
mark = -1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements between the current position and the
|
||||
* limit.
|
||||
*
|
||||
* @return The number of elements remaining in this buffer
|
||||
*/
|
||||
public final int remaining() {
|
||||
int rem = limit - position;
|
||||
return rem > 0 ? rem : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether there are any elements between the current position and
|
||||
* the limit.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, there is at least one element
|
||||
* remaining in this buffer
|
||||
*/
|
||||
public final boolean hasRemaining() {
|
||||
return position < limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer is read-only.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this buffer is read-only
|
||||
*/
|
||||
public abstract boolean isReadOnly();
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer is backed by an accessible
|
||||
* array.
|
||||
*
|
||||
* <p> If this method returns <tt>true</tt> then the {@link #array() array}
|
||||
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
|
||||
* </p>
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this buffer
|
||||
* is backed by an array and is not read-only
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract boolean hasArray();
|
||||
|
||||
/**
|
||||
* Returns the array that backs this
|
||||
* buffer <i>(optional operation)</i>.
|
||||
*
|
||||
* <p> This method is intended to allow array-backed buffers to be
|
||||
* passed to native code more efficiently. Concrete subclasses
|
||||
* provide more strongly-typed return values for this method.
|
||||
*
|
||||
* <p> Modifications to this buffer's content will cause the returned
|
||||
* array's content to be modified, and vice versa.
|
||||
*
|
||||
* <p> Invoke the {@link #hasArray hasArray} method before invoking this
|
||||
* method in order to ensure that this buffer has an accessible backing
|
||||
* array. </p>
|
||||
*
|
||||
* @return The array that backs this buffer
|
||||
*
|
||||
* @throws ReadOnlyBufferException
|
||||
* If this buffer is backed by an array but is read-only
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* If this buffer is not backed by an accessible array
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract Object array();
|
||||
|
||||
/**
|
||||
* Returns the offset within this buffer's backing array of the first
|
||||
* element of the buffer <i>(optional operation)</i>.
|
||||
*
|
||||
* <p> If this buffer is backed by an array then buffer position <i>p</i>
|
||||
* corresponds to array index <i>p</i> + <tt>arrayOffset()</tt>.
|
||||
*
|
||||
* <p> Invoke the {@link #hasArray hasArray} method before invoking this
|
||||
* method in order to ensure that this buffer has an accessible backing
|
||||
* array. </p>
|
||||
*
|
||||
* @return The offset within this buffer's array
|
||||
* of the first element of the buffer
|
||||
*
|
||||
* @throws ReadOnlyBufferException
|
||||
* If this buffer is backed by an array but is read-only
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* If this buffer is not backed by an accessible array
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract int arrayOffset();
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer is
|
||||
* <a href="ByteBuffer.html#direct"><i>direct</i></a>.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this buffer is direct
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract boolean isDirect();
|
||||
|
||||
|
||||
// -- Package-private methods for bounds checking, etc. --
|
||||
|
||||
/**
|
||||
* Checks the current position against the limit, throwing a {@link
|
||||
* BufferUnderflowException} if it is not smaller than the limit, and then
|
||||
* increments the position.
|
||||
*
|
||||
* @return The current position value, before it is incremented
|
||||
*/
|
||||
final int nextGetIndex() { // package-private
|
||||
int p = position;
|
||||
if (p >= limit)
|
||||
throw new BufferUnderflowException();
|
||||
position = p + 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
final int nextGetIndex(int nb) { // package-private
|
||||
int p = position;
|
||||
if (limit - p < nb)
|
||||
throw new BufferUnderflowException();
|
||||
position = p + nb;
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the current position against the limit, throwing a {@link
|
||||
* BufferOverflowException} if it is not smaller than the limit, and then
|
||||
* increments the position.
|
||||
*
|
||||
* @return The current position value, before it is incremented
|
||||
*/
|
||||
final int nextPutIndex() { // package-private
|
||||
int p = position;
|
||||
if (p >= limit)
|
||||
throw new BufferOverflowException();
|
||||
position = p + 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
final int nextPutIndex(int nb) { // package-private
|
||||
int p = position;
|
||||
if (limit - p < nb)
|
||||
throw new BufferOverflowException();
|
||||
position = p + nb;
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the given index against the limit, throwing an {@link
|
||||
* IndexOutOfBoundsException} if it is not smaller than the limit
|
||||
* or is smaller than zero.
|
||||
*/
|
||||
final int checkIndex(int i) { // package-private
|
||||
if ((i < 0) || (i >= limit))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return i;
|
||||
}
|
||||
|
||||
final int checkIndex(int i, int nb) { // package-private
|
||||
if ((i < 0) || (nb > limit - i))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return i;
|
||||
}
|
||||
|
||||
final int markValue() { // package-private
|
||||
return mark;
|
||||
}
|
||||
|
||||
final void truncate() { // package-private
|
||||
mark = -1;
|
||||
position = 0;
|
||||
limit = 0;
|
||||
capacity = 0;
|
||||
}
|
||||
|
||||
final void discardMark() { // package-private
|
||||
mark = -1;
|
||||
}
|
||||
|
||||
static void checkBounds(int off, int len, int size) { // package-private
|
||||
if ((off | len | (off + len) | (size - (off + len))) < 0)
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/BufferOverflowException.java
Normal file
51
jdkSrc/jdk8/java/nio/BufferOverflowException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when a relative <i>put</i> operation reaches
|
||||
* the target buffer's limit.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class BufferOverflowException
|
||||
extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -5484897634319144535L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public BufferOverflowException() { }
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/BufferUnderflowException.java
Normal file
51
jdkSrc/jdk8/java/nio/BufferUnderflowException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when a relative <i>get</i> operation reaches
|
||||
* the source buffer's limit.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class BufferUnderflowException
|
||||
extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -1713313658691622206L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public BufferUnderflowException() { }
|
||||
|
||||
}
|
||||
2098
jdkSrc/jdk8/java/nio/ByteBuffer.java
Normal file
2098
jdkSrc/jdk8/java/nio/ByteBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsCharBufferB // package-private
|
||||
extends CharBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsCharBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 1,
|
||||
bb.remaining() >> 1);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsCharBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsCharBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new ByteBufferAsCharBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsCharBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 1) + offset;
|
||||
}
|
||||
|
||||
public char get() {
|
||||
return Bits.getCharB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public char get(int i) {
|
||||
return Bits.getCharB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
char getUnchecked(int i) {
|
||||
return Bits.getCharB(bb, ix(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
Bits.putCharB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
Bits.putCharB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 1);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new ByteBufferAsCharBufferB(bb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsCharBufferL // package-private
|
||||
extends CharBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsCharBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 1,
|
||||
bb.remaining() >> 1);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsCharBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsCharBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new ByteBufferAsCharBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsCharBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 1) + offset;
|
||||
}
|
||||
|
||||
public char get() {
|
||||
return Bits.getCharL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public char get(int i) {
|
||||
return Bits.getCharL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
char getUnchecked(int i) {
|
||||
return Bits.getCharL(bb, ix(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
Bits.putCharL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
Bits.putCharL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 1);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new ByteBufferAsCharBufferL(bb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsCharBufferRB // package-private
|
||||
extends ByteBufferAsCharBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsCharBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsCharBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsCharBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new ByteBufferAsCharBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new ByteBufferAsCharBufferRB(bb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsCharBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsCharBufferRL // package-private
|
||||
extends ByteBufferAsCharBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsCharBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsCharBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsCharBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new ByteBufferAsCharBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new ByteBufferAsCharBufferRL(bb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsDoubleBufferB // package-private
|
||||
extends DoubleBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsDoubleBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 3,
|
||||
bb.remaining() >> 3);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsDoubleBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsDoubleBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new ByteBufferAsDoubleBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsDoubleBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 3) + offset;
|
||||
}
|
||||
|
||||
public double get() {
|
||||
return Bits.getDoubleB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return Bits.getDoubleB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
Bits.putDoubleB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
Bits.putDoubleB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 3);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsDoubleBufferL // package-private
|
||||
extends DoubleBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsDoubleBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 3,
|
||||
bb.remaining() >> 3);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsDoubleBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsDoubleBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new ByteBufferAsDoubleBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsDoubleBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 3) + offset;
|
||||
}
|
||||
|
||||
public double get() {
|
||||
return Bits.getDoubleL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return Bits.getDoubleL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
Bits.putDoubleL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
Bits.putDoubleL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 3);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsDoubleBufferRB // package-private
|
||||
extends ByteBufferAsDoubleBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsDoubleBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsDoubleBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsDoubleBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new ByteBufferAsDoubleBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsDoubleBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsDoubleBufferRL // package-private
|
||||
extends ByteBufferAsDoubleBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsDoubleBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsDoubleBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsDoubleBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new ByteBufferAsDoubleBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsFloatBufferB // package-private
|
||||
extends FloatBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsFloatBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 2,
|
||||
bb.remaining() >> 2);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsFloatBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsFloatBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new ByteBufferAsFloatBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsFloatBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 2) + offset;
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return Bits.getFloatB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return Bits.getFloatB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
Bits.putFloatB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
Bits.putFloatB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 2);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsFloatBufferL // package-private
|
||||
extends FloatBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsFloatBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 2,
|
||||
bb.remaining() >> 2);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsFloatBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsFloatBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new ByteBufferAsFloatBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsFloatBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 2) + offset;
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return Bits.getFloatL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return Bits.getFloatL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
Bits.putFloatL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
Bits.putFloatL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 2);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsFloatBufferRB // package-private
|
||||
extends ByteBufferAsFloatBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsFloatBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsFloatBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsFloatBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new ByteBufferAsFloatBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsFloatBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsFloatBufferRL // package-private
|
||||
extends ByteBufferAsFloatBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsFloatBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsFloatBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsFloatBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new ByteBufferAsFloatBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsIntBufferB // package-private
|
||||
extends IntBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsIntBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 2,
|
||||
bb.remaining() >> 2);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsIntBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsIntBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new ByteBufferAsIntBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsIntBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 2) + offset;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return Bits.getIntB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return Bits.getIntB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
Bits.putIntB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
Bits.putIntB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 2);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsIntBufferL // package-private
|
||||
extends IntBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsIntBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 2,
|
||||
bb.remaining() >> 2);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsIntBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsIntBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new ByteBufferAsIntBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsIntBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 2) + offset;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return Bits.getIntL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return Bits.getIntL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
Bits.putIntL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
Bits.putIntL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 2);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsIntBufferRB // package-private
|
||||
extends ByteBufferAsIntBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsIntBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsIntBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsIntBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new ByteBufferAsIntBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsIntBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsIntBufferRL // package-private
|
||||
extends ByteBufferAsIntBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsIntBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsIntBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsIntBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new ByteBufferAsIntBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsLongBufferB // package-private
|
||||
extends LongBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsLongBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 3,
|
||||
bb.remaining() >> 3);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsLongBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsLongBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new ByteBufferAsLongBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsLongBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 3) + offset;
|
||||
}
|
||||
|
||||
public long get() {
|
||||
return Bits.getLongB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return Bits.getLongB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
Bits.putLongB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
Bits.putLongB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 3);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsLongBufferL // package-private
|
||||
extends LongBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsLongBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 3,
|
||||
bb.remaining() >> 3);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsLongBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsLongBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new ByteBufferAsLongBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsLongBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 3) + offset;
|
||||
}
|
||||
|
||||
public long get() {
|
||||
return Bits.getLongL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return Bits.getLongL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
Bits.putLongL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
Bits.putLongL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 3);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsLongBufferRB // package-private
|
||||
extends ByteBufferAsLongBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsLongBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsLongBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsLongBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new ByteBufferAsLongBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsLongBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsLongBufferRL // package-private
|
||||
extends ByteBufferAsLongBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsLongBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsLongBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsLongBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new ByteBufferAsLongBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsShortBufferB // package-private
|
||||
extends ShortBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsShortBufferB(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 1,
|
||||
bb.remaining() >> 1);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsShortBufferB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsShortBufferB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new ByteBufferAsShortBufferB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsShortBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 1) + offset;
|
||||
}
|
||||
|
||||
public short get() {
|
||||
return Bits.getShortB(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return Bits.getShortB(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
Bits.putShortB(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
Bits.putShortB(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 1);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsShortBufferL // package-private
|
||||
extends ShortBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected final ByteBuffer bb;
|
||||
protected final int offset;
|
||||
|
||||
|
||||
|
||||
ByteBufferAsShortBufferL(ByteBuffer bb) { // package-private
|
||||
|
||||
super(-1, 0,
|
||||
bb.remaining() >> 1,
|
||||
bb.remaining() >> 1);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
this.limit(cap);
|
||||
int pos = this.position();
|
||||
assert (pos <= cap);
|
||||
offset = pos;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsShortBufferL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
this.bb = bb;
|
||||
offset = off;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsShortBufferL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new ByteBufferAsShortBufferL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new ByteBufferAsShortBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return (i << 1) + offset;
|
||||
}
|
||||
|
||||
public short get() {
|
||||
return Bits.getShortL(bb, ix(nextGetIndex()));
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return Bits.getShortL(bb, ix(checkIndex(i)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
Bits.putShortL(bb, ix(nextPutIndex()), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
Bits.putShortL(bb, ix(checkIndex(i)), x);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
ByteBuffer db = bb.duplicate();
|
||||
db.limit(ix(lim));
|
||||
db.position(ix(0));
|
||||
ByteBuffer sb = db.slice();
|
||||
sb.position(pos << 1);
|
||||
sb.compact();
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferRB.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferRB.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsShortBufferRB // package-private
|
||||
extends ByteBufferAsShortBufferB
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsShortBufferRB(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsShortBufferRB(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsShortBufferRB(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new ByteBufferAsShortBufferRB(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ByteOrder.BIG_ENDIAN;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferRL.java
Normal file
224
jdkSrc/jdk8/java/nio/ByteBufferAsShortBufferRL.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
class ByteBufferAsShortBufferRL // package-private
|
||||
extends ByteBufferAsShortBufferL
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ByteBufferAsShortBufferRL(ByteBuffer bb) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb);
|
||||
|
||||
}
|
||||
|
||||
ByteBufferAsShortBufferRL(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(bb, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1) + offset;
|
||||
assert (off >= 0);
|
||||
return new ByteBufferAsShortBufferRL(bb, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new ByteBufferAsShortBufferRL(bb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return bb.isDirect();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
return ByteOrder.LITTLE_ENDIAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
88
jdkSrc/jdk8/java/nio/ByteOrder.java
Normal file
88
jdkSrc/jdk8/java/nio/ByteOrder.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
* A typesafe enumeration for byte orders.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public final class ByteOrder {
|
||||
|
||||
private String name;
|
||||
|
||||
private ByteOrder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant denoting big-endian byte order. In this order, the bytes of a
|
||||
* multibyte value are ordered from most significant to least significant.
|
||||
*/
|
||||
public static final ByteOrder BIG_ENDIAN
|
||||
= new ByteOrder("BIG_ENDIAN");
|
||||
|
||||
/**
|
||||
* Constant denoting little-endian byte order. In this order, the bytes of
|
||||
* a multibyte value are ordered from least significant to most
|
||||
* significant.
|
||||
*/
|
||||
public static final ByteOrder LITTLE_ENDIAN
|
||||
= new ByteOrder("LITTLE_ENDIAN");
|
||||
|
||||
/**
|
||||
* Retrieves the native byte order of the underlying platform.
|
||||
*
|
||||
* <p> This method is defined so that performance-sensitive Java code can
|
||||
* allocate direct buffers with the same byte order as the hardware.
|
||||
* Native code libraries are often more efficient when such buffers are
|
||||
* used. </p>
|
||||
*
|
||||
* @return The native byte order of the hardware upon which this Java
|
||||
* virtual machine is running
|
||||
*/
|
||||
public static ByteOrder nativeOrder() {
|
||||
return Bits.byteOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a string describing this object.
|
||||
*
|
||||
* <p> This method returns the string <tt>"BIG_ENDIAN"</tt> for {@link
|
||||
* #BIG_ENDIAN} and <tt>"LITTLE_ENDIAN"</tt> for {@link #LITTLE_ENDIAN}.
|
||||
* </p>
|
||||
*
|
||||
* @return The specified string
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
1523
jdkSrc/jdk8/java/nio/CharBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/CharBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
96
jdkSrc/jdk8/java/nio/CharBufferSpliterator.java
Normal file
96
jdkSrc/jdk8/java/nio/CharBufferSpliterator.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
/**
|
||||
* A Spliterator.OfInt for sources that traverse and split elements
|
||||
* maintained in a CharBuffer.
|
||||
*
|
||||
* @implNote
|
||||
* The implementation is based on the code for the Array-based spliterators.
|
||||
*/
|
||||
class CharBufferSpliterator implements Spliterator.OfInt {
|
||||
private final CharBuffer buffer;
|
||||
private int index; // current index, modified on advance/split
|
||||
private final int limit;
|
||||
|
||||
CharBufferSpliterator(CharBuffer buffer) {
|
||||
this(buffer, buffer.position(), buffer.limit());
|
||||
}
|
||||
|
||||
CharBufferSpliterator(CharBuffer buffer, int origin, int limit) {
|
||||
assert origin <= limit;
|
||||
this.buffer = buffer;
|
||||
this.index = (origin <= limit) ? origin : limit;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfInt trySplit() {
|
||||
int lo = index, mid = (lo + limit) >>> 1;
|
||||
return (lo >= mid)
|
||||
? null
|
||||
: new CharBufferSpliterator(buffer, lo, index = mid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(IntConsumer action) {
|
||||
if (action == null)
|
||||
throw new NullPointerException();
|
||||
CharBuffer cb = buffer;
|
||||
int i = index;
|
||||
int hi = limit;
|
||||
index = hi;
|
||||
while (i < hi) {
|
||||
action.accept(cb.getUnchecked(i++));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAdvance(IntConsumer action) {
|
||||
if (action == null)
|
||||
throw new NullPointerException();
|
||||
if (index >= 0 && index < limit) {
|
||||
action.accept(buffer.getUnchecked(index++));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
return (long)(limit - index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
return Buffer.SPLITERATOR_CHARACTERISTICS;
|
||||
}
|
||||
}
|
||||
1032
jdkSrc/jdk8/java/nio/DirectByteBuffer.java
Normal file
1032
jdkSrc/jdk8/java/nio/DirectByteBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
1032
jdkSrc/jdk8/java/nio/DirectByteBufferR.java
Normal file
1032
jdkSrc/jdk8/java/nio/DirectByteBufferR.java
Normal file
File diff suppressed because it is too large
Load Diff
493
jdkSrc/jdk8/java/nio/DirectCharBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectCharBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectCharBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectCharBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectCharBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectCharBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new DirectCharBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new DirectCharBufferRS(this,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectCharBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectCharBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectCharBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectCharBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectCharBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectCharBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new DirectCharBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new DirectCharBufferRU(this,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectCharBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectCharBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectCharBufferS
|
||||
|
||||
extends CharBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(char[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectCharBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectCharBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new DirectCharBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectCharBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 1);
|
||||
}
|
||||
|
||||
public char get() {
|
||||
return (Bits.swap(unsafe.getChar(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public char get(int i) {
|
||||
return (Bits.swap(unsafe.getChar(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
char getUnchecked(int i) {
|
||||
return (Bits.swap(unsafe.getChar(ix(i))));
|
||||
}
|
||||
|
||||
|
||||
public CharBuffer get(char[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToCharArray(ix(pos), dst,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
unsafe.putChar(ix(nextPutIndex()), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
unsafe.putChar(ix(checkIndex(i)), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
if (src instanceof DirectCharBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectCharBufferS sb = (DirectCharBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 1);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromCharArray(src,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 1);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new DirectCharBufferS(this,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectCharBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectCharBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectCharBufferU
|
||||
|
||||
extends CharBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(char[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectCharBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectCharBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new DirectCharBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectCharBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 1);
|
||||
}
|
||||
|
||||
public char get() {
|
||||
return ((unsafe.getChar(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public char get(int i) {
|
||||
return ((unsafe.getChar(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
char getUnchecked(int i) {
|
||||
return ((unsafe.getChar(ix(i))));
|
||||
}
|
||||
|
||||
|
||||
public CharBuffer get(char[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToCharArray(ix(pos), dst,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
unsafe.putChar(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
unsafe.putChar(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
if (src instanceof DirectCharBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectCharBufferU sb = (DirectCharBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 1);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromCharArray(src,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 1);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String toString(int start, int end) {
|
||||
if ((end > limit()) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
try {
|
||||
int len = end - start;
|
||||
char[] ca = new char[len];
|
||||
CharBuffer cb = CharBuffer.wrap(ca);
|
||||
CharBuffer db = this.duplicate();
|
||||
db.position(start);
|
||||
db.limit(end);
|
||||
cb.put(db);
|
||||
return new String(ca);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
pos = (pos <= lim ? pos : lim);
|
||||
int len = lim - pos;
|
||||
|
||||
if ((start < 0) || (end > len) || (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
return new DirectCharBufferU(this,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectDoubleBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectDoubleBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectDoubleBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectDoubleBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new DirectDoubleBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectDoubleBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectDoubleBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectDoubleBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectDoubleBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new DirectDoubleBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectDoubleBufferS
|
||||
|
||||
extends DoubleBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(double[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectDoubleBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectDoubleBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new DirectDoubleBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectDoubleBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 3);
|
||||
}
|
||||
|
||||
public double get() {
|
||||
return Double.longBitsToDouble(Bits.swap(unsafe.getLong(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return Double.longBitsToDouble(Bits.swap(unsafe.getLong(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer get(double[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToLongArray(ix(pos), dst,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
unsafe.putLong(ix(nextPutIndex()), Bits.swap(Double.doubleToRawLongBits(x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
unsafe.putLong(ix(checkIndex(i)), Bits.swap(Double.doubleToRawLongBits(x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
if (src instanceof DirectDoubleBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectDoubleBufferS sb = (DirectDoubleBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 3);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromLongArray(src,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 3);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectDoubleBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectDoubleBufferU
|
||||
|
||||
extends DoubleBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(double[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectDoubleBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectDoubleBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new DirectDoubleBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectDoubleBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 3);
|
||||
}
|
||||
|
||||
public double get() {
|
||||
return ((unsafe.getDouble(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return ((unsafe.getDouble(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer get(double[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToLongArray(ix(pos), dst,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
unsafe.putDouble(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
unsafe.putDouble(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
if (src instanceof DirectDoubleBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectDoubleBufferU sb = (DirectDoubleBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 3);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromLongArray(src,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 3);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectFloatBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectFloatBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectFloatBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectFloatBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectFloatBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectFloatBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new DirectFloatBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectFloatBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectFloatBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectFloatBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectFloatBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectFloatBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectFloatBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new DirectFloatBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectFloatBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectFloatBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectFloatBufferS
|
||||
|
||||
extends FloatBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(float[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectFloatBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectFloatBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new DirectFloatBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectFloatBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 2);
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return Float.intBitsToFloat(Bits.swap(unsafe.getInt(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return Float.intBitsToFloat(Bits.swap(unsafe.getInt(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer get(float[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToIntArray(ix(pos), dst,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
unsafe.putInt(ix(nextPutIndex()), Bits.swap(Float.floatToRawIntBits(x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
unsafe.putInt(ix(checkIndex(i)), Bits.swap(Float.floatToRawIntBits(x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
if (src instanceof DirectFloatBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectFloatBufferS sb = (DirectFloatBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 2);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromIntArray(src,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 2);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectFloatBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectFloatBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectFloatBufferU
|
||||
|
||||
extends FloatBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(float[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectFloatBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectFloatBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new DirectFloatBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectFloatBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 2);
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return ((unsafe.getFloat(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return ((unsafe.getFloat(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer get(float[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToIntArray(ix(pos), dst,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
unsafe.putFloat(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
unsafe.putFloat(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
if (src instanceof DirectFloatBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectFloatBufferU sb = (DirectFloatBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 2);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromIntArray(src,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 2);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectIntBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectIntBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectIntBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectIntBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectIntBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectIntBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new DirectIntBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectIntBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectIntBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectIntBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectIntBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectIntBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectIntBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new DirectIntBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectIntBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectIntBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectIntBufferS
|
||||
|
||||
extends IntBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(int[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectIntBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectIntBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new DirectIntBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectIntBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 2);
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return (Bits.swap(unsafe.getInt(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return (Bits.swap(unsafe.getInt(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer get(int[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToIntArray(ix(pos), dst,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
unsafe.putInt(ix(nextPutIndex()), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
unsafe.putInt(ix(checkIndex(i)), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
if (src instanceof DirectIntBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectIntBufferS sb = (DirectIntBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 2);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromIntArray(src,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 2);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectIntBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectIntBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectIntBufferU
|
||||
|
||||
extends IntBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(int[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectIntBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 2);
|
||||
assert (off >= 0);
|
||||
return new DirectIntBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new DirectIntBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectIntBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 2);
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return ((unsafe.getInt(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return ((unsafe.getInt(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer get(int[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToIntArray(ix(pos), dst,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
unsafe.putInt(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
unsafe.putInt(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
if (src instanceof DirectIntBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectIntBufferU sb = (DirectIntBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 2);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromIntArray(src,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 2,
|
||||
ix(pos),
|
||||
(long)length << 2);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 2);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectLongBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectLongBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectLongBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectLongBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectLongBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectLongBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new DirectLongBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectLongBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectLongBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectLongBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectLongBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectLongBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectLongBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new DirectLongBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectLongBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectLongBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectLongBufferS
|
||||
|
||||
extends LongBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(long[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectLongBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectLongBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new DirectLongBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectLongBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 3);
|
||||
}
|
||||
|
||||
public long get() {
|
||||
return (Bits.swap(unsafe.getLong(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return (Bits.swap(unsafe.getLong(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer get(long[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToLongArray(ix(pos), dst,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
unsafe.putLong(ix(nextPutIndex()), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
unsafe.putLong(ix(checkIndex(i)), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
if (src instanceof DirectLongBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectLongBufferS sb = (DirectLongBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 3);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromLongArray(src,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 3);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectLongBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectLongBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectLongBufferU
|
||||
|
||||
extends LongBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(long[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectLongBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 3);
|
||||
assert (off >= 0);
|
||||
return new DirectLongBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new DirectLongBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectLongBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 3);
|
||||
}
|
||||
|
||||
public long get() {
|
||||
return ((unsafe.getLong(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return ((unsafe.getLong(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer get(long[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToLongArray(ix(pos), dst,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
unsafe.putLong(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
unsafe.putLong(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
if (src instanceof DirectLongBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectLongBufferU sb = (DirectLongBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 3);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromLongArray(src,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 3,
|
||||
ix(pos),
|
||||
(long)length << 3);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 3);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectShortBufferRS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectShortBufferRS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectShortBufferRS
|
||||
|
||||
|
||||
|
||||
extends DirectShortBufferS
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectShortBufferRS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectShortBufferRS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new DirectShortBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectShortBufferRU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectShortBufferRU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectShortBufferRU
|
||||
|
||||
|
||||
|
||||
extends DirectShortBufferU
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectShortBufferRU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(db, mark, pos, lim, cap, off);
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectShortBufferRU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new DirectShortBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectShortBufferS.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectShortBufferS.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectShortBufferS
|
||||
|
||||
extends ShortBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(short[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectShortBufferS(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectShortBufferS(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new DirectShortBufferS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectShortBufferRS(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 1);
|
||||
}
|
||||
|
||||
public short get() {
|
||||
return (Bits.swap(unsafe.getShort(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return (Bits.swap(unsafe.getShort(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer get(short[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToShortArray(ix(pos), dst,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
unsafe.putShort(ix(nextPutIndex()), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
unsafe.putShort(ix(checkIndex(i)), Bits.swap((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
if (src instanceof DirectShortBufferS) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectShortBufferS sb = (DirectShortBufferS)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 1);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromShortArray(src,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 1);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
493
jdkSrc/jdk8/java/nio/DirectShortBufferU.java
Normal file
493
jdkSrc/jdk8/java/nio/DirectShortBufferU.java
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
class DirectShortBufferU
|
||||
|
||||
extends ShortBuffer
|
||||
|
||||
|
||||
|
||||
implements DirectBuffer
|
||||
{
|
||||
|
||||
|
||||
|
||||
// Cached unsafe-access object
|
||||
protected static final Unsafe unsafe = Bits.unsafe();
|
||||
|
||||
// Cached array base offset
|
||||
private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset(short[].class);
|
||||
|
||||
// Cached unaligned-access capability
|
||||
protected static final boolean unaligned = Bits.unaligned();
|
||||
|
||||
// Base address, used in all indexing calculations
|
||||
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
|
||||
// protected long address;
|
||||
|
||||
// An object attached to this buffer. If this buffer is a view of another
|
||||
// buffer then we use this field to keep a reference to that buffer to
|
||||
// ensure that its memory isn't freed before we are done with it.
|
||||
private final Object att;
|
||||
|
||||
public Object attachment() {
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Cleaner cleaner() { return null; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// For duplicates and slices
|
||||
//
|
||||
DirectShortBufferU(DirectBuffer db, // package-private
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap);
|
||||
address = db.address() + off;
|
||||
|
||||
|
||||
|
||||
att = db;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
int off = (pos << 1);
|
||||
assert (off >= 0);
|
||||
return new DirectShortBufferU(this, -1, 0, rem, rem, off);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new DirectShortBufferU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new DirectShortBufferRU(this,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
private long ix(int i) {
|
||||
return address + ((long)i << 1);
|
||||
}
|
||||
|
||||
public short get() {
|
||||
return ((unsafe.getShort(ix(nextGetIndex()))));
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return ((unsafe.getShort(ix(checkIndex(i)))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer get(short[] dst, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferUnderflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyToShortArray(ix(pos), dst,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyToArray(ix(pos), dst, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.get(dst, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
unsafe.putShort(ix(nextPutIndex()), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
unsafe.putShort(ix(checkIndex(i)), ((x)));
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
if (src instanceof DirectShortBufferU) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
DirectShortBufferU sb = (DirectShortBufferU)src;
|
||||
|
||||
int spos = sb.position();
|
||||
int slim = sb.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (srem > rem)
|
||||
throw new BufferOverflowException();
|
||||
unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << 1);
|
||||
sb.position(spos + srem);
|
||||
position(pos + srem);
|
||||
} else if (src.hb != null) {
|
||||
|
||||
int spos = src.position();
|
||||
int slim = src.limit();
|
||||
assert (spos <= slim);
|
||||
int srem = (spos <= slim ? slim - spos : 0);
|
||||
|
||||
put(src.hb, src.offset + spos, srem);
|
||||
src.position(spos + srem);
|
||||
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
if (((long)length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
|
||||
if (order() != ByteOrder.nativeOrder())
|
||||
Bits.copyFromShortArray(src,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
else
|
||||
|
||||
Bits.copyFromArray(src, arrayBaseOffset,
|
||||
(long)offset << 1,
|
||||
ix(pos),
|
||||
(long)length << 1);
|
||||
position(pos + length);
|
||||
} else {
|
||||
super.put(src, offset, length);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
unsafe.copyMemory(ix(pos), ix(0), (long)rem << 1);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
|
||||
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1523
jdkSrc/jdk8/java/nio/DoubleBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/DoubleBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
1523
jdkSrc/jdk8/java/nio/FloatBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/FloatBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
619
jdkSrc/jdk8/java/nio/HeapByteBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapByteBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapByteBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapByteBuffer
|
||||
extends ByteBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final byte[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapByteBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new byte[cap], 0);
|
||||
/*
|
||||
hb = new byte[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapByteBuffer(byte[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapByteBuffer(byte[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapByteBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public ByteBuffer duplicate() {
|
||||
return new HeapByteBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ByteBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapByteBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public byte get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public byte get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer get(byte[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ByteBuffer put(byte x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(int i, byte x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(byte[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(ByteBuffer src) {
|
||||
|
||||
if (src instanceof HeapByteBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapByteBuffer sb = (HeapByteBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
byte _get(int i) { // package-private
|
||||
return hb[i];
|
||||
}
|
||||
|
||||
void _put(int i, byte b) { // package-private
|
||||
|
||||
hb[i] = b;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// char
|
||||
|
||||
|
||||
|
||||
public char getChar() {
|
||||
return Bits.getChar(this, ix(nextGetIndex(2)), bigEndian);
|
||||
}
|
||||
|
||||
public char getChar(int i) {
|
||||
return Bits.getChar(this, ix(checkIndex(i, 2)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putChar(char x) {
|
||||
|
||||
Bits.putChar(this, ix(nextPutIndex(2)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putChar(int i, char x) {
|
||||
|
||||
Bits.putChar(this, ix(checkIndex(i, 2)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer asCharBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 1;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (CharBuffer)(new ByteBufferAsCharBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (CharBuffer)(new ByteBufferAsCharBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// short
|
||||
|
||||
|
||||
|
||||
public short getShort() {
|
||||
return Bits.getShort(this, ix(nextGetIndex(2)), bigEndian);
|
||||
}
|
||||
|
||||
public short getShort(int i) {
|
||||
return Bits.getShort(this, ix(checkIndex(i, 2)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putShort(short x) {
|
||||
|
||||
Bits.putShort(this, ix(nextPutIndex(2)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putShort(int i, short x) {
|
||||
|
||||
Bits.putShort(this, ix(checkIndex(i, 2)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer asShortBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 1;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (ShortBuffer)(new ByteBufferAsShortBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (ShortBuffer)(new ByteBufferAsShortBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// int
|
||||
|
||||
|
||||
|
||||
public int getInt() {
|
||||
return Bits.getInt(this, ix(nextGetIndex(4)), bigEndian);
|
||||
}
|
||||
|
||||
public int getInt(int i) {
|
||||
return Bits.getInt(this, ix(checkIndex(i, 4)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putInt(int x) {
|
||||
|
||||
Bits.putInt(this, ix(nextPutIndex(4)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putInt(int i, int x) {
|
||||
|
||||
Bits.putInt(this, ix(checkIndex(i, 4)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer asIntBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 2;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (IntBuffer)(new ByteBufferAsIntBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (IntBuffer)(new ByteBufferAsIntBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// long
|
||||
|
||||
|
||||
|
||||
public long getLong() {
|
||||
return Bits.getLong(this, ix(nextGetIndex(8)), bigEndian);
|
||||
}
|
||||
|
||||
public long getLong(int i) {
|
||||
return Bits.getLong(this, ix(checkIndex(i, 8)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putLong(long x) {
|
||||
|
||||
Bits.putLong(this, ix(nextPutIndex(8)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putLong(int i, long x) {
|
||||
|
||||
Bits.putLong(this, ix(checkIndex(i, 8)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer asLongBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 3;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (LongBuffer)(new ByteBufferAsLongBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (LongBuffer)(new ByteBufferAsLongBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// float
|
||||
|
||||
|
||||
|
||||
public float getFloat() {
|
||||
return Bits.getFloat(this, ix(nextGetIndex(4)), bigEndian);
|
||||
}
|
||||
|
||||
public float getFloat(int i) {
|
||||
return Bits.getFloat(this, ix(checkIndex(i, 4)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putFloat(float x) {
|
||||
|
||||
Bits.putFloat(this, ix(nextPutIndex(4)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putFloat(int i, float x) {
|
||||
|
||||
Bits.putFloat(this, ix(checkIndex(i, 4)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer asFloatBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 2;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (FloatBuffer)(new ByteBufferAsFloatBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (FloatBuffer)(new ByteBufferAsFloatBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// double
|
||||
|
||||
|
||||
|
||||
public double getDouble() {
|
||||
return Bits.getDouble(this, ix(nextGetIndex(8)), bigEndian);
|
||||
}
|
||||
|
||||
public double getDouble(int i) {
|
||||
return Bits.getDouble(this, ix(checkIndex(i, 8)), bigEndian);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putDouble(double x) {
|
||||
|
||||
Bits.putDouble(this, ix(nextPutIndex(8)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putDouble(int i, double x) {
|
||||
|
||||
Bits.putDouble(this, ix(checkIndex(i, 8)), x, bigEndian);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer asDoubleBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 3;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (DoubleBuffer)(new ByteBufferAsDoubleBufferB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (DoubleBuffer)(new ByteBufferAsDoubleBufferL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapByteBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapByteBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapByteBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapByteBufferR
|
||||
extends HeapByteBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapByteBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapByteBufferR(byte[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapByteBufferR(byte[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapByteBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public ByteBuffer duplicate() {
|
||||
return new HeapByteBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ByteBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ByteBuffer put(byte x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(int i, byte x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(byte[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer put(ByteBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
byte _get(int i) { // package-private
|
||||
return hb[i];
|
||||
}
|
||||
|
||||
void _put(int i, byte b) { // package-private
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
// char
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putChar(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putChar(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer asCharBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 1;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (CharBuffer)(new ByteBufferAsCharBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (CharBuffer)(new ByteBufferAsCharBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// short
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putShort(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putShort(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer asShortBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 1;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (ShortBuffer)(new ByteBufferAsShortBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (ShortBuffer)(new ByteBufferAsShortBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// int
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putInt(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putInt(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer asIntBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 2;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (IntBuffer)(new ByteBufferAsIntBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (IntBuffer)(new ByteBufferAsIntBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// long
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putLong(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putLong(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer asLongBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 3;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (LongBuffer)(new ByteBufferAsLongBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (LongBuffer)(new ByteBufferAsLongBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// float
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putFloat(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putFloat(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer asFloatBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 2;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (FloatBuffer)(new ByteBufferAsFloatBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (FloatBuffer)(new ByteBufferAsFloatBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
// double
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteBuffer putDouble(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ByteBuffer putDouble(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer asDoubleBuffer() {
|
||||
int pos = position();
|
||||
int size = (limit() - pos) >> 3;
|
||||
int off = offset + pos;
|
||||
return (bigEndian
|
||||
? (DoubleBuffer)(new ByteBufferAsDoubleBufferRB(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off))
|
||||
: (DoubleBuffer)(new ByteBufferAsDoubleBufferRL(this,
|
||||
-1,
|
||||
0,
|
||||
size,
|
||||
size,
|
||||
off)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapCharBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapCharBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapCharBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapCharBuffer
|
||||
extends CharBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final char[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapCharBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new char[cap], 0);
|
||||
/*
|
||||
hb = new char[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapCharBuffer(char[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapCharBuffer(char[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapCharBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new HeapCharBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapCharBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public char get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public char get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
char getUnchecked(int i) {
|
||||
return hb[ix(i)];
|
||||
}
|
||||
|
||||
|
||||
public CharBuffer get(char[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
if (src instanceof HeapCharBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapCharBuffer sb = (HeapCharBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String toString(int start, int end) { // package-private
|
||||
try {
|
||||
return new String(hb, start + offset, end - start);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
if ((start < 0)
|
||||
|| (end > length())
|
||||
|| (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
int pos = position();
|
||||
return new HeapCharBuffer(hb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapCharBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapCharBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapCharBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapCharBufferR
|
||||
extends HeapCharBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapCharBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapCharBufferR(char[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapCharBufferR(char[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapCharBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new HeapCharBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public CharBuffer put(char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(int i, char x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(char[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer put(CharBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public CharBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String toString(int start, int end) { // package-private
|
||||
try {
|
||||
return new String(hb, start + offset, end - start);
|
||||
} catch (StringIndexOutOfBoundsException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Methods to support CharSequence ---
|
||||
|
||||
public CharBuffer subSequence(int start, int end) {
|
||||
if ((start < 0)
|
||||
|| (end > length())
|
||||
|| (start > end))
|
||||
throw new IndexOutOfBoundsException();
|
||||
int pos = position();
|
||||
return new HeapCharBufferR(hb,
|
||||
-1,
|
||||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapDoubleBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapDoubleBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapDoubleBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapDoubleBuffer
|
||||
extends DoubleBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final double[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapDoubleBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new double[cap], 0);
|
||||
/*
|
||||
hb = new double[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapDoubleBuffer(double[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapDoubleBuffer(double[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapDoubleBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new HeapDoubleBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapDoubleBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public double get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public DoubleBuffer get(double[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
if (src instanceof HeapDoubleBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapDoubleBuffer sb = (HeapDoubleBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapDoubleBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapDoubleBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapDoubleBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapDoubleBufferR
|
||||
extends HeapDoubleBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapDoubleBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapDoubleBufferR(double[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapDoubleBufferR(double[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapDoubleBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer duplicate() {
|
||||
return new HeapDoubleBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public DoubleBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(int i, double x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(double[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer put(DoubleBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public DoubleBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapFloatBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapFloatBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapFloatBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapFloatBuffer
|
||||
extends FloatBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final float[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapFloatBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new float[cap], 0);
|
||||
/*
|
||||
hb = new float[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapFloatBuffer(float[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapFloatBuffer(float[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapFloatBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new HeapFloatBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapFloatBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public FloatBuffer get(float[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
if (src instanceof HeapFloatBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapFloatBuffer sb = (HeapFloatBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapFloatBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapFloatBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapFloatBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapFloatBufferR
|
||||
extends HeapFloatBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapFloatBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapFloatBufferR(float[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapFloatBufferR(float[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapFloatBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public FloatBuffer duplicate() {
|
||||
return new HeapFloatBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public FloatBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public FloatBuffer put(float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(int i, float x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(float[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer put(FloatBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public FloatBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapIntBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapIntBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapIntBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapIntBuffer
|
||||
extends IntBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final int[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapIntBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new int[cap], 0);
|
||||
/*
|
||||
hb = new int[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapIntBuffer(int[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapIntBuffer(int[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapIntBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new HeapIntBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapIntBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public IntBuffer get(int[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
if (src instanceof HeapIntBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapIntBuffer sb = (HeapIntBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapIntBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapIntBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapIntBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapIntBufferR
|
||||
extends HeapIntBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapIntBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapIntBufferR(int[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapIntBufferR(int[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapIntBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public IntBuffer duplicate() {
|
||||
return new HeapIntBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public IntBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public IntBuffer put(int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int i, int x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(int[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer put(IntBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public IntBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapLongBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapLongBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapLongBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapLongBuffer
|
||||
extends LongBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final long[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapLongBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new long[cap], 0);
|
||||
/*
|
||||
hb = new long[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapLongBuffer(long[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapLongBuffer(long[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapLongBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new HeapLongBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapLongBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public long get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public LongBuffer get(long[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
if (src instanceof HeapLongBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapLongBuffer sb = (HeapLongBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapLongBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapLongBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapLongBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapLongBufferR
|
||||
extends HeapLongBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapLongBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapLongBufferR(long[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapLongBufferR(long[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapLongBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public LongBuffer duplicate() {
|
||||
return new HeapLongBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public LongBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public LongBuffer put(long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(int i, long x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(long[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer put(LongBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public LongBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapShortBuffer.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapShortBuffer.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* A read/write HeapShortBuffer.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class HeapShortBuffer
|
||||
extends ShortBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
protected final short[] hb;
|
||||
protected final int offset;
|
||||
|
||||
*/
|
||||
|
||||
HeapShortBuffer(int cap, int lim) { // package-private
|
||||
|
||||
super(-1, 0, lim, cap, new short[cap], 0);
|
||||
/*
|
||||
hb = new short[cap];
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
HeapShortBuffer(short[] buf, int off, int len) { // package-private
|
||||
|
||||
super(-1, off, off + len, buf.length, buf, 0);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = 0;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected HeapShortBuffer(short[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
super(mark, pos, lim, cap, buf, off);
|
||||
/*
|
||||
hb = buf;
|
||||
offset = off;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapShortBuffer(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new HeapShortBuffer(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
return new HeapShortBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected int ix(int i) {
|
||||
return i + offset;
|
||||
}
|
||||
|
||||
public short get() {
|
||||
return hb[ix(nextGetIndex())];
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return hb[ix(checkIndex(i))];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ShortBuffer get(short[] dst, int offset, int length) {
|
||||
checkBounds(offset, length, dst.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferUnderflowException();
|
||||
System.arraycopy(hb, ix(pos), dst, offset, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
hb[ix(nextPutIndex())] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
hb[ix(checkIndex(i))] = x;
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
checkBounds(offset, length, src.length);
|
||||
int pos = position();
|
||||
if (length > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(src, offset, hb, ix(pos), length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
if (src instanceof HeapShortBuffer) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
HeapShortBuffer sb = (HeapShortBuffer)src;
|
||||
int pos = position();
|
||||
int sbpos = sb.position();
|
||||
int n = sb.limit() - sbpos;
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
System.arraycopy(sb.hb, sb.ix(sbpos),
|
||||
hb, ix(pos), n);
|
||||
sb.position(sbpos + n);
|
||||
position(pos + n);
|
||||
} else if (src.isDirect()) {
|
||||
int n = src.remaining();
|
||||
int pos = position();
|
||||
if (n > limit() - pos)
|
||||
throw new BufferOverflowException();
|
||||
src.get(hb, ix(pos), n);
|
||||
position(pos + n);
|
||||
} else {
|
||||
super.put(src);
|
||||
}
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
|
||||
position(rem);
|
||||
limit(capacity());
|
||||
discardMark();
|
||||
return this;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
619
jdkSrc/jdk8/java/nio/HeapShortBufferR.java
Normal file
619
jdkSrc/jdk8/java/nio/HeapShortBufferR.java
Normal file
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
|
||||
* A read-only HeapShortBuffer. This class extends the corresponding
|
||||
* read/write class, overriding the mutation methods to throw a {@link
|
||||
* ReadOnlyBufferException} and overriding the view-buffer methods to return an
|
||||
* instance of this class rather than of the superclass.
|
||||
|
||||
*/
|
||||
|
||||
class HeapShortBufferR
|
||||
extends HeapShortBuffer
|
||||
{
|
||||
|
||||
// For speed these fields are actually declared in X-Buffer;
|
||||
// these declarations are here as documentation
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
HeapShortBufferR(int cap, int lim) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(cap, lim);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
HeapShortBufferR(short[] buf, int off, int len) { // package-private
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, off, len);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
protected HeapShortBufferR(short[] buf,
|
||||
int mark, int pos, int lim, int cap,
|
||||
int off)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super(buf, mark, pos, lim, cap, off);
|
||||
this.isReadOnly = true;
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new HeapShortBufferR(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
}
|
||||
|
||||
public ShortBuffer duplicate() {
|
||||
return new HeapShortBufferR(hb,
|
||||
this.markValue(),
|
||||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
offset);
|
||||
}
|
||||
|
||||
public ShortBuffer asReadOnlyBuffer() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return duplicate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShortBuffer put(short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(int i, short x) {
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(short[] src, int offset, int length) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer put(ShortBuffer src) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
public ShortBuffer compact() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new ReadOnlyBufferException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
1523
jdkSrc/jdk8/java/nio/IntBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/IntBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
51
jdkSrc/jdk8/java/nio/InvalidMarkException.java
Normal file
51
jdkSrc/jdk8/java/nio/InvalidMarkException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to reset a buffer
|
||||
* when its mark is not defined.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class InvalidMarkException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1698329710438510774L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public InvalidMarkException() { }
|
||||
|
||||
}
|
||||
1523
jdkSrc/jdk8/java/nio/LongBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/LongBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
211
jdkSrc/jdk8/java/nio/MappedByteBuffer.java
Normal file
211
jdkSrc/jdk8/java/nio/MappedByteBuffer.java
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
|
||||
/**
|
||||
* A direct byte buffer whose content is a memory-mapped region of a file.
|
||||
*
|
||||
* <p> Mapped byte buffers are created via the {@link
|
||||
* java.nio.channels.FileChannel#map FileChannel.map} method. This class
|
||||
* extends the {@link ByteBuffer} class with operations that are specific to
|
||||
* memory-mapped file regions.
|
||||
*
|
||||
* <p> A mapped byte buffer and the file mapping that it represents remain
|
||||
* valid until the buffer itself is garbage-collected.
|
||||
*
|
||||
* <p> The content of a mapped byte buffer can change at any time, for example
|
||||
* if the content of the corresponding region of the mapped file is changed by
|
||||
* this program or another. Whether or not such changes occur, and when they
|
||||
* occur, is operating-system dependent and therefore unspecified.
|
||||
*
|
||||
* <a name="inaccess"></a><p> All or part of a mapped byte buffer may become
|
||||
* inaccessible at any time, for example if the mapped file is truncated. An
|
||||
* attempt to access an inaccessible region of a mapped byte buffer will not
|
||||
* change the buffer's content and will cause an unspecified exception to be
|
||||
* thrown either at the time of the access or at some later time. It is
|
||||
* therefore strongly recommended that appropriate precautions be taken to
|
||||
* avoid the manipulation of a mapped file by this program, or by a
|
||||
* concurrently running program, except to read or write the file's content.
|
||||
*
|
||||
* <p> Mapped byte buffers otherwise behave no differently than ordinary direct
|
||||
* byte buffers. </p>
|
||||
*
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public abstract class MappedByteBuffer
|
||||
extends ByteBuffer
|
||||
{
|
||||
|
||||
// This is a little bit backwards: By rights MappedByteBuffer should be a
|
||||
// subclass of DirectByteBuffer, but to keep the spec clear and simple, and
|
||||
// for optimization purposes, it's easier to do it the other way around.
|
||||
// This works because DirectByteBuffer is a package-private class.
|
||||
|
||||
// For mapped buffers, a FileDescriptor that may be used for mapping
|
||||
// operations if valid; null if the buffer is not mapped.
|
||||
private final FileDescriptor fd;
|
||||
|
||||
// This should only be invoked by the DirectByteBuffer constructors
|
||||
//
|
||||
MappedByteBuffer(int mark, int pos, int lim, int cap, // package-private
|
||||
FileDescriptor fd)
|
||||
{
|
||||
super(mark, pos, lim, cap);
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
MappedByteBuffer(int mark, int pos, int lim, int cap) { // package-private
|
||||
super(mark, pos, lim, cap);
|
||||
this.fd = null;
|
||||
}
|
||||
|
||||
private void checkMapped() {
|
||||
if (fd == null)
|
||||
// Can only happen if a luser explicitly casts a direct byte buffer
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// Returns the distance (in bytes) of the buffer from the page aligned address
|
||||
// of the mapping. Computed each time to avoid storing in every direct buffer.
|
||||
private long mappingOffset() {
|
||||
int ps = Bits.pageSize();
|
||||
long offset = address % ps;
|
||||
return (offset >= 0) ? offset : (ps + offset);
|
||||
}
|
||||
|
||||
private long mappingAddress(long mappingOffset) {
|
||||
return address - mappingOffset;
|
||||
}
|
||||
|
||||
private long mappingLength(long mappingOffset) {
|
||||
return (long)capacity() + mappingOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not this buffer's content is resident in physical
|
||||
* memory.
|
||||
*
|
||||
* <p> A return value of <tt>true</tt> implies that it is highly likely
|
||||
* that all of the data in this buffer is resident in physical memory and
|
||||
* may therefore be accessed without incurring any virtual-memory page
|
||||
* faults or I/O operations. A return value of <tt>false</tt> does not
|
||||
* necessarily imply that the buffer's content is not resident in physical
|
||||
* memory.
|
||||
*
|
||||
* <p> The returned value is a hint, rather than a guarantee, because the
|
||||
* underlying operating system may have paged out some of the buffer's data
|
||||
* by the time that an invocation of this method returns. </p>
|
||||
*
|
||||
* @return <tt>true</tt> if it is likely that this buffer's content
|
||||
* is resident in physical memory
|
||||
*/
|
||||
public final boolean isLoaded() {
|
||||
checkMapped();
|
||||
if ((address == 0) || (capacity() == 0))
|
||||
return true;
|
||||
long offset = mappingOffset();
|
||||
long length = mappingLength(offset);
|
||||
return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
|
||||
}
|
||||
|
||||
// not used, but a potential target for a store, see load() for details.
|
||||
private static byte unused;
|
||||
|
||||
/**
|
||||
* Loads this buffer's content into physical memory.
|
||||
*
|
||||
* <p> This method makes a best effort to ensure that, when it returns,
|
||||
* this buffer's content is resident in physical memory. Invoking this
|
||||
* method may cause some number of page faults and I/O operations to
|
||||
* occur. </p>
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final MappedByteBuffer load() {
|
||||
checkMapped();
|
||||
if ((address == 0) || (capacity() == 0))
|
||||
return this;
|
||||
long offset = mappingOffset();
|
||||
long length = mappingLength(offset);
|
||||
load0(mappingAddress(offset), length);
|
||||
|
||||
// Read a byte from each page to bring it into memory. A checksum
|
||||
// is computed as we go along to prevent the compiler from otherwise
|
||||
// considering the loop as dead code.
|
||||
Unsafe unsafe = Unsafe.getUnsafe();
|
||||
int ps = Bits.pageSize();
|
||||
int count = Bits.pageCount(length);
|
||||
long a = mappingAddress(offset);
|
||||
byte x = 0;
|
||||
for (int i=0; i<count; i++) {
|
||||
x ^= unsafe.getByte(a);
|
||||
a += ps;
|
||||
}
|
||||
if (unused != 0)
|
||||
unused = x;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces any changes made to this buffer's content to be written to the
|
||||
* storage device containing the mapped file.
|
||||
*
|
||||
* <p> If the file mapped into this buffer resides on a local storage
|
||||
* device then when this method returns it is guaranteed that all changes
|
||||
* made to the buffer since it was created, or since this method was last
|
||||
* invoked, will have been written to that device.
|
||||
*
|
||||
* <p> If the file does not reside on a local device then no such guarantee
|
||||
* is made.
|
||||
*
|
||||
* <p> If this buffer was not mapped in read/write mode ({@link
|
||||
* java.nio.channels.FileChannel.MapMode#READ_WRITE}) then invoking this
|
||||
* method has no effect. </p>
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final MappedByteBuffer force() {
|
||||
checkMapped();
|
||||
if ((address != 0) && (capacity() != 0)) {
|
||||
long offset = mappingOffset();
|
||||
force0(fd, mappingAddress(offset), mappingLength(offset));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private native boolean isLoaded0(long address, long length, int pageCount);
|
||||
private native void load0(long address, long length);
|
||||
private native void force0(FileDescriptor fd, long address, long length);
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/ReadOnlyBufferException.java
Normal file
51
jdkSrc/jdk8/java/nio/ReadOnlyBufferException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when a content-mutation method such as
|
||||
* <tt>put</tt> or <tt>compact</tt> is invoked upon a read-only buffer.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class ReadOnlyBufferException
|
||||
extends UnsupportedOperationException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -1210063976496234090L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public ReadOnlyBufferException() { }
|
||||
|
||||
}
|
||||
1523
jdkSrc/jdk8/java/nio/ShortBuffer.java
Normal file
1523
jdkSrc/jdk8/java/nio/ShortBuffer.java
Normal file
File diff suppressed because it is too large
Load Diff
131
jdkSrc/jdk8/java/nio/StringCharBuffer.java
Normal file
131
jdkSrc/jdk8/java/nio/StringCharBuffer.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio;
|
||||
|
||||
|
||||
// ## If the sequence is a string, use reflection to share its array
|
||||
|
||||
class StringCharBuffer // package-private
|
||||
extends CharBuffer
|
||||
{
|
||||
CharSequence str;
|
||||
|
||||
StringCharBuffer(CharSequence s, int start, int end) { // package-private
|
||||
super(-1, start, end, s.length());
|
||||
int n = s.length();
|
||||
if ((start < 0) || (start > n) || (end < start) || (end > n))
|
||||
throw new IndexOutOfBoundsException();
|
||||
str = s;
|
||||
}
|
||||
|
||||
public CharBuffer slice() {
|
||||
int pos = this.position();
|
||||
int lim = this.limit();
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
return new StringCharBuffer(str,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
offset + pos);
|
||||
}
|
||||
|
||||
private StringCharBuffer(CharSequence s,
|
||||
int mark,
|
||||
int pos,
|
||||
int limit,
|
||||
int cap,
|
||||
int offset) {
|
||||
super(mark, pos, limit, cap, null, offset);
|
||||
str = s;
|
||||
}
|
||||
|
||||
public CharBuffer duplicate() {
|
||||
return new StringCharBuffer(str, markValue(),
|
||||
position(), limit(), capacity(), offset);
|
||||
}
|
||||
|
||||
public CharBuffer asReadOnlyBuffer() {
|
||||
return duplicate();
|
||||
}
|
||||
|
||||
public final char get() {
|
||||
return str.charAt(nextGetIndex() + offset);
|
||||
}
|
||||
|
||||
public final char get(int index) {
|
||||
return str.charAt(checkIndex(index) + offset);
|
||||
}
|
||||
|
||||
char getUnchecked(int index) {
|
||||
return str.charAt(index + offset);
|
||||
}
|
||||
|
||||
// ## Override bulk get methods for better performance
|
||||
|
||||
public final CharBuffer put(char c) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
public final CharBuffer put(int index, char c) {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
public final CharBuffer compact() {
|
||||
throw new ReadOnlyBufferException();
|
||||
}
|
||||
|
||||
public final boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String toString(int start, int end) {
|
||||
return str.toString().substring(start + offset, end + offset);
|
||||
}
|
||||
|
||||
public final CharBuffer subSequence(int start, int end) {
|
||||
try {
|
||||
int pos = position();
|
||||
return new StringCharBuffer(str,
|
||||
-1,
|
||||
pos + checkIndex(start, pos),
|
||||
pos + checkIndex(end, pos),
|
||||
capacity(),
|
||||
offset);
|
||||
} catch (IllegalArgumentException x) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDirect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ByteOrder order() {
|
||||
return ByteOrder.nativeOrder();
|
||||
}
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/channels/AcceptPendingException.java
Normal file
51
jdkSrc/jdk8/java/nio/channels/AcceptPendingException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to initiate an accept
|
||||
* operation on a channel and a previous accept operation has not completed.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class AcceptPendingException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 2721339977965416421L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public AcceptPendingException() { }
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/channels/AlreadyBoundException.java
Normal file
51
jdkSrc/jdk8/java/nio/channels/AlreadyBoundException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to bind the socket a
|
||||
* network oriented channel that is already bound.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class AlreadyBoundException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 6796072983322737592L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public AlreadyBoundException() { }
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/channels/AlreadyConnectedException.java
Normal file
51
jdkSrc/jdk8/java/nio/channels/AlreadyConnectedException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to connect a {@link
|
||||
* SocketChannel} that is already connected.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class AlreadyConnectedException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -7331895245053773357L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public AlreadyConnectedException() { }
|
||||
|
||||
}
|
||||
213
jdkSrc/jdk8/java/nio/channels/AsynchronousByteChannel.java
Normal file
213
jdkSrc/jdk8/java/nio/channels/AsynchronousByteChannel.java
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* An asynchronous channel that can read and write bytes.
|
||||
*
|
||||
* <p> Some channels may not allow more than one read or write to be outstanding
|
||||
* at any given time. If a thread invokes a read method before a previous read
|
||||
* operation has completed then a {@link ReadPendingException} will be thrown.
|
||||
* Similarly, if a write method is invoked before a previous write has completed
|
||||
* then {@link WritePendingException} is thrown. Whether or not other kinds of
|
||||
* I/O operations may proceed concurrently with a read operation depends upon
|
||||
* the type of the channel.
|
||||
*
|
||||
* <p> Note that {@link java.nio.ByteBuffer ByteBuffers} are not safe for use by
|
||||
* multiple concurrent threads. When a read or write operation is initiated then
|
||||
* care must be taken to ensure that the buffer is not accessed until the
|
||||
* operation completes.
|
||||
*
|
||||
* @see Channels#newInputStream(AsynchronousByteChannel)
|
||||
* @see Channels#newOutputStream(AsynchronousByteChannel)
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public interface AsynchronousByteChannel
|
||||
extends AsynchronousChannel
|
||||
{
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous read operation to read a
|
||||
* sequence of bytes from this channel into the given buffer. The {@code
|
||||
* handler} parameter is a completion handler that is invoked when the read
|
||||
* operation completes (or fails). The result passed to the completion
|
||||
* handler is the number of bytes read or {@code -1} if no bytes could be
|
||||
* read because the channel has reached end-of-stream.
|
||||
*
|
||||
* <p> The read operation may read up to <i>r</i> bytes from the channel,
|
||||
* where <i>r</i> is the number of bytes remaining in the buffer, that is,
|
||||
* {@code dst.remaining()} at the time that the read is attempted. Where
|
||||
* <i>r</i> is 0, the read operation completes immediately with a result of
|
||||
* {@code 0} without initiating an I/O operation.
|
||||
*
|
||||
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
|
||||
* <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
|
||||
* This byte sequence will be transferred into the buffer so that the first
|
||||
* byte in the sequence is at index <i>p</i> and the last byte is at index
|
||||
* <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>,
|
||||
* where <i>p</i> is the buffer's position at the moment the read is
|
||||
* performed. Upon completion the buffer's position will be equal to
|
||||
* <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
|
||||
*
|
||||
* <p> Buffers are not safe for use by multiple concurrent threads so care
|
||||
* should be taken to not access the buffer until the operation has
|
||||
* completed.
|
||||
*
|
||||
* <p> This method may be invoked at any time. Some channel types may not
|
||||
* allow more than one read to be outstanding at any given time. If a thread
|
||||
* initiates a read operation before a previous read operation has
|
||||
* completed then a {@link ReadPendingException} will be thrown.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param dst
|
||||
* The buffer into which bytes are to be transferred
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The completion handler
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the buffer is read-only
|
||||
* @throws ReadPendingException
|
||||
* If the channel does not allow more than one read to be outstanding
|
||||
* and a previous read has not completed
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel is associated with a {@link AsynchronousChannelGroup
|
||||
* group} that has terminated
|
||||
*/
|
||||
<A> void read(ByteBuffer dst,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous read operation to read a
|
||||
* sequence of bytes from this channel into the given buffer. The method
|
||||
* behaves in exactly the same manner as the {@link
|
||||
* #read(ByteBuffer,Object,CompletionHandler)
|
||||
* read(ByteBuffer,Object,CompletionHandler)} method except that instead
|
||||
* of specifying a completion handler, this method returns a {@code Future}
|
||||
* representing the pending result. The {@code Future}'s {@link Future#get()
|
||||
* get} method returns the number of bytes read or {@code -1} if no bytes
|
||||
* could be read because the channel has reached end-of-stream.
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which bytes are to be transferred
|
||||
*
|
||||
* @return A Future representing the result of the operation
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the buffer is read-only
|
||||
* @throws ReadPendingException
|
||||
* If the channel does not allow more than one read to be outstanding
|
||||
* and a previous read has not completed
|
||||
*/
|
||||
Future<Integer> read(ByteBuffer dst);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous write operation to write a
|
||||
* sequence of bytes to this channel from the given buffer. The {@code
|
||||
* handler} parameter is a completion handler that is invoked when the write
|
||||
* operation completes (or fails). The result passed to the completion
|
||||
* handler is the number of bytes written.
|
||||
*
|
||||
* <p> The write operation may write up to <i>r</i> bytes to the channel,
|
||||
* where <i>r</i> is the number of bytes remaining in the buffer, that is,
|
||||
* {@code src.remaining()} at the time that the write is attempted. Where
|
||||
* <i>r</i> is 0, the write operation completes immediately with a result of
|
||||
* {@code 0} without initiating an I/O operation.
|
||||
*
|
||||
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
|
||||
* <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
|
||||
* This byte sequence will be transferred from the buffer starting at index
|
||||
* <i>p</i>, where <i>p</i> is the buffer's position at the moment the
|
||||
* write is performed; the index of the last byte written will be
|
||||
* <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>.
|
||||
* Upon completion the buffer's position will be equal to
|
||||
* <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
|
||||
*
|
||||
* <p> Buffers are not safe for use by multiple concurrent threads so care
|
||||
* should be taken to not access the buffer until the operation has
|
||||
* completed.
|
||||
*
|
||||
* <p> This method may be invoked at any time. Some channel types may not
|
||||
* allow more than one write to be outstanding at any given time. If a thread
|
||||
* initiates a write operation before a previous write operation has
|
||||
* completed then a {@link WritePendingException} will be thrown.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param src
|
||||
* The buffer from which bytes are to be retrieved
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The completion handler object
|
||||
*
|
||||
* @throws WritePendingException
|
||||
* If the channel does not allow more than one write to be outstanding
|
||||
* and a previous write has not completed
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel is associated with a {@link AsynchronousChannelGroup
|
||||
* group} that has terminated
|
||||
*/
|
||||
<A> void write(ByteBuffer src,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous write operation to write a
|
||||
* sequence of bytes to this channel from the given buffer. The method
|
||||
* behaves in exactly the same manner as the {@link
|
||||
* #write(ByteBuffer,Object,CompletionHandler)
|
||||
* write(ByteBuffer,Object,CompletionHandler)} method except that instead
|
||||
* of specifying a completion handler, this method returns a {@code Future}
|
||||
* representing the pending result. The {@code Future}'s {@link Future#get()
|
||||
* get} method returns the number of bytes written.
|
||||
*
|
||||
* @param src
|
||||
* The buffer from which bytes are to be retrieved
|
||||
*
|
||||
* @return A Future representing the result of the operation
|
||||
*
|
||||
* @throws WritePendingException
|
||||
* If the channel does not allow more than one write to be outstanding
|
||||
* and a previous write has not completed
|
||||
*/
|
||||
Future<Integer> write(ByteBuffer src);
|
||||
}
|
||||
117
jdkSrc/jdk8/java/nio/channels/AsynchronousChannel.java
Normal file
117
jdkSrc/jdk8/java/nio/channels/AsynchronousChannel.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Future; // javadoc
|
||||
|
||||
/**
|
||||
* A channel that supports asynchronous I/O operations. Asynchronous I/O
|
||||
* operations will usually take one of two forms:
|
||||
*
|
||||
* <ol>
|
||||
* <li><pre>{@link Future}<V> <em>operation</em>(<em>...</em>)</pre></li>
|
||||
* <li><pre>void <em>operation</em>(<em>...</em> A attachment, {@link
|
||||
* CompletionHandler}<V,? super A> handler)</pre></li>
|
||||
* </ol>
|
||||
*
|
||||
* where <i>operation</i> is the name of the I/O operation (read or write for
|
||||
* example), <i>V</i> is the result type of the I/O operation, and <i>A</i> is
|
||||
* the type of an object attached to the I/O operation to provide context when
|
||||
* consuming the result. The attachment is important for cases where a
|
||||
* <em>state-less</em> {@code CompletionHandler} is used to consume the result
|
||||
* of many I/O operations.
|
||||
*
|
||||
* <p> In the first form, the methods defined by the {@link Future Future}
|
||||
* interface may be used to check if the operation has completed, wait for its
|
||||
* completion, and to retrieve the result. In the second form, a {@link
|
||||
* CompletionHandler} is invoked to consume the result of the I/O operation when
|
||||
* it completes or fails.
|
||||
*
|
||||
* <p> A channel that implements this interface is <em>asynchronously
|
||||
* closeable</em>: If an I/O operation is outstanding on the channel and the
|
||||
* channel's {@link #close close} method is invoked, then the I/O operation
|
||||
* fails with the exception {@link AsynchronousCloseException}.
|
||||
*
|
||||
* <p> Asynchronous channels are safe for use by multiple concurrent threads.
|
||||
* Some channel implementations may support concurrent reading and writing, but
|
||||
* may not allow more than one read and one write operation to be outstanding at
|
||||
* any given time.
|
||||
*
|
||||
* <h2>Cancellation</h2>
|
||||
*
|
||||
* <p> The {@code Future} interface defines the {@link Future#cancel cancel}
|
||||
* method to cancel execution. This causes all threads waiting on the result of
|
||||
* the I/O operation to throw {@link java.util.concurrent.CancellationException}.
|
||||
* Whether the underlying I/O operation can be cancelled is highly implementation
|
||||
* specific and therefore not specified. Where cancellation leaves the channel,
|
||||
* or the entity to which it is connected, in an inconsistent state, then the
|
||||
* channel is put into an implementation specific <em>error state</em> that
|
||||
* prevents further attempts to initiate I/O operations that are <i>similar</i>
|
||||
* to the operation that was cancelled. For example, if a read operation is
|
||||
* cancelled but the implementation cannot guarantee that bytes have not been
|
||||
* read from the channel then it puts the channel into an error state; further
|
||||
* attempts to initiate a {@code read} operation cause an unspecified runtime
|
||||
* exception to be thrown. Similarly, if a write operation is cancelled but the
|
||||
* implementation cannot guarantee that bytes have not been written to the
|
||||
* channel then subsequent attempts to initiate a {@code write} will fail with
|
||||
* an unspecified runtime exception.
|
||||
*
|
||||
* <p> Where the {@link Future#cancel cancel} method is invoked with the {@code
|
||||
* mayInterruptIfRunning} parameter set to {@code true} then the I/O operation
|
||||
* may be interrupted by closing the channel. In that case all threads waiting
|
||||
* on the result of the I/O operation throw {@code CancellationException} and
|
||||
* any other I/O operations outstanding on the channel complete with the
|
||||
* exception {@link AsynchronousCloseException}.
|
||||
*
|
||||
* <p> Where the {@code cancel} method is invoked to cancel read or write
|
||||
* operations then it is recommended that all buffers used in the I/O operations
|
||||
* be discarded or care taken to ensure that the buffers are not accessed while
|
||||
* the channel remains open.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public interface AsynchronousChannel
|
||||
extends Channel
|
||||
{
|
||||
/**
|
||||
* Closes this channel.
|
||||
*
|
||||
* <p> Any outstanding asynchronous operations upon this channel will
|
||||
* complete with the exception {@link AsynchronousCloseException}. After a
|
||||
* channel is closed, further attempts to initiate asynchronous I/O
|
||||
* operations complete immediately with cause {@link ClosedChannelException}.
|
||||
*
|
||||
* <p> This method otherwise behaves exactly as specified by the {@link
|
||||
* Channel} interface.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
void close() throws IOException;
|
||||
}
|
||||
343
jdkSrc/jdk8/java/nio/channels/AsynchronousChannelGroup.java
Normal file
343
jdkSrc/jdk8/java/nio/channels/AsynchronousChannelGroup.java
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.nio.channels.spi.AsynchronousChannelProvider;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A grouping of asynchronous channels for the purpose of resource sharing.
|
||||
*
|
||||
* <p> An asynchronous channel group encapsulates the mechanics required to
|
||||
* handle the completion of I/O operations initiated by {@link AsynchronousChannel
|
||||
* asynchronous channels} that are bound to the group. A group has an associated
|
||||
* thread pool to which tasks are submitted to handle I/O events and dispatch to
|
||||
* {@link CompletionHandler completion-handlers} that consume the result of
|
||||
* asynchronous operations performed on channels in the group. In addition to
|
||||
* handling I/O events, the pooled threads may also execute other tasks required
|
||||
* to support the execution of asynchronous I/O operations.
|
||||
*
|
||||
* <p> An asynchronous channel group is created by invoking the {@link
|
||||
* #withFixedThreadPool withFixedThreadPool} or {@link #withCachedThreadPool
|
||||
* withCachedThreadPool} methods defined here. Channels are bound to a group by
|
||||
* specifying the group when constructing the channel. The associated thread
|
||||
* pool is <em>owned</em> by the group; termination of the group results in the
|
||||
* shutdown of the associated thread pool.
|
||||
*
|
||||
* <p> In addition to groups created explicitly, the Java virtual machine
|
||||
* maintains a system-wide <em>default group</em> that is constructed
|
||||
* automatically. Asynchronous channels that do not specify a group at
|
||||
* construction time are bound to the default group. The default group has an
|
||||
* associated thread pool that creates new threads as needed. The default group
|
||||
* may be configured by means of system properties defined in the table below.
|
||||
* Where the {@link java.util.concurrent.ThreadFactory ThreadFactory} for the
|
||||
* default group is not configured then the pooled threads of the default group
|
||||
* are {@link Thread#isDaemon daemon} threads.
|
||||
*
|
||||
* <table border summary="System properties">
|
||||
* <tr>
|
||||
* <th>System property</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code java.nio.channels.DefaultThreadPool.threadFactory} </td>
|
||||
* <td> The value of this property is taken to be the fully-qualified name
|
||||
* of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
|
||||
* class. The class is loaded using the system class loader and instantiated.
|
||||
* The factory's {@link java.util.concurrent.ThreadFactory#newThread
|
||||
* newThread} method is invoked to create each thread for the default
|
||||
* group's thread pool. If the process to load and instantiate the value
|
||||
* of the property fails then an unspecified error is thrown during the
|
||||
* construction of the default group. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code java.nio.channels.DefaultThreadPool.initialSize} </td>
|
||||
* <td> The value of the {@code initialSize} parameter for the default
|
||||
* group (see {@link #withCachedThreadPool withCachedThreadPool}).
|
||||
* The value of the property is taken to be the {@code String}
|
||||
* representation of an {@code Integer} that is the initial size parameter.
|
||||
* If the value cannot be parsed as an {@code Integer} it causes an
|
||||
* unspecified error to be thrown during the construction of the default
|
||||
* group. </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <a name="threading"></a><h2>Threading</h2>
|
||||
*
|
||||
* <p> The completion handler for an I/O operation initiated on a channel bound
|
||||
* to a group is guaranteed to be invoked by one of the pooled threads in the
|
||||
* group. This ensures that the completion handler is run by a thread with the
|
||||
* expected <em>identity</em>.
|
||||
*
|
||||
* <p> Where an I/O operation completes immediately, and the initiating thread
|
||||
* is one of the pooled threads in the group then the completion handler may
|
||||
* be invoked directly by the initiating thread. To avoid stack overflow, an
|
||||
* implementation may impose a limit as to the number of activations on the
|
||||
* thread stack. Some I/O operations may prohibit invoking the completion
|
||||
* handler directly by the initiating thread (see {@link
|
||||
* AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}).
|
||||
*
|
||||
* <a name="shutdown"></a><h2>Shutdown and Termination</h2>
|
||||
*
|
||||
* <p> The {@link #shutdown() shutdown} method is used to initiate an <em>orderly
|
||||
* shutdown</em> of a group. An orderly shutdown marks the group as shutdown;
|
||||
* further attempts to construct a channel that binds to the group will throw
|
||||
* {@link ShutdownChannelGroupException}. Whether or not a group is shutdown can
|
||||
* be tested using the {@link #isShutdown() isShutdown} method. Once shutdown,
|
||||
* the group <em>terminates</em> when all asynchronous channels that are bound to
|
||||
* the group are closed, all actively executing completion handlers have run to
|
||||
* completion, and resources used by the group are released. No attempt is made
|
||||
* to stop or interrupt threads that are executing completion handlers. The
|
||||
* {@link #isTerminated() isTerminated} method is used to test if the group has
|
||||
* terminated, and the {@link #awaitTermination awaitTermination} method can be
|
||||
* used to block until the group has terminated.
|
||||
*
|
||||
* <p> The {@link #shutdownNow() shutdownNow} method can be used to initiate a
|
||||
* <em>forceful shutdown</em> of the group. In addition to the actions performed
|
||||
* by an orderly shutdown, the {@code shutdownNow} method closes all open channels
|
||||
* in the group as if by invoking the {@link AsynchronousChannel#close close}
|
||||
* method.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @see AsynchronousSocketChannel#open(AsynchronousChannelGroup)
|
||||
* @see AsynchronousServerSocketChannel#open(AsynchronousChannelGroup)
|
||||
*/
|
||||
|
||||
public abstract class AsynchronousChannelGroup {
|
||||
private final AsynchronousChannelProvider provider;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of this class.
|
||||
*
|
||||
* @param provider
|
||||
* The asynchronous channel provider for this group
|
||||
*/
|
||||
protected AsynchronousChannelGroup(AsynchronousChannelProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider that created this channel group.
|
||||
*
|
||||
* @return The provider that created this channel group
|
||||
*/
|
||||
public final AsynchronousChannelProvider provider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an asynchronous channel group with a fixed thread pool.
|
||||
*
|
||||
* <p> The resulting asynchronous channel group reuses a fixed number of
|
||||
* threads. At any point, at most {@code nThreads} threads will be active
|
||||
* processing tasks that are submitted to handle I/O events and dispatch
|
||||
* completion results for operations initiated on asynchronous channels in
|
||||
* the group.
|
||||
*
|
||||
* <p> The group is created by invoking the {@link
|
||||
* AsynchronousChannelProvider#openAsynchronousChannelGroup(int,ThreadFactory)
|
||||
* openAsynchronousChannelGroup(int,ThreadFactory)} method of the system-wide
|
||||
* default {@link AsynchronousChannelProvider} object.
|
||||
*
|
||||
* @param nThreads
|
||||
* The number of threads in the pool
|
||||
* @param threadFactory
|
||||
* The factory to use when creating new threads
|
||||
*
|
||||
* @return A new asynchronous channel group
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If {@code nThreads <= 0}
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousChannelGroup withFixedThreadPool(int nThreads,
|
||||
ThreadFactory threadFactory)
|
||||
throws IOException
|
||||
{
|
||||
return AsynchronousChannelProvider.provider()
|
||||
.openAsynchronousChannelGroup(nThreads, threadFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an asynchronous channel group with a given thread pool that
|
||||
* creates new threads as needed.
|
||||
*
|
||||
* <p> The {@code executor} parameter is an {@code ExecutorService} that
|
||||
* creates new threads as needed to execute tasks that are submitted to
|
||||
* handle I/O events and dispatch completion results for operations initiated
|
||||
* on asynchronous channels in the group. It may reuse previously constructed
|
||||
* threads when they are available.
|
||||
*
|
||||
* <p> The {@code initialSize} parameter may be used by the implementation
|
||||
* as a <em>hint</em> as to the initial number of tasks it may submit. For
|
||||
* example, it may be used to indicate the initial number of threads that
|
||||
* wait on I/O events.
|
||||
*
|
||||
* <p> The executor is intended to be used exclusively by the resulting
|
||||
* asynchronous channel group. Termination of the group results in the
|
||||
* orderly {@link ExecutorService#shutdown shutdown} of the executor
|
||||
* service. Shutting down the executor service by other means results in
|
||||
* unspecified behavior.
|
||||
*
|
||||
* <p> The group is created by invoking the {@link
|
||||
* AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
|
||||
* openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
|
||||
* default {@link AsynchronousChannelProvider} object.
|
||||
*
|
||||
* @param executor
|
||||
* The thread pool for the resulting group
|
||||
* @param initialSize
|
||||
* A value {@code >=0} or a negative value for implementation
|
||||
* specific default
|
||||
*
|
||||
* @return A new asynchronous channel group
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*
|
||||
* @see java.util.concurrent.Executors#newCachedThreadPool
|
||||
*/
|
||||
public static AsynchronousChannelGroup withCachedThreadPool(ExecutorService executor,
|
||||
int initialSize)
|
||||
throws IOException
|
||||
{
|
||||
return AsynchronousChannelProvider.provider()
|
||||
.openAsynchronousChannelGroup(executor, initialSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an asynchronous channel group with a given thread pool.
|
||||
*
|
||||
* <p> The {@code executor} parameter is an {@code ExecutorService} that
|
||||
* executes tasks submitted to dispatch completion results for operations
|
||||
* initiated on asynchronous channels in the group.
|
||||
*
|
||||
* <p> Care should be taken when configuring the executor service. It
|
||||
* should support <em>direct handoff</em> or <em>unbounded queuing</em> of
|
||||
* submitted tasks, and the thread that invokes the {@link
|
||||
* ExecutorService#execute execute} method should never invoke the task
|
||||
* directly. An implementation may mandate additional constraints.
|
||||
*
|
||||
* <p> The executor is intended to be used exclusively by the resulting
|
||||
* asynchronous channel group. Termination of the group results in the
|
||||
* orderly {@link ExecutorService#shutdown shutdown} of the executor
|
||||
* service. Shutting down the executor service by other means results in
|
||||
* unspecified behavior.
|
||||
*
|
||||
* <p> The group is created by invoking the {@link
|
||||
* AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
|
||||
* openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
|
||||
* default {@link AsynchronousChannelProvider} object with an {@code
|
||||
* initialSize} of {@code 0}.
|
||||
*
|
||||
* @param executor
|
||||
* The thread pool for the resulting group
|
||||
*
|
||||
* @return A new asynchronous channel group
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousChannelGroup withThreadPool(ExecutorService executor)
|
||||
throws IOException
|
||||
{
|
||||
return AsynchronousChannelProvider.provider()
|
||||
.openAsynchronousChannelGroup(executor, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not this asynchronous channel group is shutdown.
|
||||
*
|
||||
* @return {@code true} if this asynchronous channel group is shutdown or
|
||||
* has been marked for shutdown.
|
||||
*/
|
||||
public abstract boolean isShutdown();
|
||||
|
||||
/**
|
||||
* Tells whether or not this group has terminated.
|
||||
*
|
||||
* <p> Where this method returns {@code true}, then the associated thread
|
||||
* pool has also {@link ExecutorService#isTerminated terminated}.
|
||||
*
|
||||
* @return {@code true} if this group has terminated
|
||||
*/
|
||||
public abstract boolean isTerminated();
|
||||
|
||||
/**
|
||||
* Initiates an orderly shutdown of the group.
|
||||
*
|
||||
* <p> This method marks the group as shutdown. Further attempts to construct
|
||||
* channel that binds to this group will throw {@link ShutdownChannelGroupException}.
|
||||
* The group terminates when all asynchronous channels in the group are
|
||||
* closed, all actively executing completion handlers have run to completion,
|
||||
* and all resources have been released. This method has no effect if the
|
||||
* group is already shutdown.
|
||||
*/
|
||||
public abstract void shutdown();
|
||||
|
||||
/**
|
||||
* Shuts down the group and closes all open channels in the group.
|
||||
*
|
||||
* <p> In addition to the actions performed by the {@link #shutdown() shutdown}
|
||||
* method, this method invokes the {@link AsynchronousChannel#close close}
|
||||
* method on all open channels in the group. This method does not attempt to
|
||||
* stop or interrupt threads that are executing completion handlers. The
|
||||
* group terminates when all actively executing completion handlers have run
|
||||
* to completion and all resources have been released. This method may be
|
||||
* invoked at any time. If some other thread has already invoked it, then
|
||||
* another invocation will block until the first invocation is complete,
|
||||
* after which it will return without effect.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract void shutdownNow() throws IOException;
|
||||
|
||||
/**
|
||||
* Awaits termination of the group.
|
||||
|
||||
* <p> This method blocks until the group has terminated, or the timeout
|
||||
* occurs, or the current thread is interrupted, whichever happens first.
|
||||
*
|
||||
* @param timeout
|
||||
* The maximum time to wait, or zero or less to not wait
|
||||
* @param unit
|
||||
* The time unit of the timeout argument
|
||||
*
|
||||
* @return {@code true} if the group has terminated; {@code false} if the
|
||||
* timeout elapsed before termination
|
||||
*
|
||||
* @throws InterruptedException
|
||||
* If interrupted while waiting
|
||||
*/
|
||||
public abstract boolean awaitTermination(long timeout, TimeUnit unit)
|
||||
throws InterruptedException;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Checked exception received by a thread when another thread closes the
|
||||
* channel or the part of the channel upon which it is blocked in an I/O
|
||||
* operation.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class AsynchronousCloseException
|
||||
extends ClosedChannelException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 6891178312432313966L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public AsynchronousCloseException() { }
|
||||
|
||||
}
|
||||
779
jdkSrc/jdk8/java/nio/channels/AsynchronousFileChannel.java
Normal file
779
jdkSrc/jdk8/java/nio/channels/AsynchronousFileChannel.java
Normal file
@@ -0,0 +1,779 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.nio.file.spi.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* An asynchronous channel for reading, writing, and manipulating a file.
|
||||
*
|
||||
* <p> An asynchronous file channel is created when a file is opened by invoking
|
||||
* one of the {@link #open open} methods defined by this class. The file contains
|
||||
* a variable-length sequence of bytes that can be read and written and whose
|
||||
* current size can be {@link #size() queried}. The size of the file increases
|
||||
* when bytes are written beyond its current size; the size of the file decreases
|
||||
* when it is {@link #truncate truncated}.
|
||||
*
|
||||
* <p> An asynchronous file channel does not have a <i>current position</i>
|
||||
* within the file. Instead, the file position is specified to each read and
|
||||
* write method that initiates asynchronous operations. A {@link CompletionHandler}
|
||||
* is specified as a parameter and is invoked to consume the result of the I/O
|
||||
* operation. This class also defines read and write methods that initiate
|
||||
* asynchronous operations, returning a {@link Future} to represent the pending
|
||||
* result of the operation. The {@code Future} may be used to check if the
|
||||
* operation has completed, wait for its completion, and retrieve the result.
|
||||
*
|
||||
* <p> In addition to read and write operations, this class defines the
|
||||
* following operations: </p>
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><p> Updates made to a file may be {@link #force <i>forced
|
||||
* out</i>} to the underlying storage device, ensuring that data are not
|
||||
* lost in the event of a system crash. </p></li>
|
||||
*
|
||||
* <li><p> A region of a file may be {@link #lock <i>locked</i>} against
|
||||
* access by other programs. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* <p> An {@code AsynchronousFileChannel} is associated with a thread pool to
|
||||
* which tasks are submitted to handle I/O events and dispatch to completion
|
||||
* handlers that consume the results of I/O operations on the channel. The
|
||||
* completion handler for an I/O operation initiated on a channel is guaranteed
|
||||
* to be invoked by one of the threads in the thread pool (This ensures that the
|
||||
* completion handler is run by a thread with the expected <em>identity</em>).
|
||||
* Where an I/O operation completes immediately, and the initiating thread is
|
||||
* itself a thread in the thread pool, then the completion handler may be invoked
|
||||
* directly by the initiating thread. When an {@code AsynchronousFileChannel} is
|
||||
* created without specifying a thread pool then the channel is associated with
|
||||
* a system-dependent default thread pool that may be shared with other
|
||||
* channels. The default thread pool is configured by the system properties
|
||||
* defined by the {@link AsynchronousChannelGroup} class.
|
||||
*
|
||||
* <p> Channels of this type are safe for use by multiple concurrent threads. The
|
||||
* {@link Channel#close close} method may be invoked at any time, as specified
|
||||
* by the {@link Channel} interface. This causes all outstanding asynchronous
|
||||
* operations on the channel to complete with the exception {@link
|
||||
* AsynchronousCloseException}. Multiple read and write operations may be
|
||||
* outstanding at the same time. When multiple read and write operations are
|
||||
* outstanding then the ordering of the I/O operations, and the order that the
|
||||
* completion handlers are invoked, is not specified; they are not, in particular,
|
||||
* guaranteed to execute in the order that the operations were initiated. The
|
||||
* {@link java.nio.ByteBuffer ByteBuffers} used when reading or writing are not
|
||||
* safe for use by multiple concurrent I/O operations. Furthermore, after an I/O
|
||||
* operation is initiated then care should be taken to ensure that the buffer is
|
||||
* not accessed until after the operation has completed.
|
||||
*
|
||||
* <p> As with {@link FileChannel}, the view of a file provided by an instance of
|
||||
* this class is guaranteed to be consistent with other views of the same file
|
||||
* provided by other instances in the same program. The view provided by an
|
||||
* instance of this class may or may not, however, be consistent with the views
|
||||
* seen by other concurrently-running programs due to caching performed by the
|
||||
* underlying operating system and delays induced by network-filesystem protocols.
|
||||
* This is true regardless of the language in which these other programs are
|
||||
* written, and whether they are running on the same machine or on some other
|
||||
* machine. The exact nature of any such inconsistencies are system-dependent
|
||||
* and are therefore unspecified.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public abstract class AsynchronousFileChannel
|
||||
implements AsynchronousChannel
|
||||
{
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*/
|
||||
protected AsynchronousFileChannel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or creates a file for reading and/or writing, returning an
|
||||
* asynchronous file channel to access the file.
|
||||
*
|
||||
* <p> The {@code options} parameter determines how the file is opened.
|
||||
* The {@link StandardOpenOption#READ READ} and {@link StandardOpenOption#WRITE
|
||||
* WRITE} options determines if the file should be opened for reading and/or
|
||||
* writing. If neither option is contained in the array then an existing file
|
||||
* is opened for reading.
|
||||
*
|
||||
* <p> In addition to {@code READ} and {@code WRITE}, the following options
|
||||
* may be present:
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="">
|
||||
* <tr> <th>Option</th> <th>Description</th> </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td>
|
||||
* <td> When opening an existing file, the file is first truncated to a
|
||||
* size of 0 bytes. This option is ignored when the file is opened only
|
||||
* for reading.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </td>
|
||||
* <td> If this option is present then a new file is created, failing if
|
||||
* the file already exists. When creating a file the check for the
|
||||
* existence of the file and the creation of the file if it does not exist
|
||||
* is atomic with respect to other file system operations. This option is
|
||||
* ignored when the file is opened only for reading. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td > {@link StandardOpenOption#CREATE CREATE} </td>
|
||||
* <td> If this option is present then an existing file is opened if it
|
||||
* exists, otherwise a new file is created. When creating a file the check
|
||||
* for the existence of the file and the creation of the file if it does
|
||||
* not exist is atomic with respect to other file system operations. This
|
||||
* option is ignored if the {@code CREATE_NEW} option is also present or
|
||||
* the file is opened only for reading. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </td>
|
||||
* <td> When this option is present then the implementation makes a
|
||||
* <em>best effort</em> attempt to delete the file when closed by the
|
||||
* the {@link #close close} method. If the {@code close} method is not
|
||||
* invoked then a <em>best effort</em> attempt is made to delete the file
|
||||
* when the Java virtual machine terminates. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link StandardOpenOption#SPARSE SPARSE} </td>
|
||||
* <td> When creating a new file this option is a <em>hint</em> that the
|
||||
* new file will be sparse. This option is ignored when not creating
|
||||
* a new file. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#SYNC SYNC} </td>
|
||||
* <td> Requires that every update to the file's content or metadata be
|
||||
* written synchronously to the underlying storage device. (see <a
|
||||
* href="../file/package-summary.html#integrity"> Synchronized I/O file
|
||||
* integrity</a>). </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#DSYNC DSYNC} </td>
|
||||
* <td> Requires that every update to the file's content be written
|
||||
* synchronously to the underlying storage device. (see <a
|
||||
* href="../file/package-summary.html#integrity"> Synchronized I/O file
|
||||
* integrity</a>). </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p> An implementation may also support additional options.
|
||||
*
|
||||
* <p> The {@code executor} parameter is the {@link ExecutorService} to
|
||||
* which tasks are submitted to handle I/O events and dispatch completion
|
||||
* results for operations initiated on resulting channel.
|
||||
* The nature of these tasks is highly implementation specific and so care
|
||||
* should be taken when configuring the {@code Executor}. Minimally it
|
||||
* should support an unbounded work queue and should not run tasks on the
|
||||
* caller thread of the {@link ExecutorService#execute execute} method.
|
||||
* Shutting down the executor service while the channel is open results in
|
||||
* unspecified behavior.
|
||||
*
|
||||
* <p> The {@code attrs} parameter is an optional array of file {@link
|
||||
* FileAttribute file-attributes} to set atomically when creating the file.
|
||||
*
|
||||
* <p> The new channel is created by invoking the {@link
|
||||
* FileSystemProvider#newFileChannel newFileChannel} method on the
|
||||
* provider that created the {@code Path}.
|
||||
*
|
||||
* @param file
|
||||
* The path of the file to open or create
|
||||
* @param options
|
||||
* Options specifying how the file is opened
|
||||
* @param executor
|
||||
* The thread pool or {@code null} to associate the channel with
|
||||
* the default thread pool
|
||||
* @param attrs
|
||||
* An optional list of file attributes to set atomically when
|
||||
* creating the file
|
||||
*
|
||||
* @return A new asynchronous file channel
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the set contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* If the {@code file} is associated with a provider that does not
|
||||
* support creating asynchronous file channels, or an unsupported
|
||||
* open option is specified, or the array contains an attribute that
|
||||
* cannot be set atomically when creating the file
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an
|
||||
* unspecified permission required by the implementation.
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String)} method is invoked to check
|
||||
* read access if the file is opened for reading. The {@link
|
||||
* SecurityManager#checkWrite(String)} method is invoked to check
|
||||
* write access if the file is opened for writing
|
||||
*/
|
||||
public static AsynchronousFileChannel open(Path file,
|
||||
Set<? extends OpenOption> options,
|
||||
ExecutorService executor,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
FileSystemProvider provider = file.getFileSystem().provider();
|
||||
return provider.newAsynchronousFileChannel(file, options, executor, attrs);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
|
||||
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
|
||||
|
||||
/**
|
||||
* Opens or creates a file for reading and/or writing, returning an
|
||||
* asynchronous file channel to access the file.
|
||||
*
|
||||
* <p> An invocation of this method behaves in exactly the same way as the
|
||||
* invocation
|
||||
* <pre>
|
||||
* ch.{@link #open(Path,Set,ExecutorService,FileAttribute[])
|
||||
* open}(file, opts, null, new FileAttribute<?>[0]);
|
||||
* </pre>
|
||||
* where {@code opts} is a {@code Set} containing the options specified to
|
||||
* this method.
|
||||
*
|
||||
* <p> The resulting channel is associated with default thread pool to which
|
||||
* tasks are submitted to handle I/O events and dispatch to completion
|
||||
* handlers that consume the result of asynchronous operations performed on
|
||||
* the resulting channel.
|
||||
*
|
||||
* @param file
|
||||
* The path of the file to open or create
|
||||
* @param options
|
||||
* Options specifying how the file is opened
|
||||
*
|
||||
* @return A new asynchronous file channel
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the set contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* If the {@code file} is associated with a provider that does not
|
||||
* support creating file channels, or an unsupported open option is
|
||||
* specified
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an
|
||||
* unspecified permission required by the implementation.
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String)} method is invoked to check
|
||||
* read access if the file is opened for reading. The {@link
|
||||
* SecurityManager#checkWrite(String)} method is invoked to check
|
||||
* write access if the file is opened for writing
|
||||
*/
|
||||
public static AsynchronousFileChannel open(Path file, OpenOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> set = new HashSet<OpenOption>(options.length);
|
||||
Collections.addAll(set, options);
|
||||
return open(file, set, null, NO_ATTRIBUTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current size of this channel's file.
|
||||
*
|
||||
* @return The current size of this channel's file, measured in bytes
|
||||
*
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract long size() throws IOException;
|
||||
|
||||
/**
|
||||
* Truncates this channel's file to the given size.
|
||||
*
|
||||
* <p> If the given size is less than the file's current size then the file
|
||||
* is truncated, discarding any bytes beyond the new end of the file. If
|
||||
* the given size is greater than or equal to the file's current size then
|
||||
* the file is not modified. </p>
|
||||
*
|
||||
* @param size
|
||||
* The new size, a non-negative byte count
|
||||
*
|
||||
* @return This file channel
|
||||
*
|
||||
* @throws NonWritableChannelException
|
||||
* If this channel was not opened for writing
|
||||
*
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the new size is negative
|
||||
*
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract AsynchronousFileChannel truncate(long size) throws IOException;
|
||||
|
||||
/**
|
||||
* Forces any updates to this channel's file to be written to the storage
|
||||
* device that contains it.
|
||||
*
|
||||
* <p> If this channel's file resides on a local storage device then when
|
||||
* this method returns it is guaranteed that all changes made to the file
|
||||
* since this channel was created, or since this method was last invoked,
|
||||
* will have been written to that device. This is useful for ensuring that
|
||||
* critical information is not lost in the event of a system crash.
|
||||
*
|
||||
* <p> If the file does not reside on a local device then no such guarantee
|
||||
* is made.
|
||||
*
|
||||
* <p> The {@code metaData} parameter can be used to limit the number of
|
||||
* I/O operations that this method is required to perform. Passing
|
||||
* {@code false} for this parameter indicates that only updates to the
|
||||
* file's content need be written to storage; passing {@code true}
|
||||
* indicates that updates to both the file's content and metadata must be
|
||||
* written, which generally requires at least one more I/O operation.
|
||||
* Whether this parameter actually has any effect is dependent upon the
|
||||
* underlying operating system and is therefore unspecified.
|
||||
*
|
||||
* <p> Invoking this method may cause an I/O operation to occur even if the
|
||||
* channel was only opened for reading. Some operating systems, for
|
||||
* example, maintain a last-access time as part of a file's metadata, and
|
||||
* this time is updated whenever the file is read. Whether or not this is
|
||||
* actually done is system-dependent and is therefore unspecified.
|
||||
*
|
||||
* <p> This method is only guaranteed to force changes that were made to
|
||||
* this channel's file via the methods defined in this class.
|
||||
*
|
||||
* @param metaData
|
||||
* If {@code true} then this method is required to force changes
|
||||
* to both the file's content and metadata to be written to
|
||||
* storage; otherwise, it need only force content changes to be
|
||||
* written
|
||||
*
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
*
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract void force(boolean metaData) throws IOException;
|
||||
|
||||
/**
|
||||
* Acquires a lock on the given region of this channel's file.
|
||||
*
|
||||
* <p> This method initiates an operation to acquire a lock on the given
|
||||
* region of this channel's file. The {@code handler} parameter is a
|
||||
* completion handler that is invoked when the lock is acquired (or the
|
||||
* operation fails). The result passed to the completion handler is the
|
||||
* resulting {@code FileLock}.
|
||||
*
|
||||
* <p> The region specified by the {@code position} and {@code size}
|
||||
* parameters need not be contained within, or even overlap, the actual
|
||||
* underlying file. Lock regions are fixed in size; if a locked region
|
||||
* initially contains the end of the file and the file grows beyond the
|
||||
* region then the new portion of the file will not be covered by the lock.
|
||||
* If a file is expected to grow in size and a lock on the entire file is
|
||||
* required then a region starting at zero, and no smaller than the
|
||||
* expected maximum size of the file, should be locked. The two-argument
|
||||
* {@link #lock(Object,CompletionHandler)} method simply locks a region
|
||||
* of size {@link Long#MAX_VALUE}. If a lock that overlaps the requested
|
||||
* region is already held by this Java virtual machine, or this method has
|
||||
* been invoked to lock an overlapping region and that operation has not
|
||||
* completed, then this method throws {@link OverlappingFileLockException}.
|
||||
*
|
||||
* <p> Some operating systems do not support a mechanism to acquire a file
|
||||
* lock in an asynchronous manner. Consequently an implementation may
|
||||
* acquire the file lock in a background thread or from a task executed by
|
||||
* a thread in the associated thread pool. If there are many lock operations
|
||||
* outstanding then it may consume threads in the Java virtual machine for
|
||||
* indefinite periods.
|
||||
*
|
||||
* <p> Some operating systems do not support shared locks, in which case a
|
||||
* request for a shared lock is automatically converted into a request for
|
||||
* an exclusive lock. Whether the newly-acquired lock is shared or
|
||||
* exclusive may be tested by invoking the resulting lock object's {@link
|
||||
* FileLock#isShared() isShared} method.
|
||||
*
|
||||
* <p> File locks are held on behalf of the entire Java virtual machine.
|
||||
* They are not suitable for controlling access to a file by multiple
|
||||
* threads within the same virtual machine.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param position
|
||||
* The position at which the locked region is to start; must be
|
||||
* non-negative
|
||||
* @param size
|
||||
* The size of the locked region; must be non-negative, and the sum
|
||||
* {@code position} + {@code size} must be non-negative
|
||||
* @param shared
|
||||
* {@code true} to request a shared lock, in which case this
|
||||
* channel must be open for reading (and possibly writing);
|
||||
* {@code false} to request an exclusive lock, in which case this
|
||||
* channel must be open for writing (and possibly reading)
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock that overlaps the requested region is already held by
|
||||
* this Java virtual machine, or there is already a pending attempt
|
||||
* to lock an overlapping region
|
||||
* @throws IllegalArgumentException
|
||||
* If the preconditions on the parameters do not hold
|
||||
* @throws NonReadableChannelException
|
||||
* If {@code shared} is true but this channel was not opened for reading
|
||||
* @throws NonWritableChannelException
|
||||
* If {@code shared} is false but this channel was not opened for writing
|
||||
*/
|
||||
public abstract <A> void lock(long position,
|
||||
long size,
|
||||
boolean shared,
|
||||
A attachment,
|
||||
CompletionHandler<FileLock,? super A> handler);
|
||||
|
||||
/**
|
||||
* Acquires an exclusive lock on this channel's file.
|
||||
*
|
||||
* <p> This method initiates an operation to acquire a lock on the given
|
||||
* region of this channel's file. The {@code handler} parameter is a
|
||||
* completion handler that is invoked when the lock is acquired (or the
|
||||
* operation fails). The result passed to the completion handler is the
|
||||
* resulting {@code FileLock}.
|
||||
*
|
||||
* <p> An invocation of this method of the form {@code ch.lock(att,handler)}
|
||||
* behaves in exactly the same way as the invocation
|
||||
* <pre>
|
||||
* ch.{@link #lock(long,long,boolean,Object,CompletionHandler) lock}(0L, Long.MAX_VALUE, false, att, handler)
|
||||
* </pre>
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock is already held by this Java virtual machine, or there
|
||||
* is already a pending attempt to lock a region
|
||||
* @throws NonWritableChannelException
|
||||
* If this channel was not opened for writing
|
||||
*/
|
||||
public final <A> void lock(A attachment,
|
||||
CompletionHandler<FileLock,? super A> handler)
|
||||
{
|
||||
lock(0L, Long.MAX_VALUE, false, attachment, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquires a lock on the given region of this channel's file.
|
||||
*
|
||||
* <p> This method initiates an operation to acquire a lock on the given
|
||||
* region of this channel's file. The method behaves in exactly the same
|
||||
* manner as the {@link #lock(long, long, boolean, Object, CompletionHandler)}
|
||||
* method except that instead of specifying a completion handler, this
|
||||
* method returns a {@code Future} representing the pending result. The
|
||||
* {@code Future}'s {@link Future#get() get} method returns the {@link
|
||||
* FileLock} on successful completion.
|
||||
*
|
||||
* @param position
|
||||
* The position at which the locked region is to start; must be
|
||||
* non-negative
|
||||
* @param size
|
||||
* The size of the locked region; must be non-negative, and the sum
|
||||
* {@code position} + {@code size} must be non-negative
|
||||
* @param shared
|
||||
* {@code true} to request a shared lock, in which case this
|
||||
* channel must be open for reading (and possibly writing);
|
||||
* {@code false} to request an exclusive lock, in which case this
|
||||
* channel must be open for writing (and possibly reading)
|
||||
*
|
||||
* @return a {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock is already held by this Java virtual machine, or there
|
||||
* is already a pending attempt to lock a region
|
||||
* @throws IllegalArgumentException
|
||||
* If the preconditions on the parameters do not hold
|
||||
* @throws NonReadableChannelException
|
||||
* If {@code shared} is true but this channel was not opened for reading
|
||||
* @throws NonWritableChannelException
|
||||
* If {@code shared} is false but this channel was not opened for writing
|
||||
*/
|
||||
public abstract Future<FileLock> lock(long position, long size, boolean shared);
|
||||
|
||||
/**
|
||||
* Acquires an exclusive lock on this channel's file.
|
||||
*
|
||||
* <p> This method initiates an operation to acquire an exclusive lock on this
|
||||
* channel's file. The method returns a {@code Future} representing the
|
||||
* pending result of the operation. The {@code Future}'s {@link Future#get()
|
||||
* get} method returns the {@link FileLock} on successful completion.
|
||||
*
|
||||
* <p> An invocation of this method behaves in exactly the same way as the
|
||||
* invocation
|
||||
* <pre>
|
||||
* ch.{@link #lock(long,long,boolean) lock}(0L, Long.MAX_VALUE, false)
|
||||
* </pre>
|
||||
*
|
||||
* @return a {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock is already held by this Java virtual machine, or there
|
||||
* is already a pending attempt to lock a region
|
||||
* @throws NonWritableChannelException
|
||||
* If this channel was not opened for writing
|
||||
*/
|
||||
public final Future<FileLock> lock() {
|
||||
return lock(0L, Long.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to acquire a lock on the given region of this channel's file.
|
||||
*
|
||||
* <p> This method does not block. An invocation always returns immediately,
|
||||
* either having acquired a lock on the requested region or having failed to
|
||||
* do so. If it fails to acquire a lock because an overlapping lock is held
|
||||
* by another program then it returns {@code null}. If it fails to acquire
|
||||
* a lock for any other reason then an appropriate exception is thrown.
|
||||
*
|
||||
* @param position
|
||||
* The position at which the locked region is to start; must be
|
||||
* non-negative
|
||||
*
|
||||
* @param size
|
||||
* The size of the locked region; must be non-negative, and the sum
|
||||
* {@code position} + {@code size} must be non-negative
|
||||
*
|
||||
* @param shared
|
||||
* {@code true} to request a shared lock,
|
||||
* {@code false} to request an exclusive lock
|
||||
*
|
||||
* @return A lock object representing the newly-acquired lock,
|
||||
* or {@code null} if the lock could not be acquired
|
||||
* because another program holds an overlapping lock
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the preconditions on the parameters do not hold
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock that overlaps the requested region is already held by
|
||||
* this Java virtual machine, or if another thread is already
|
||||
* blocked in this method and is attempting to lock an overlapping
|
||||
* region of the same file
|
||||
* @throws NonReadableChannelException
|
||||
* If {@code shared} is true but this channel was not opened for reading
|
||||
* @throws NonWritableChannelException
|
||||
* If {@code shared} is false but this channel was not opened for writing
|
||||
*
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*
|
||||
* @see #lock(Object,CompletionHandler)
|
||||
* @see #lock(long,long,boolean,Object,CompletionHandler)
|
||||
* @see #tryLock()
|
||||
*/
|
||||
public abstract FileLock tryLock(long position, long size, boolean shared)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Attempts to acquire an exclusive lock on this channel's file.
|
||||
*
|
||||
* <p> An invocation of this method of the form {@code ch.tryLock()}
|
||||
* behaves in exactly the same way as the invocation
|
||||
*
|
||||
* <pre>
|
||||
* ch.{@link #tryLock(long,long,boolean) tryLock}(0L, Long.MAX_VALUE, false) </pre>
|
||||
*
|
||||
* @return A lock object representing the newly-acquired lock,
|
||||
* or {@code null} if the lock could not be acquired
|
||||
* because another program holds an overlapping lock
|
||||
*
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
* @throws OverlappingFileLockException
|
||||
* If a lock that overlaps the requested region is already held by
|
||||
* this Java virtual machine, or if another thread is already
|
||||
* blocked in this method and is attempting to lock an overlapping
|
||||
* region
|
||||
* @throws NonWritableChannelException
|
||||
* If {@code shared} is false but this channel was not opened for writing
|
||||
*
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*
|
||||
* @see #lock(Object,CompletionHandler)
|
||||
* @see #lock(long,long,boolean,Object,CompletionHandler)
|
||||
* @see #tryLock(long,long,boolean)
|
||||
*/
|
||||
public final FileLock tryLock() throws IOException {
|
||||
return tryLock(0L, Long.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into the given buffer,
|
||||
* starting at the given file position.
|
||||
*
|
||||
* <p> This method initiates the reading of a sequence of bytes from this
|
||||
* channel into the given buffer, starting at the given file position. The
|
||||
* result of the read is the number of bytes read or {@code -1} if the given
|
||||
* position is greater than or equal to the file's size at the time that the
|
||||
* read is attempted.
|
||||
*
|
||||
* <p> This method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#read(ByteBuffer,Object,CompletionHandler)}
|
||||
* method, except that bytes are read starting at the given file position.
|
||||
* If the given file position is greater than the file's size at the time
|
||||
* that the read is attempted then no bytes are read.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param dst
|
||||
* The buffer into which bytes are to be transferred
|
||||
* @param position
|
||||
* The file position at which the transfer is to begin;
|
||||
* must be non-negative
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the position is negative or the buffer is read-only
|
||||
* @throws NonReadableChannelException
|
||||
* If this channel was not opened for reading
|
||||
*/
|
||||
public abstract <A> void read(ByteBuffer dst,
|
||||
long position,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into the given buffer,
|
||||
* starting at the given file position.
|
||||
*
|
||||
* <p> This method initiates the reading of a sequence of bytes from this
|
||||
* channel into the given buffer, starting at the given file position. This
|
||||
* method returns a {@code Future} representing the pending result of the
|
||||
* operation. The {@code Future}'s {@link Future#get() get} method returns
|
||||
* the number of bytes read or {@code -1} if the given position is greater
|
||||
* than or equal to the file's size at the time that the read is attempted.
|
||||
*
|
||||
* <p> This method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#read(ByteBuffer)} method, except that bytes are
|
||||
* read starting at the given file position. If the given file position is
|
||||
* greater than the file's size at the time that the read is attempted then
|
||||
* no bytes are read.
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which bytes are to be transferred
|
||||
* @param position
|
||||
* The file position at which the transfer is to begin;
|
||||
* must be non-negative
|
||||
*
|
||||
* @return A {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the position is negative or the buffer is read-only
|
||||
* @throws NonReadableChannelException
|
||||
* If this channel was not opened for reading
|
||||
*/
|
||||
public abstract Future<Integer> read(ByteBuffer dst, long position);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from the given buffer, starting
|
||||
* at the given file position.
|
||||
*
|
||||
* <p> This method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#write(ByteBuffer,Object,CompletionHandler)}
|
||||
* method, except that bytes are written starting at the given file position.
|
||||
* If the given position is greater than the file's size, at the time that
|
||||
* the write is attempted, then the file will be grown to accommodate the new
|
||||
* bytes; the values of any bytes between the previous end-of-file and the
|
||||
* newly-written bytes are unspecified.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param src
|
||||
* The buffer from which bytes are to be transferred
|
||||
* @param position
|
||||
* The file position at which the transfer is to begin;
|
||||
* must be non-negative
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the position is negative
|
||||
* @throws NonWritableChannelException
|
||||
* If this channel was not opened for writing
|
||||
*/
|
||||
public abstract <A> void write(ByteBuffer src,
|
||||
long position,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from the given buffer, starting
|
||||
* at the given file position.
|
||||
*
|
||||
* <p> This method initiates the writing of a sequence of bytes to this
|
||||
* channel from the given buffer, starting at the given file position. The
|
||||
* method returns a {@code Future} representing the pending result of the
|
||||
* write operation. The {@code Future}'s {@link Future#get() get} method
|
||||
* returns the number of bytes written.
|
||||
*
|
||||
* <p> This method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#write(ByteBuffer)} method, except that bytes are
|
||||
* written starting at the given file position. If the given position is
|
||||
* greater than the file's size, at the time that the write is attempted,
|
||||
* then the file will be grown to accommodate the new bytes; the values of
|
||||
* any bytes between the previous end-of-file and the newly-written bytes
|
||||
* are unspecified.
|
||||
*
|
||||
* @param src
|
||||
* The buffer from which bytes are to be transferred
|
||||
* @param position
|
||||
* The file position at which the transfer is to begin;
|
||||
* must be non-negative
|
||||
*
|
||||
* @return A {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the position is negative
|
||||
* @throws NonWritableChannelException
|
||||
* If this channel was not opened for writing
|
||||
*/
|
||||
public abstract Future<Integer> write(ByteBuffer src, long position);
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.nio.channels.spi.*;
|
||||
import java.net.SocketOption;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.Future;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An asynchronous channel for stream-oriented listening sockets.
|
||||
*
|
||||
* <p> An asynchronous server-socket channel is created by invoking the
|
||||
* {@link #open open} method of this class.
|
||||
* A newly-created asynchronous server-socket channel is open but not yet bound.
|
||||
* It can be bound to a local address and configured to listen for connections
|
||||
* by invoking the {@link #bind(SocketAddress,int) bind} method. Once bound,
|
||||
* the {@link #accept(Object,CompletionHandler) accept} method
|
||||
* is used to initiate the accepting of connections to the channel's socket.
|
||||
* An attempt to invoke the <tt>accept</tt> method on an unbound channel will
|
||||
* cause a {@link NotYetBoundException} to be thrown.
|
||||
*
|
||||
* <p> Channels of this type are safe for use by multiple concurrent threads
|
||||
* though at most one accept operation can be outstanding at any time.
|
||||
* If a thread initiates an accept operation before a previous accept operation
|
||||
* has completed then an {@link AcceptPendingException} will be thrown.
|
||||
*
|
||||
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
|
||||
* setOption} method. Channels of this type support the following options:
|
||||
* <blockquote>
|
||||
* <table border summary="Socket options">
|
||||
* <tr>
|
||||
* <th>Option Name</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
|
||||
* <td> The size of the socket receive buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
|
||||
* <td> Re-use address </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* Additional (implementation specific) options may also be supported.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* <pre>
|
||||
* final AsynchronousServerSocketChannel listener =
|
||||
* AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(5000));
|
||||
*
|
||||
* listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
|
||||
* public void completed(AsynchronousSocketChannel ch, Void att) {
|
||||
* // accept the next connection
|
||||
* listener.accept(null, this);
|
||||
*
|
||||
* // handle this connection
|
||||
* handle(ch);
|
||||
* }
|
||||
* public void failed(Throwable exc, Void att) {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public abstract class AsynchronousServerSocketChannel
|
||||
implements AsynchronousChannel, NetworkChannel
|
||||
{
|
||||
private final AsynchronousChannelProvider provider;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*
|
||||
* @param provider
|
||||
* The provider that created this channel
|
||||
*/
|
||||
protected AsynchronousServerSocketChannel(AsynchronousChannelProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider that created this channel.
|
||||
*
|
||||
* @return The provider that created this channel
|
||||
*/
|
||||
public final AsynchronousChannelProvider provider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an asynchronous server-socket channel.
|
||||
*
|
||||
* <p> The new channel is created by invoking the {@link
|
||||
* java.nio.channels.spi.AsynchronousChannelProvider#openAsynchronousServerSocketChannel
|
||||
* openAsynchronousServerSocketChannel} method on the {@link
|
||||
* java.nio.channels.spi.AsynchronousChannelProvider} object that created
|
||||
* the given group. If the group parameter is <tt>null</tt> then the
|
||||
* resulting channel is created by the system-wide default provider, and
|
||||
* bound to the <em>default group</em>.
|
||||
*
|
||||
* @param group
|
||||
* The group to which the newly constructed channel should be bound,
|
||||
* or <tt>null</tt> for the default group
|
||||
*
|
||||
* @return A new asynchronous server socket channel
|
||||
*
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group is shutdown
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousServerSocketChannel open(AsynchronousChannelGroup group)
|
||||
throws IOException
|
||||
{
|
||||
AsynchronousChannelProvider provider = (group == null) ?
|
||||
AsynchronousChannelProvider.provider() : group.provider();
|
||||
return provider.openAsynchronousServerSocketChannel(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an asynchronous server-socket channel.
|
||||
*
|
||||
* <p> This method returns an asynchronous server socket channel that is
|
||||
* bound to the <em>default group</em>. This method is equivalent to evaluating
|
||||
* the expression:
|
||||
* <blockquote><pre>
|
||||
* open((AsynchronousChannelGroup)null);
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @return A new asynchronous server socket channel
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousServerSocketChannel open()
|
||||
throws IOException
|
||||
{
|
||||
return open(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the channel's socket to a local address and configures the socket to
|
||||
* listen for connections.
|
||||
*
|
||||
* <p> An invocation of this method is equivalent to the following:
|
||||
* <blockquote><pre>
|
||||
* bind(local, 0);
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @param local
|
||||
* The local address to bind the socket, or <tt>null</tt> to bind
|
||||
* to an automatically assigned socket address
|
||||
*
|
||||
* @return This channel
|
||||
*
|
||||
* @throws AlreadyBoundException {@inheritDoc}
|
||||
* @throws UnsupportedAddressTypeException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
*/
|
||||
public final AsynchronousServerSocketChannel bind(SocketAddress local)
|
||||
throws IOException
|
||||
{
|
||||
return bind(local, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the channel's socket to a local address and configures the socket to
|
||||
* listen for connections.
|
||||
*
|
||||
* <p> This method is used to establish an association between the socket and
|
||||
* a local address. Once an association is established then the socket remains
|
||||
* bound until the associated channel is closed.
|
||||
*
|
||||
* <p> The {@code backlog} parameter is the maximum number of pending
|
||||
* connections on the socket. Its exact semantics are implementation specific.
|
||||
* In particular, an implementation may impose a maximum length or may choose
|
||||
* to ignore the parameter altogther. If the {@code backlog} parameter has
|
||||
* the value {@code 0}, or a negative value, then an implementation specific
|
||||
* default is used.
|
||||
*
|
||||
* @param local
|
||||
* The local address to bind the socket, or {@code null} to bind
|
||||
* to an automatically assigned socket address
|
||||
* @param backlog
|
||||
* The maximum number of pending connections
|
||||
*
|
||||
* @return This channel
|
||||
*
|
||||
* @throws AlreadyBoundException
|
||||
* If the socket is already bound
|
||||
* @throws UnsupportedAddressTypeException
|
||||
* If the type of the given address is not supported
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed and its {@link
|
||||
* SecurityManager#checkListen checkListen} method denies the operation
|
||||
* @throws ClosedChannelException
|
||||
* If the channel is closed
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract AsynchronousServerSocketChannel bind(SocketAddress local, int backlog)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
*/
|
||||
public abstract <T> AsynchronousServerSocketChannel setOption(SocketOption<T> name, T value)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Accepts a connection.
|
||||
*
|
||||
* <p> This method initiates an asynchronous operation to accept a
|
||||
* connection made to this channel's socket. The {@code handler} parameter is
|
||||
* a completion handler that is invoked when a connection is accepted (or
|
||||
* the operation fails). The result passed to the completion handler is
|
||||
* the {@link AsynchronousSocketChannel} to the new connection.
|
||||
*
|
||||
* <p> When a new connection is accepted then the resulting {@code
|
||||
* AsynchronousSocketChannel} will be bound to the same {@link
|
||||
* AsynchronousChannelGroup} as this channel. If the group is {@link
|
||||
* AsynchronousChannelGroup#isShutdown shutdown} and a connection is accepted,
|
||||
* then the connection is closed, and the operation completes with an {@code
|
||||
* IOException} and cause {@link ShutdownChannelGroupException}.
|
||||
*
|
||||
* <p> To allow for concurrent handling of new connections, the completion
|
||||
* handler is not invoked directly by the initiating thread when a new
|
||||
* connection is accepted immediately (see <a
|
||||
* href="AsynchronousChannelGroup.html#threading">Threading</a>).
|
||||
*
|
||||
* <p> If a security manager has been installed then it verifies that the
|
||||
* address and port number of the connection's remote endpoint are permitted
|
||||
* by the security manager's {@link SecurityManager#checkAccept checkAccept}
|
||||
* method. The permission check is performed with privileges that are restricted
|
||||
* by the calling context of this method. If the permission check fails then
|
||||
* the connection is closed and the operation completes with a {@link
|
||||
* SecurityException}.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws AcceptPendingException
|
||||
* If an accept operation is already in progress on this channel
|
||||
* @throws NotYetBoundException
|
||||
* If this channel's socket has not yet been bound
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
public abstract <A> void accept(A attachment,
|
||||
CompletionHandler<AsynchronousSocketChannel,? super A> handler);
|
||||
|
||||
/**
|
||||
* Accepts a connection.
|
||||
*
|
||||
* <p> This method initiates an asynchronous operation to accept a
|
||||
* connection made to this channel's socket. The method behaves in exactly
|
||||
* the same manner as the {@link #accept(Object, CompletionHandler)} method
|
||||
* except that instead of specifying a completion handler, this method
|
||||
* returns a {@code Future} representing the pending result. The {@code
|
||||
* Future}'s {@link Future#get() get} method returns the {@link
|
||||
* AsynchronousSocketChannel} to the new connection on successful completion.
|
||||
*
|
||||
* @return a {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws AcceptPendingException
|
||||
* If an accept operation is already in progress on this channel
|
||||
* @throws NotYetBoundException
|
||||
* If this channel's socket has not yet been bound
|
||||
*/
|
||||
public abstract Future<AsynchronousSocketChannel> accept();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If there is a security manager set, its {@code checkConnect} method is
|
||||
* called with the local address and {@code -1} as its arguments to see
|
||||
* if the operation is allowed. If the operation is not allowed,
|
||||
* a {@code SocketAddress} representing the
|
||||
* {@link java.net.InetAddress#getLoopbackAddress loopback} address and the
|
||||
* local port of the channel's socket is returned.
|
||||
*
|
||||
* @return The {@code SocketAddress} that the socket is bound to, or the
|
||||
* {@code SocketAddress} representing the loopback address if
|
||||
* denied by the security manager, or {@code null} if the
|
||||
* channel's socket is not bound
|
||||
*
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public abstract SocketAddress getLocalAddress() throws IOException;
|
||||
}
|
||||
687
jdkSrc/jdk8/java/nio/channels/AsynchronousSocketChannel.java
Normal file
687
jdkSrc/jdk8/java/nio/channels/AsynchronousSocketChannel.java
Normal file
@@ -0,0 +1,687 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.nio.channels.spi.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.Future;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketOption;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* An asynchronous channel for stream-oriented connecting sockets.
|
||||
*
|
||||
* <p> Asynchronous socket channels are created in one of two ways. A newly-created
|
||||
* {@code AsynchronousSocketChannel} is created by invoking one of the {@link
|
||||
* #open open} methods defined by this class. A newly-created channel is open but
|
||||
* not yet connected. A connected {@code AsynchronousSocketChannel} is created
|
||||
* when a connection is made to the socket of an {@link AsynchronousServerSocketChannel}.
|
||||
* It is not possible to create an asynchronous socket channel for an arbitrary,
|
||||
* pre-existing {@link java.net.Socket socket}.
|
||||
*
|
||||
* <p> A newly-created channel is connected by invoking its {@link #connect connect}
|
||||
* method; once connected, a channel remains connected until it is closed. Whether
|
||||
* or not a socket channel is connected may be determined by invoking its {@link
|
||||
* #getRemoteAddress getRemoteAddress} method. An attempt to invoke an I/O
|
||||
* operation upon an unconnected channel will cause a {@link NotYetConnectedException}
|
||||
* to be thrown.
|
||||
*
|
||||
* <p> Channels of this type are safe for use by multiple concurrent threads.
|
||||
* They support concurrent reading and writing, though at most one read operation
|
||||
* and one write operation can be outstanding at any time.
|
||||
* If a thread initiates a read operation before a previous read operation has
|
||||
* completed then a {@link ReadPendingException} will be thrown. Similarly, an
|
||||
* attempt to initiate a write operation before a previous write has completed
|
||||
* will throw a {@link WritePendingException}.
|
||||
*
|
||||
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
|
||||
* setOption} method. Asynchronous socket channels support the following options:
|
||||
* <blockquote>
|
||||
* <table border summary="Socket options">
|
||||
* <tr>
|
||||
* <th>Option Name</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
|
||||
* <td> The size of the socket send buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
|
||||
* <td> The size of the socket receive buffer </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </td>
|
||||
* <td> Keep connection alive </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
|
||||
* <td> Re-use address </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </td>
|
||||
* <td> Disable the Nagle algorithm </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* Additional (implementation specific) options may also be supported.
|
||||
*
|
||||
* <h2>Timeouts</h2>
|
||||
*
|
||||
* <p> The {@link #read(ByteBuffer,long,TimeUnit,Object,CompletionHandler) read}
|
||||
* and {@link #write(ByteBuffer,long,TimeUnit,Object,CompletionHandler) write}
|
||||
* methods defined by this class allow a timeout to be specified when initiating
|
||||
* a read or write operation. If the timeout elapses before an operation completes
|
||||
* then the operation completes with the exception {@link
|
||||
* InterruptedByTimeoutException}. A timeout may leave the channel, or the
|
||||
* underlying connection, in an inconsistent state. Where the implementation
|
||||
* cannot guarantee that bytes have not been read from the channel then it puts
|
||||
* the channel into an implementation specific <em>error state</em>. A subsequent
|
||||
* attempt to initiate a {@code read} operation causes an unspecified runtime
|
||||
* exception to be thrown. Similarly if a {@code write} operation times out and
|
||||
* the implementation cannot guarantee bytes have not been written to the
|
||||
* channel then further attempts to {@code write} to the channel cause an
|
||||
* unspecified runtime exception to be thrown. When a timeout elapses then the
|
||||
* state of the {@link ByteBuffer}, or the sequence of buffers, for the I/O
|
||||
* operation is not defined. Buffers should be discarded or at least care must
|
||||
* be taken to ensure that the buffers are not accessed while the channel remains
|
||||
* open. All methods that accept timeout parameters treat values less than or
|
||||
* equal to zero to mean that the I/O operation does not timeout.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public abstract class AsynchronousSocketChannel
|
||||
implements AsynchronousByteChannel, NetworkChannel
|
||||
{
|
||||
private final AsynchronousChannelProvider provider;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*
|
||||
* @param provider
|
||||
* The provider that created this channel
|
||||
*/
|
||||
protected AsynchronousSocketChannel(AsynchronousChannelProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider that created this channel.
|
||||
*
|
||||
* @return The provider that created this channel
|
||||
*/
|
||||
public final AsynchronousChannelProvider provider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an asynchronous socket channel.
|
||||
*
|
||||
* <p> The new channel is created by invoking the {@link
|
||||
* AsynchronousChannelProvider#openAsynchronousSocketChannel
|
||||
* openAsynchronousSocketChannel} method on the {@link
|
||||
* AsynchronousChannelProvider} that created the group. If the group parameter
|
||||
* is {@code null} then the resulting channel is created by the system-wide
|
||||
* default provider, and bound to the <em>default group</em>.
|
||||
*
|
||||
* @param group
|
||||
* The group to which the newly constructed channel should be bound,
|
||||
* or {@code null} for the default group
|
||||
*
|
||||
* @return A new asynchronous socket channel
|
||||
*
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group is shutdown
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousSocketChannel open(AsynchronousChannelGroup group)
|
||||
throws IOException
|
||||
{
|
||||
AsynchronousChannelProvider provider = (group == null) ?
|
||||
AsynchronousChannelProvider.provider() : group.provider();
|
||||
return provider.openAsynchronousSocketChannel(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an asynchronous socket channel.
|
||||
*
|
||||
* <p> This method returns an asynchronous socket channel that is bound to
|
||||
* the <em>default group</em>.This method is equivalent to evaluating the
|
||||
* expression:
|
||||
* <blockquote><pre>
|
||||
* open((AsynchronousChannelGroup)null);
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @return A new asynchronous socket channel
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public static AsynchronousSocketChannel open()
|
||||
throws IOException
|
||||
{
|
||||
return open(null);
|
||||
}
|
||||
|
||||
|
||||
// -- socket options and related --
|
||||
|
||||
/**
|
||||
* @throws ConnectionPendingException
|
||||
* If a connection operation is already in progress on this channel
|
||||
* @throws AlreadyBoundException {@inheritDoc}
|
||||
* @throws UnsupportedAddressTypeException {@inheritDoc}
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed and its
|
||||
* {@link SecurityManager#checkListen checkListen} method denies
|
||||
* the operation
|
||||
*/
|
||||
@Override
|
||||
public abstract AsynchronousSocketChannel bind(SocketAddress local)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public abstract <T> AsynchronousSocketChannel setOption(SocketOption<T> name, T value)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Shutdown the connection for reading without closing the channel.
|
||||
*
|
||||
* <p> Once shutdown for reading then further reads on the channel will
|
||||
* return {@code -1}, the end-of-stream indication. If the input side of the
|
||||
* connection is already shutdown then invoking this method has no effect.
|
||||
* The effect on an outstanding read operation is system dependent and
|
||||
* therefore not specified. The effect, if any, when there is data in the
|
||||
* socket receive buffer that has not been read, or data arrives subsequently,
|
||||
* is also system dependent.
|
||||
*
|
||||
* @return The channel
|
||||
*
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract AsynchronousSocketChannel shutdownInput() throws IOException;
|
||||
|
||||
/**
|
||||
* Shutdown the connection for writing without closing the channel.
|
||||
*
|
||||
* <p> Once shutdown for writing then further attempts to write to the
|
||||
* channel will throw {@link ClosedChannelException}. If the output side of
|
||||
* the connection is already shutdown then invoking this method has no
|
||||
* effect. The effect on an outstanding write operation is system dependent
|
||||
* and therefore not specified.
|
||||
*
|
||||
* @return The channel
|
||||
*
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ClosedChannelException
|
||||
* If this channel is closed
|
||||
* @throws IOException
|
||||
* If some other I/O error occurs
|
||||
*/
|
||||
public abstract AsynchronousSocketChannel shutdownOutput() throws IOException;
|
||||
|
||||
// -- state --
|
||||
|
||||
/**
|
||||
* Returns the remote address to which this channel's socket is connected.
|
||||
*
|
||||
* <p> Where the channel is bound and connected to an Internet Protocol
|
||||
* socket address then the return value from this method is of type {@link
|
||||
* java.net.InetSocketAddress}.
|
||||
*
|
||||
* @return The remote address; {@code null} if the channel's socket is not
|
||||
* connected
|
||||
*
|
||||
* @throws ClosedChannelException
|
||||
* If the channel is closed
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract SocketAddress getRemoteAddress() throws IOException;
|
||||
|
||||
// -- asynchronous operations --
|
||||
|
||||
/**
|
||||
* Connects this channel.
|
||||
*
|
||||
* <p> This method initiates an operation to connect this channel. The
|
||||
* {@code handler} parameter is a completion handler that is invoked when
|
||||
* the connection is successfully established or connection cannot be
|
||||
* established. If the connection cannot be established then the channel is
|
||||
* closed.
|
||||
*
|
||||
* <p> This method performs exactly the same security checks as the {@link
|
||||
* java.net.Socket} class. That is, if a security manager has been
|
||||
* installed then this method verifies that its {@link
|
||||
* java.lang.SecurityManager#checkConnect checkConnect} method permits
|
||||
* connecting to the address and port number of the given remote endpoint.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param remote
|
||||
* The remote address to which this channel is to be connected
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws UnresolvedAddressException
|
||||
* If the given remote address is not fully resolved
|
||||
* @throws UnsupportedAddressTypeException
|
||||
* If the type of the given remote address is not supported
|
||||
* @throws AlreadyConnectedException
|
||||
* If this channel is already connected
|
||||
* @throws ConnectionPendingException
|
||||
* If a connection operation is already in progress on this channel
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed
|
||||
* and it does not permit access to the given remote endpoint
|
||||
*
|
||||
* @see #getRemoteAddress
|
||||
*/
|
||||
public abstract <A> void connect(SocketAddress remote,
|
||||
A attachment,
|
||||
CompletionHandler<Void,? super A> handler);
|
||||
|
||||
/**
|
||||
* Connects this channel.
|
||||
*
|
||||
* <p> This method initiates an operation to connect this channel. This
|
||||
* method behaves in exactly the same manner as the {@link
|
||||
* #connect(SocketAddress, Object, CompletionHandler)} method except that
|
||||
* instead of specifying a completion handler, this method returns a {@code
|
||||
* Future} representing the pending result. The {@code Future}'s {@link
|
||||
* Future#get() get} method returns {@code null} on successful completion.
|
||||
*
|
||||
* @param remote
|
||||
* The remote address to which this channel is to be connected
|
||||
*
|
||||
* @return A {@code Future} object representing the pending result
|
||||
*
|
||||
* @throws UnresolvedAddressException
|
||||
* If the given remote address is not fully resolved
|
||||
* @throws UnsupportedAddressTypeException
|
||||
* If the type of the given remote address is not supported
|
||||
* @throws AlreadyConnectedException
|
||||
* If this channel is already connected
|
||||
* @throws ConnectionPendingException
|
||||
* If a connection operation is already in progress on this channel
|
||||
* @throws SecurityException
|
||||
* If a security manager has been installed
|
||||
* and it does not permit access to the given remote endpoint
|
||||
*/
|
||||
public abstract Future<Void> connect(SocketAddress remote);
|
||||
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous read operation to read a
|
||||
* sequence of bytes from this channel into the given buffer. The {@code
|
||||
* handler} parameter is a completion handler that is invoked when the read
|
||||
* operation completes (or fails). The result passed to the completion
|
||||
* handler is the number of bytes read or {@code -1} if no bytes could be
|
||||
* read because the channel has reached end-of-stream.
|
||||
*
|
||||
* <p> If a timeout is specified and the timeout elapses before the operation
|
||||
* completes then the operation completes with the exception {@link
|
||||
* InterruptedByTimeoutException}. Where a timeout occurs, and the
|
||||
* implementation cannot guarantee that bytes have not been read, or will not
|
||||
* be read from the channel into the given buffer, then further attempts to
|
||||
* read from the channel will cause an unspecific runtime exception to be
|
||||
* thrown.
|
||||
*
|
||||
* <p> Otherwise this method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#read(ByteBuffer,Object,CompletionHandler)}
|
||||
* method.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param dst
|
||||
* The buffer into which bytes are to be transferred
|
||||
* @param timeout
|
||||
* The maximum time for the I/O operation to complete
|
||||
* @param unit
|
||||
* The time unit of the {@code timeout} argument
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the buffer is read-only
|
||||
* @throws ReadPendingException
|
||||
* If a read operation is already in progress on this channel
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
public abstract <A> void read(ByteBuffer dst,
|
||||
long timeout,
|
||||
TimeUnit unit,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws ReadPendingException {@inheritDoc}
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
@Override
|
||||
public final <A> void read(ByteBuffer dst,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler)
|
||||
{
|
||||
read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws ReadPendingException {@inheritDoc}
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
*/
|
||||
@Override
|
||||
public abstract Future<Integer> read(ByteBuffer dst);
|
||||
|
||||
/**
|
||||
* Reads a sequence of bytes from this channel into a subsequence of the
|
||||
* given buffers. This operation, sometimes called a <em>scattering read</em>,
|
||||
* is often useful when implementing network protocols that group data into
|
||||
* segments consisting of one or more fixed-length headers followed by a
|
||||
* variable-length body. The {@code handler} parameter is a completion
|
||||
* handler that is invoked when the read operation completes (or fails). The
|
||||
* result passed to the completion handler is the number of bytes read or
|
||||
* {@code -1} if no bytes could be read because the channel has reached
|
||||
* end-of-stream.
|
||||
*
|
||||
* <p> This method initiates a read of up to <i>r</i> bytes from this channel,
|
||||
* where <i>r</i> is the total number of bytes remaining in the specified
|
||||
* subsequence of the given buffer array, that is,
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* dsts[offset].remaining()
|
||||
* + dsts[offset+1].remaining()
|
||||
* + ... + dsts[offset+length-1].remaining()</pre></blockquote>
|
||||
*
|
||||
* at the moment that the read is attempted.
|
||||
*
|
||||
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
|
||||
* <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
|
||||
* Up to the first <tt>dsts[offset].remaining()</tt> bytes of this sequence
|
||||
* are transferred into buffer <tt>dsts[offset]</tt>, up to the next
|
||||
* <tt>dsts[offset+1].remaining()</tt> bytes are transferred into buffer
|
||||
* <tt>dsts[offset+1]</tt>, and so forth, until the entire byte sequence
|
||||
* is transferred into the given buffers. As many bytes as possible are
|
||||
* transferred into each buffer, hence the final position of each updated
|
||||
* buffer, except the last updated buffer, is guaranteed to be equal to
|
||||
* that buffer's limit. The underlying operating system may impose a limit
|
||||
* on the number of buffers that may be used in an I/O operation. Where the
|
||||
* number of buffers (with bytes remaining), exceeds this limit, then the
|
||||
* I/O operation is performed with the maximum number of buffers allowed by
|
||||
* the operating system.
|
||||
*
|
||||
* <p> If a timeout is specified and the timeout elapses before the operation
|
||||
* completes then it completes with the exception {@link
|
||||
* InterruptedByTimeoutException}. Where a timeout occurs, and the
|
||||
* implementation cannot guarantee that bytes have not been read, or will not
|
||||
* be read from the channel into the given buffers, then further attempts to
|
||||
* read from the channel will cause an unspecific runtime exception to be
|
||||
* thrown.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param dsts
|
||||
* The buffers into which bytes are to be transferred
|
||||
* @param offset
|
||||
* The offset within the buffer array of the first buffer into which
|
||||
* bytes are to be transferred; must be non-negative and no larger than
|
||||
* {@code dsts.length}
|
||||
* @param length
|
||||
* The maximum number of buffers to be accessed; must be non-negative
|
||||
* and no larger than {@code dsts.length - offset}
|
||||
* @param timeout
|
||||
* The maximum time for the I/O operation to complete
|
||||
* @param unit
|
||||
* The time unit of the {@code timeout} argument
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* If the pre-conditions for the {@code offset} and {@code length}
|
||||
* parameter aren't met
|
||||
* @throws IllegalArgumentException
|
||||
* If the buffer is read-only
|
||||
* @throws ReadPendingException
|
||||
* If a read operation is already in progress on this channel
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
public abstract <A> void read(ByteBuffer[] dsts,
|
||||
int offset,
|
||||
int length,
|
||||
long timeout,
|
||||
TimeUnit unit,
|
||||
A attachment,
|
||||
CompletionHandler<Long,? super A> handler);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from the given buffer.
|
||||
*
|
||||
* <p> This method initiates an asynchronous write operation to write a
|
||||
* sequence of bytes to this channel from the given buffer. The {@code
|
||||
* handler} parameter is a completion handler that is invoked when the write
|
||||
* operation completes (or fails). The result passed to the completion
|
||||
* handler is the number of bytes written.
|
||||
*
|
||||
* <p> If a timeout is specified and the timeout elapses before the operation
|
||||
* completes then it completes with the exception {@link
|
||||
* InterruptedByTimeoutException}. Where a timeout occurs, and the
|
||||
* implementation cannot guarantee that bytes have not been written, or will
|
||||
* not be written to the channel from the given buffer, then further attempts
|
||||
* to write to the channel will cause an unspecific runtime exception to be
|
||||
* thrown.
|
||||
*
|
||||
* <p> Otherwise this method works in the same manner as the {@link
|
||||
* AsynchronousByteChannel#write(ByteBuffer,Object,CompletionHandler)}
|
||||
* method.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param src
|
||||
* The buffer from which bytes are to be retrieved
|
||||
* @param timeout
|
||||
* The maximum time for the I/O operation to complete
|
||||
* @param unit
|
||||
* The time unit of the {@code timeout} argument
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws WritePendingException
|
||||
* If a write operation is already in progress on this channel
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
public abstract <A> void write(ByteBuffer src,
|
||||
long timeout,
|
||||
TimeUnit unit,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler);
|
||||
|
||||
/**
|
||||
* @throws WritePendingException {@inheritDoc}
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
@Override
|
||||
public final <A> void write(ByteBuffer src,
|
||||
A attachment,
|
||||
CompletionHandler<Integer,? super A> handler)
|
||||
|
||||
{
|
||||
write(src, 0L, TimeUnit.MILLISECONDS, attachment, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WritePendingException {@inheritDoc}
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
*/
|
||||
@Override
|
||||
public abstract Future<Integer> write(ByteBuffer src);
|
||||
|
||||
/**
|
||||
* Writes a sequence of bytes to this channel from a subsequence of the given
|
||||
* buffers. This operation, sometimes called a <em>gathering write</em>, is
|
||||
* often useful when implementing network protocols that group data into
|
||||
* segments consisting of one or more fixed-length headers followed by a
|
||||
* variable-length body. The {@code handler} parameter is a completion
|
||||
* handler that is invoked when the write operation completes (or fails).
|
||||
* The result passed to the completion handler is the number of bytes written.
|
||||
*
|
||||
* <p> This method initiates a write of up to <i>r</i> bytes to this channel,
|
||||
* where <i>r</i> is the total number of bytes remaining in the specified
|
||||
* subsequence of the given buffer array, that is,
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* srcs[offset].remaining()
|
||||
* + srcs[offset+1].remaining()
|
||||
* + ... + srcs[offset+length-1].remaining()</pre></blockquote>
|
||||
*
|
||||
* at the moment that the write is attempted.
|
||||
*
|
||||
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
|
||||
* <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
|
||||
* Up to the first <tt>srcs[offset].remaining()</tt> bytes of this sequence
|
||||
* are written from buffer <tt>srcs[offset]</tt>, up to the next
|
||||
* <tt>srcs[offset+1].remaining()</tt> bytes are written from buffer
|
||||
* <tt>srcs[offset+1]</tt>, and so forth, until the entire byte sequence is
|
||||
* written. As many bytes as possible are written from each buffer, hence
|
||||
* the final position of each updated buffer, except the last updated
|
||||
* buffer, is guaranteed to be equal to that buffer's limit. The underlying
|
||||
* operating system may impose a limit on the number of buffers that may be
|
||||
* used in an I/O operation. Where the number of buffers (with bytes
|
||||
* remaining), exceeds this limit, then the I/O operation is performed with
|
||||
* the maximum number of buffers allowed by the operating system.
|
||||
*
|
||||
* <p> If a timeout is specified and the timeout elapses before the operation
|
||||
* completes then it completes with the exception {@link
|
||||
* InterruptedByTimeoutException}. Where a timeout occurs, and the
|
||||
* implementation cannot guarantee that bytes have not been written, or will
|
||||
* not be written to the channel from the given buffers, then further attempts
|
||||
* to write to the channel will cause an unspecific runtime exception to be
|
||||
* thrown.
|
||||
*
|
||||
* @param <A>
|
||||
* The type of the attachment
|
||||
* @param srcs
|
||||
* The buffers from which bytes are to be retrieved
|
||||
* @param offset
|
||||
* The offset within the buffer array of the first buffer from which
|
||||
* bytes are to be retrieved; must be non-negative and no larger
|
||||
* than {@code srcs.length}
|
||||
* @param length
|
||||
* The maximum number of buffers to be accessed; must be non-negative
|
||||
* and no larger than {@code srcs.length - offset}
|
||||
* @param timeout
|
||||
* The maximum time for the I/O operation to complete
|
||||
* @param unit
|
||||
* The time unit of the {@code timeout} argument
|
||||
* @param attachment
|
||||
* The object to attach to the I/O operation; can be {@code null}
|
||||
* @param handler
|
||||
* The handler for consuming the result
|
||||
*
|
||||
* @throws IndexOutOfBoundsException
|
||||
* If the pre-conditions for the {@code offset} and {@code length}
|
||||
* parameter aren't met
|
||||
* @throws WritePendingException
|
||||
* If a write operation is already in progress on this channel
|
||||
* @throws NotYetConnectedException
|
||||
* If this channel is not yet connected
|
||||
* @throws ShutdownChannelGroupException
|
||||
* If the channel group has terminated
|
||||
*/
|
||||
public abstract <A> void write(ByteBuffer[] srcs,
|
||||
int offset,
|
||||
int length,
|
||||
long timeout,
|
||||
TimeUnit unit,
|
||||
A attachment,
|
||||
CompletionHandler<Long,? super A> handler);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If there is a security manager set, its {@code checkConnect} method is
|
||||
* called with the local address and {@code -1} as its arguments to see
|
||||
* if the operation is allowed. If the operation is not allowed,
|
||||
* a {@code SocketAddress} representing the
|
||||
* {@link java.net.InetAddress#getLoopbackAddress loopback} address and the
|
||||
* local port of the channel's socket is returned.
|
||||
*
|
||||
* @return The {@code SocketAddress} that the socket is bound to, or the
|
||||
* {@code SocketAddress} representing the loopback address if
|
||||
* denied by the security manager, or {@code null} if the
|
||||
* channel's socket is not bound
|
||||
*
|
||||
* @throws ClosedChannelException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
*/
|
||||
public abstract SocketAddress getLocalAddress() throws IOException;
|
||||
}
|
||||
45
jdkSrc/jdk8/java/nio/channels/ByteChannel.java
Normal file
45
jdkSrc/jdk8/java/nio/channels/ByteChannel.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* A channel that can read and write bytes. This interface simply unifies
|
||||
* {@link ReadableByteChannel} and {@link WritableByteChannel}; it does not
|
||||
* specify any new operations.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public interface ByteChannel
|
||||
extends ReadableByteChannel, WritableByteChannel
|
||||
{
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/channels/CancelledKeyException.java
Normal file
51
jdkSrc/jdk8/java/nio/channels/CancelledKeyException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to use
|
||||
* a selection key that is no longer valid.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class CancelledKeyException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -8438032138028814268L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public CancelledKeyException() { }
|
||||
|
||||
}
|
||||
84
jdkSrc/jdk8/java/nio/channels/Channel.java
Normal file
84
jdkSrc/jdk8/java/nio/channels/Channel.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Closeable;
|
||||
|
||||
|
||||
/**
|
||||
* A nexus for I/O operations.
|
||||
*
|
||||
* <p> A channel represents an open connection to an entity such as a hardware
|
||||
* device, a file, a network socket, or a program component that is capable of
|
||||
* performing one or more distinct I/O operations, for example reading or
|
||||
* writing.
|
||||
*
|
||||
* <p> A channel is either open or closed. A channel is open upon creation,
|
||||
* and once closed it remains closed. Once a channel is closed, any attempt to
|
||||
* invoke an I/O operation upon it will cause a {@link ClosedChannelException}
|
||||
* to be thrown. Whether or not a channel is open may be tested by invoking
|
||||
* its {@link #isOpen isOpen} method.
|
||||
*
|
||||
* <p> Channels are, in general, intended to be safe for multithreaded access
|
||||
* as described in the specifications of the interfaces and classes that extend
|
||||
* and implement this interface.
|
||||
*
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public interface Channel extends Closeable {
|
||||
|
||||
/**
|
||||
* Tells whether or not this channel is open.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this channel is open
|
||||
*/
|
||||
public boolean isOpen();
|
||||
|
||||
/**
|
||||
* Closes this channel.
|
||||
*
|
||||
* <p> After a channel is closed, any further attempt to invoke I/O
|
||||
* operations upon it will cause a {@link ClosedChannelException} to be
|
||||
* thrown.
|
||||
*
|
||||
* <p> If this channel is already closed then invoking this method has no
|
||||
* effect.
|
||||
*
|
||||
* <p> This method may be invoked at any time. If some other thread has
|
||||
* already invoked it, however, then another invocation will block until
|
||||
* the first invocation is complete, after which it will return without
|
||||
* effect. </p>
|
||||
*
|
||||
* @throws IOException If an I/O error occurs
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
|
||||
}
|
||||
615
jdkSrc/jdk8/java/nio/channels/Channels.java
Normal file
615
jdkSrc/jdk8/java/nio/channels/Channels.java
Normal file
@@ -0,0 +1,615 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.nio.channels.spi.AbstractInterruptibleChannel;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import sun.nio.ch.ChannelInputStream;
|
||||
import sun.nio.cs.StreamDecoder;
|
||||
import sun.nio.cs.StreamEncoder;
|
||||
|
||||
|
||||
/**
|
||||
* Utility methods for channels and streams.
|
||||
*
|
||||
* <p> This class defines static methods that support the interoperation of the
|
||||
* stream classes of the <tt>{@link java.io}</tt> package with the channel
|
||||
* classes of this package. </p>
|
||||
*
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author Mike McCloskey
|
||||
* @author JSR-51 Expert Group
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public final class Channels {
|
||||
|
||||
private Channels() { } // No instantiation
|
||||
|
||||
private static void checkNotNull(Object o, String name) {
|
||||
if (o == null)
|
||||
throw new NullPointerException("\"" + name + "\" is null!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all remaining bytes in buffer to the given channel.
|
||||
* If the channel is selectable then it must be configured blocking.
|
||||
*/
|
||||
private static void writeFullyImpl(WritableByteChannel ch, ByteBuffer bb)
|
||||
throws IOException
|
||||
{
|
||||
while (bb.remaining() > 0) {
|
||||
int n = ch.write(bb);
|
||||
if (n <= 0)
|
||||
throw new RuntimeException("no bytes written");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all remaining bytes in buffer to the given channel.
|
||||
*
|
||||
* @throws IllegalBlockingModeException
|
||||
* If the channel is selectable and configured non-blocking.
|
||||
*/
|
||||
private static void writeFully(WritableByteChannel ch, ByteBuffer bb)
|
||||
throws IOException
|
||||
{
|
||||
if (ch instanceof SelectableChannel) {
|
||||
SelectableChannel sc = (SelectableChannel)ch;
|
||||
synchronized (sc.blockingLock()) {
|
||||
if (!sc.isBlocking())
|
||||
throw new IllegalBlockingModeException();
|
||||
writeFullyImpl(ch, bb);
|
||||
}
|
||||
} else {
|
||||
writeFullyImpl(ch, bb);
|
||||
}
|
||||
}
|
||||
|
||||
// -- Byte streams from channels --
|
||||
|
||||
/**
|
||||
* Constructs a stream that reads bytes from the given channel.
|
||||
*
|
||||
* <p> The <tt>read</tt> methods of the resulting stream will throw an
|
||||
* {@link IllegalBlockingModeException} if invoked while the underlying
|
||||
* channel is in non-blocking mode. The stream will not be buffered, and
|
||||
* it will not support the {@link InputStream#mark mark} or {@link
|
||||
* InputStream#reset reset} methods. The stream will be safe for access by
|
||||
* multiple concurrent threads. Closing the stream will in turn cause the
|
||||
* channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel from which bytes will be read
|
||||
*
|
||||
* @return A new input stream
|
||||
*/
|
||||
public static InputStream newInputStream(ReadableByteChannel ch) {
|
||||
checkNotNull(ch, "ch");
|
||||
return new sun.nio.ch.ChannelInputStream(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a stream that writes bytes to the given channel.
|
||||
*
|
||||
* <p> The <tt>write</tt> methods of the resulting stream will throw an
|
||||
* {@link IllegalBlockingModeException} if invoked while the underlying
|
||||
* channel is in non-blocking mode. The stream will not be buffered. The
|
||||
* stream will be safe for access by multiple concurrent threads. Closing
|
||||
* the stream will in turn cause the channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel to which bytes will be written
|
||||
*
|
||||
* @return A new output stream
|
||||
*/
|
||||
public static OutputStream newOutputStream(final WritableByteChannel ch) {
|
||||
checkNotNull(ch, "ch");
|
||||
|
||||
return new OutputStream() {
|
||||
|
||||
private ByteBuffer bb = null;
|
||||
private byte[] bs = null; // Invoker's previous array
|
||||
private byte[] b1 = null;
|
||||
|
||||
public synchronized void write(int b) throws IOException {
|
||||
if (b1 == null)
|
||||
b1 = new byte[1];
|
||||
b1[0] = (byte)b;
|
||||
this.write(b1);
|
||||
}
|
||||
|
||||
public synchronized void write(byte[] bs, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
if ((off < 0) || (off > bs.length) || (len < 0) ||
|
||||
((off + len) > bs.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
ByteBuffer bb = ((this.bs == bs)
|
||||
? this.bb
|
||||
: ByteBuffer.wrap(bs));
|
||||
bb.limit(Math.min(off + len, bb.capacity()));
|
||||
bb.position(off);
|
||||
this.bb = bb;
|
||||
this.bs = bs;
|
||||
Channels.writeFully(ch, bb);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
ch.close();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a stream that reads bytes from the given channel.
|
||||
*
|
||||
* <p> The stream will not be buffered, and it will not support the {@link
|
||||
* InputStream#mark mark} or {@link InputStream#reset reset} methods. The
|
||||
* stream will be safe for access by multiple concurrent threads. Closing
|
||||
* the stream will in turn cause the channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel from which bytes will be read
|
||||
*
|
||||
* @return A new input stream
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static InputStream newInputStream(final AsynchronousByteChannel ch) {
|
||||
checkNotNull(ch, "ch");
|
||||
return new InputStream() {
|
||||
|
||||
private ByteBuffer bb = null;
|
||||
private byte[] bs = null; // Invoker's previous array
|
||||
private byte[] b1 = null;
|
||||
|
||||
@Override
|
||||
public synchronized int read() throws IOException {
|
||||
if (b1 == null)
|
||||
b1 = new byte[1];
|
||||
int n = this.read(b1);
|
||||
if (n == 1)
|
||||
return b1[0] & 0xff;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int read(byte[] bs, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
if ((off < 0) || (off > bs.length) || (len < 0) ||
|
||||
((off + len) > bs.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0)
|
||||
return 0;
|
||||
|
||||
ByteBuffer bb = ((this.bs == bs)
|
||||
? this.bb
|
||||
: ByteBuffer.wrap(bs));
|
||||
bb.position(off);
|
||||
bb.limit(Math.min(off + len, bb.capacity()));
|
||||
this.bb = bb;
|
||||
this.bs = bs;
|
||||
|
||||
boolean interrupted = false;
|
||||
try {
|
||||
for (;;) {
|
||||
try {
|
||||
return ch.read(bb).get();
|
||||
} catch (ExecutionException ee) {
|
||||
throw new IOException(ee.getCause());
|
||||
} catch (InterruptedException ie) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (interrupted)
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
ch.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a stream that writes bytes to the given channel.
|
||||
*
|
||||
* <p> The stream will not be buffered. The stream will be safe for access
|
||||
* by multiple concurrent threads. Closing the stream will in turn cause
|
||||
* the channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel to which bytes will be written
|
||||
*
|
||||
* @return A new output stream
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static OutputStream newOutputStream(final AsynchronousByteChannel ch) {
|
||||
checkNotNull(ch, "ch");
|
||||
return new OutputStream() {
|
||||
|
||||
private ByteBuffer bb = null;
|
||||
private byte[] bs = null; // Invoker's previous array
|
||||
private byte[] b1 = null;
|
||||
|
||||
@Override
|
||||
public synchronized void write(int b) throws IOException {
|
||||
if (b1 == null)
|
||||
b1 = new byte[1];
|
||||
b1[0] = (byte)b;
|
||||
this.write(b1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void write(byte[] bs, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
if ((off < 0) || (off > bs.length) || (len < 0) ||
|
||||
((off + len) > bs.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
ByteBuffer bb = ((this.bs == bs)
|
||||
? this.bb
|
||||
: ByteBuffer.wrap(bs));
|
||||
bb.limit(Math.min(off + len, bb.capacity()));
|
||||
bb.position(off);
|
||||
this.bb = bb;
|
||||
this.bs = bs;
|
||||
|
||||
boolean interrupted = false;
|
||||
try {
|
||||
while (bb.remaining() > 0) {
|
||||
try {
|
||||
ch.write(bb).get();
|
||||
} catch (ExecutionException ee) {
|
||||
throw new IOException(ee.getCause());
|
||||
} catch (InterruptedException ie) {
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (interrupted)
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
ch.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// -- Channels from streams --
|
||||
|
||||
/**
|
||||
* Constructs a channel that reads bytes from the given stream.
|
||||
*
|
||||
* <p> The resulting channel will not be buffered; it will simply redirect
|
||||
* its I/O operations to the given stream. Closing the channel will in
|
||||
* turn cause the stream to be closed. </p>
|
||||
*
|
||||
* @param in
|
||||
* The stream from which bytes are to be read
|
||||
*
|
||||
* @return A new readable byte channel
|
||||
*/
|
||||
public static ReadableByteChannel newChannel(final InputStream in) {
|
||||
checkNotNull(in, "in");
|
||||
|
||||
if (in instanceof FileInputStream &&
|
||||
FileInputStream.class.equals(in.getClass())) {
|
||||
return ((FileInputStream)in).getChannel();
|
||||
}
|
||||
|
||||
return new ReadableByteChannelImpl(in);
|
||||
}
|
||||
|
||||
private static class ReadableByteChannelImpl
|
||||
extends AbstractInterruptibleChannel // Not really interruptible
|
||||
implements ReadableByteChannel
|
||||
{
|
||||
InputStream in;
|
||||
private static final int TRANSFER_SIZE = 8192;
|
||||
private byte buf[] = new byte[0];
|
||||
private boolean open = true;
|
||||
private Object readLock = new Object();
|
||||
|
||||
ReadableByteChannelImpl(InputStream in) {
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
public int read(ByteBuffer dst) throws IOException {
|
||||
int len = dst.remaining();
|
||||
int totalRead = 0;
|
||||
int bytesRead = 0;
|
||||
synchronized (readLock) {
|
||||
while (totalRead < len) {
|
||||
int bytesToRead = Math.min((len - totalRead),
|
||||
TRANSFER_SIZE);
|
||||
if (buf.length < bytesToRead)
|
||||
buf = new byte[bytesToRead];
|
||||
if ((totalRead > 0) && !(in.available() > 0))
|
||||
break; // block at most once
|
||||
try {
|
||||
begin();
|
||||
bytesRead = in.read(buf, 0, bytesToRead);
|
||||
} finally {
|
||||
end(bytesRead > 0);
|
||||
}
|
||||
if (bytesRead < 0)
|
||||
break;
|
||||
else
|
||||
totalRead += bytesRead;
|
||||
dst.put(buf, 0, bytesRead);
|
||||
}
|
||||
if ((bytesRead < 0) && (totalRead == 0))
|
||||
return -1;
|
||||
|
||||
return totalRead;
|
||||
}
|
||||
}
|
||||
|
||||
protected void implCloseChannel() throws IOException {
|
||||
in.close();
|
||||
open = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a channel that writes bytes to the given stream.
|
||||
*
|
||||
* <p> The resulting channel will not be buffered; it will simply redirect
|
||||
* its I/O operations to the given stream. Closing the channel will in
|
||||
* turn cause the stream to be closed. </p>
|
||||
*
|
||||
* @param out
|
||||
* The stream to which bytes are to be written
|
||||
*
|
||||
* @return A new writable byte channel
|
||||
*/
|
||||
public static WritableByteChannel newChannel(final OutputStream out) {
|
||||
checkNotNull(out, "out");
|
||||
|
||||
if (out instanceof FileOutputStream &&
|
||||
FileOutputStream.class.equals(out.getClass())) {
|
||||
return ((FileOutputStream)out).getChannel();
|
||||
}
|
||||
|
||||
return new WritableByteChannelImpl(out);
|
||||
}
|
||||
|
||||
private static class WritableByteChannelImpl
|
||||
extends AbstractInterruptibleChannel // Not really interruptible
|
||||
implements WritableByteChannel
|
||||
{
|
||||
OutputStream out;
|
||||
private static final int TRANSFER_SIZE = 8192;
|
||||
private byte buf[] = new byte[0];
|
||||
private boolean open = true;
|
||||
private Object writeLock = new Object();
|
||||
|
||||
WritableByteChannelImpl(OutputStream out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
int len = src.remaining();
|
||||
int totalWritten = 0;
|
||||
synchronized (writeLock) {
|
||||
while (totalWritten < len) {
|
||||
int bytesToWrite = Math.min((len - totalWritten),
|
||||
TRANSFER_SIZE);
|
||||
if (buf.length < bytesToWrite)
|
||||
buf = new byte[bytesToWrite];
|
||||
src.get(buf, 0, bytesToWrite);
|
||||
try {
|
||||
begin();
|
||||
out.write(buf, 0, bytesToWrite);
|
||||
} finally {
|
||||
end(bytesToWrite > 0);
|
||||
}
|
||||
totalWritten += bytesToWrite;
|
||||
}
|
||||
return totalWritten;
|
||||
}
|
||||
}
|
||||
|
||||
protected void implCloseChannel() throws IOException {
|
||||
out.close();
|
||||
open = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- Character streams from channels --
|
||||
|
||||
/**
|
||||
* Constructs a reader that decodes bytes from the given channel using the
|
||||
* given decoder.
|
||||
*
|
||||
* <p> The resulting stream will contain an internal input buffer of at
|
||||
* least <tt>minBufferCap</tt> bytes. The stream's <tt>read</tt> methods
|
||||
* will, as needed, fill the buffer by reading bytes from the underlying
|
||||
* channel; if the channel is in non-blocking mode when bytes are to be
|
||||
* read then an {@link IllegalBlockingModeException} will be thrown. The
|
||||
* resulting stream will not otherwise be buffered, and it will not support
|
||||
* the {@link Reader#mark mark} or {@link Reader#reset reset} methods.
|
||||
* Closing the stream will in turn cause the channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel from which bytes will be read
|
||||
*
|
||||
* @param dec
|
||||
* The charset decoder to be used
|
||||
*
|
||||
* @param minBufferCap
|
||||
* The minimum capacity of the internal byte buffer,
|
||||
* or <tt>-1</tt> if an implementation-dependent
|
||||
* default capacity is to be used
|
||||
*
|
||||
* @return A new reader
|
||||
*/
|
||||
public static Reader newReader(ReadableByteChannel ch,
|
||||
CharsetDecoder dec,
|
||||
int minBufferCap)
|
||||
{
|
||||
checkNotNull(ch, "ch");
|
||||
return StreamDecoder.forDecoder(ch, dec.reset(), minBufferCap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a reader that decodes bytes from the given channel according
|
||||
* to the named charset.
|
||||
*
|
||||
* <p> An invocation of this method of the form
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Channels.newReader(ch, csname)</pre></blockquote>
|
||||
*
|
||||
* behaves in exactly the same way as the expression
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Channels.newReader(ch,
|
||||
* Charset.forName(csName)
|
||||
* .newDecoder(),
|
||||
* -1);</pre></blockquote>
|
||||
*
|
||||
* @param ch
|
||||
* The channel from which bytes will be read
|
||||
*
|
||||
* @param csName
|
||||
* The name of the charset to be used
|
||||
*
|
||||
* @return A new reader
|
||||
*
|
||||
* @throws UnsupportedCharsetException
|
||||
* If no support for the named charset is available
|
||||
* in this instance of the Java virtual machine
|
||||
*/
|
||||
public static Reader newReader(ReadableByteChannel ch,
|
||||
String csName)
|
||||
{
|
||||
checkNotNull(csName, "csName");
|
||||
return newReader(ch, Charset.forName(csName).newDecoder(), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a writer that encodes characters using the given encoder and
|
||||
* writes the resulting bytes to the given channel.
|
||||
*
|
||||
* <p> The resulting stream will contain an internal output buffer of at
|
||||
* least <tt>minBufferCap</tt> bytes. The stream's <tt>write</tt> methods
|
||||
* will, as needed, flush the buffer by writing bytes to the underlying
|
||||
* channel; if the channel is in non-blocking mode when bytes are to be
|
||||
* written then an {@link IllegalBlockingModeException} will be thrown.
|
||||
* The resulting stream will not otherwise be buffered. Closing the stream
|
||||
* will in turn cause the channel to be closed. </p>
|
||||
*
|
||||
* @param ch
|
||||
* The channel to which bytes will be written
|
||||
*
|
||||
* @param enc
|
||||
* The charset encoder to be used
|
||||
*
|
||||
* @param minBufferCap
|
||||
* The minimum capacity of the internal byte buffer,
|
||||
* or <tt>-1</tt> if an implementation-dependent
|
||||
* default capacity is to be used
|
||||
*
|
||||
* @return A new writer
|
||||
*/
|
||||
public static Writer newWriter(final WritableByteChannel ch,
|
||||
final CharsetEncoder enc,
|
||||
final int minBufferCap)
|
||||
{
|
||||
checkNotNull(ch, "ch");
|
||||
return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a writer that encodes characters according to the named
|
||||
* charset and writes the resulting bytes to the given channel.
|
||||
*
|
||||
* <p> An invocation of this method of the form
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Channels.newWriter(ch, csname)</pre></blockquote>
|
||||
*
|
||||
* behaves in exactly the same way as the expression
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Channels.newWriter(ch,
|
||||
* Charset.forName(csName)
|
||||
* .newEncoder(),
|
||||
* -1);</pre></blockquote>
|
||||
*
|
||||
* @param ch
|
||||
* The channel to which bytes will be written
|
||||
*
|
||||
* @param csName
|
||||
* The name of the charset to be used
|
||||
*
|
||||
* @return A new writer
|
||||
*
|
||||
* @throws UnsupportedCharsetException
|
||||
* If no support for the named charset is available
|
||||
* in this instance of the Java virtual machine
|
||||
*/
|
||||
public static Writer newWriter(WritableByteChannel ch,
|
||||
String csName)
|
||||
{
|
||||
checkNotNull(csName, "csName");
|
||||
return newWriter(ch, Charset.forName(csName).newEncoder(), -1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Checked exception received by a thread when another thread interrupts it
|
||||
* while it is blocked in an I/O operation upon a channel. Before this
|
||||
* exception is thrown the channel will have been closed and the interrupt
|
||||
* status of the previously-blocked thread will have been set.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class ClosedByInterruptException
|
||||
extends AsynchronousCloseException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -4488191543534286750L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public ClosedByInterruptException() { }
|
||||
|
||||
}
|
||||
54
jdkSrc/jdk8/java/nio/channels/ClosedChannelException.java
Normal file
54
jdkSrc/jdk8/java/nio/channels/ClosedChannelException.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Checked exception thrown when an attempt is made to invoke or complete an
|
||||
* I/O operation upon channel that is closed, or at least closed to that
|
||||
* operation. That this exception is thrown does not necessarily imply that
|
||||
* the channel is completely closed. A socket channel whose write half has
|
||||
* been shut down, for example, may still be open for reading.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class ClosedChannelException
|
||||
extends java.io.IOException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 882777185433553857L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public ClosedChannelException() { }
|
||||
|
||||
}
|
||||
51
jdkSrc/jdk8/java/nio/channels/ClosedSelectorException.java
Normal file
51
jdkSrc/jdk8/java/nio/channels/ClosedSelectorException.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to invoke an I/O
|
||||
* operation upon a closed selector.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class ClosedSelectorException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 6466297122317847835L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public ClosedSelectorException() { }
|
||||
|
||||
}
|
||||
66
jdkSrc/jdk8/java/nio/channels/CompletionHandler.java
Normal file
66
jdkSrc/jdk8/java/nio/channels/CompletionHandler.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
/**
|
||||
* A handler for consuming the result of an asynchronous I/O operation.
|
||||
*
|
||||
* <p> The asynchronous channels defined in this package allow a completion
|
||||
* handler to be specified to consume the result of an asynchronous operation.
|
||||
* The {@link #completed completed} method is invoked when the I/O operation
|
||||
* completes successfully. The {@link #failed failed} method is invoked if the
|
||||
* I/O operations fails. The implementations of these methods should complete
|
||||
* in a timely manner so as to avoid keeping the invoking thread from dispatching
|
||||
* to other completion handlers.
|
||||
*
|
||||
* @param <V> The result type of the I/O operation
|
||||
* @param <A> The type of the object attached to the I/O operation
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public interface CompletionHandler<V,A> {
|
||||
|
||||
/**
|
||||
* Invoked when an operation has completed.
|
||||
*
|
||||
* @param result
|
||||
* The result of the I/O operation.
|
||||
* @param attachment
|
||||
* The object attached to the I/O operation when it was initiated.
|
||||
*/
|
||||
void completed(V result, A attachment);
|
||||
|
||||
/**
|
||||
* Invoked when an operation fails.
|
||||
*
|
||||
* @param exc
|
||||
* The exception to indicate why the I/O operation failed
|
||||
* @param attachment
|
||||
* The object attached to the I/O operation when it was initiated.
|
||||
*/
|
||||
void failed(Throwable exc, A attachment);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package java.nio.channels;
|
||||
|
||||
|
||||
/**
|
||||
* Unchecked exception thrown when an attempt is made to connect a {@link
|
||||
* SocketChannel} for which a non-blocking connection operation is already in
|
||||
* progress.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class ConnectionPendingException
|
||||
extends IllegalStateException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 2008393366501760879L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*/
|
||||
public ConnectionPendingException() { }
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user