summaryrefslogtreecommitdiffstats
path: root/nio/src/main/java
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2009-10-15 15:01:39 -0700
committerJesse Wilson <jessewilson@google.com>2009-10-16 12:09:52 -0700
commiteaa2ff09069424b0f7a95c7cd831cef1b744fe67 (patch)
treef18757348712cfbce81a3b22301c21aee2af8255 /nio/src/main/java
parentbe13bf181738e1bd6d98d6f226c813a517c27f65 (diff)
downloadlibcore-eaa2ff09069424b0f7a95c7cd831cef1b744fe67.zip
libcore-eaa2ff09069424b0f7a95c7cd831cef1b744fe67.tar.gz
libcore-eaa2ff09069424b0f7a95c7cd831cef1b744fe67.tar.bz2
Update NIO and NIO char packages to Harmony 802921.
Notable changes: - We don't use Harmony's new indexing for SelectorImpl. See the long bug thread on Harmony's site, https://issues.apache.org/jira/browse/HARMONY-6312 This patch includes the latest Harmony changes to SelectorImpl, which have been optimized since this patch was first created. - Several uses of StringBuffer updated to use StringBuilder - CharBuffer.read implementation changes - Additional checking in CharsetEncoder - Some inner classes made static - Harmony changed their Charset impl from ICU to Java. We're sticking with ICU. - Harmony added support for epoll. We're sticking with standard 'poll'. commit 2ed6cb602a52f4681afbf1348928f1b0c36d914d Merge: 8a74fca bcc5ec7 Author: Jesse Wilson <jessewilson@google.com> Date: Fri Aug 14 15:14:10 2009 -0700 Merge branch 'nio_802921' into nio_dalvik Conflicts: libcore/nio/.classpath libcore/nio/META-INF/MANIFEST.MF libcore/nio/build.xml libcore/nio/make/exclude.linux.x86.drl libcore/nio/make/exclude.linux.x86.ibm libcore/nio/make/exclude.linux.x86_64.drl libcore/nio/src/main/java/java/nio/BaseByteBuffer.java libcore/nio/src/main/java/java/nio/Buffer.java libcore/nio/src/main/java/java/nio/BufferOverflowException.java libcore/nio/src/main/java/java/nio/BufferUnderflowException.java libcore/nio/src/main/java/java/nio/ByteBuffer.java libcore/nio/src/main/java/java/nio/ByteOrder.java libcore/nio/src/main/java/java/nio/CharArrayBuffer.java libcore/nio/src/main/java/java/nio/CharBuffer.java libcore/nio/src/main/java/java/nio/CharSequenceAdapter.java libcore/nio/src/main/java/java/nio/CharToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/DirectByteBuffer.java libcore/nio/src/main/java/java/nio/DirectByteBuffers.java libcore/nio/src/main/java/java/nio/DoubleArrayBuffer.java libcore/nio/src/main/java/java/nio/DoubleBuffer.java libcore/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/FloatArrayBuffer.java libcore/nio/src/main/java/java/nio/FloatBuffer.java libcore/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/HeapByteBuffer.java libcore/nio/src/main/java/java/nio/IntArrayBuffer.java libcore/nio/src/main/java/java/nio/IntBuffer.java libcore/nio/src/main/java/java/nio/IntToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/InvalidMarkException.java libcore/nio/src/main/java/java/nio/LongArrayBuffer.java libcore/nio/src/main/java/java/nio/LongBuffer.java libcore/nio/src/main/java/java/nio/LongToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/MappedByteBuffer.java libcore/nio/src/main/java/java/nio/MappedByteBufferAdapter.java libcore/nio/src/main/java/java/nio/ReadOnlyBufferException.java libcore/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java libcore/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java libcore/nio/src/main/java/java/nio/ShortArrayBuffer.java libcore/nio/src/main/java/java/nio/ShortBuffer.java libcore/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java libcore/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java libcore/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java libcore/nio/src/main/java/java/nio/channels/ByteChannel.java libcore/nio/src/main/java/java/nio/channels/CancelledKeyException.java libcore/nio/src/main/java/java/nio/channels/Channel.java libcore/nio/src/main/java/java/nio/channels/Channels.java libcore/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java libcore/nio/src/main/java/java/nio/channels/ClosedChannelException.java libcore/nio/src/main/java/java/nio/channels/ClosedSelectorException.java libcore/nio/src/main/java/java/nio/channels/ConnectionPendingException.java libcore/nio/src/main/java/java/nio/channels/DatagramChannel.java libcore/nio/src/main/java/java/nio/channels/FileChannel.java libcore/nio/src/main/java/java/nio/channels/FileLock.java libcore/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java libcore/nio/src/main/java/java/nio/channels/GatheringByteChannel.java libcore/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java libcore/nio/src/main/java/java/nio/channels/IllegalSelectorException.java libcore/nio/src/main/java/java/nio/channels/InterruptibleChannel.java libcore/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java libcore/nio/src/main/java/java/nio/channels/NonReadableChannelException.java libcore/nio/src/main/java/java/nio/channels/NonWritableChannelException.java libcore/nio/src/main/java/java/nio/channels/NotYetBoundException.java libcore/nio/src/main/java/java/nio/channels/NotYetConnectedException.java libcore/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java libcore/nio/src/main/java/java/nio/channels/Pipe.java libcore/nio/src/main/java/java/nio/channels/ReadableByteChannel.java libcore/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java libcore/nio/src/main/java/java/nio/channels/SelectableChannel.java libcore/nio/src/main/java/java/nio/channels/SelectionKey.java libcore/nio/src/main/java/java/nio/channels/Selector.java libcore/nio/src/main/java/java/nio/channels/ServerSocketChannel.java libcore/nio/src/main/java/java/nio/channels/SocketChannel.java libcore/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java libcore/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java libcore/nio/src/main/java/java/nio/channels/WritableByteChannel.java libcore/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java libcore/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java libcore/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java libcore/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java libcore/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/ReadWriteFileChannel.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java libcore/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java libcore/nio/src/main/native/nio/shared/DirectBufferUtil.c libcore/nio/src/main/native/nio/unix/exports.txt libcore/nio/src/main/native/nio/unix/makefile libcore/nio/src/main/native/nio/windows/makefile libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferOverflowExceptionTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/BufferUnderflowExceptionTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/CharBufferTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/FloatBufferTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/InvalidMarkExceptionTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/MappedByteBufferTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/ReadOnlyBufferExceptionTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/DatagramChannelTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelLockingTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileChannelWin32OnlyTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/FileLockTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/ServerSocketChannelTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java libcore/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/spi/AbstractSelectableChannelTest.java libcore/nio_char/.classpath libcore/nio_char/META-INF/MANIFEST.MF libcore/nio_char/build.xml libcore/nio_char/src/main/java/java/nio/charset/CharacterCodingException.java libcore/nio_char/src/main/java/java/nio/charset/Charset.java libcore/nio_char/src/main/java/java/nio/charset/CharsetDecoder.java libcore/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java libcore/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java libcore/nio_char/src/main/java/java/nio/charset/CoderResult.java libcore/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java libcore/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java libcore/nio_char/src/main/java/java/nio/charset/MalformedInputException.java libcore/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java libcore/nio_char/src/main/java/java/nio/charset/UnsupportedCharsetException.java libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetDecoderTest.java libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetEncoderTest.java libcore/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetProviderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetEncoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetEncoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java libcore/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetEncoderTest.java commit 8a74fca0d85c82a9d02a83d00fd028d9b09755f7 Author: Jesse Wilson <jessewilson@google.com> Date: Thu Aug 13 16:03:25 2009 -0700 Dalvik Nio, Nio char commit bcc5ec78806787fbecab742e716fc0d63bcece5c Author: Jesse Wilson <jessewilson@google.com> Date: Thu Aug 13 16:01:06 2009 -0700 Nio, nio char 802921 commit fc1e09e74aec8e49e0e23f13643deed1e9112af4 Author: Jesse Wilson <jessewilson@google.com> Date: Thu Aug 13 15:48:17 2009 -0700 Nio, nio char 527399
Diffstat (limited to 'nio/src/main/java')
-rw-r--r--nio/src/main/java/java/nio/BaseByteBuffer.java12
-rw-r--r--nio/src/main/java/java/nio/Buffer.java38
-rw-r--r--nio/src/main/java/java/nio/BufferFactory.java2
-rw-r--r--nio/src/main/java/java/nio/BufferOverflowException.java5
-rw-r--r--nio/src/main/java/java/nio/BufferUnderflowException.java5
-rw-r--r--nio/src/main/java/java/nio/ByteBuffer.java213
-rw-r--r--nio/src/main/java/java/nio/ByteOrder.java10
-rw-r--r--nio/src/main/java/java/nio/CharArrayBuffer.java15
-rw-r--r--nio/src/main/java/java/nio/CharBuffer.java163
-rw-r--r--nio/src/main/java/java/nio/CharSequenceAdapter.java33
-rw-r--r--nio/src/main/java/java/nio/CharToByteBufferAdapter.java68
-rw-r--r--nio/src/main/java/java/nio/DirectByteBuffer.java59
-rw-r--r--nio/src/main/java/java/nio/DirectByteBuffers.java9
-rw-r--r--nio/src/main/java/java/nio/DoubleArrayBuffer.java14
-rw-r--r--nio/src/main/java/java/nio/DoubleBuffer.java95
-rw-r--r--nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java66
-rw-r--r--nio/src/main/java/java/nio/FloatArrayBuffer.java11
-rw-r--r--nio/src/main/java/java/nio/FloatBuffer.java97
-rw-r--r--nio/src/main/java/java/nio/FloatToByteBufferAdapter.java64
-rw-r--r--nio/src/main/java/java/nio/HeapByteBuffer.java42
-rw-r--r--nio/src/main/java/java/nio/IntArrayBuffer.java15
-rw-r--r--nio/src/main/java/java/nio/IntBuffer.java94
-rw-r--r--nio/src/main/java/java/nio/IntToByteBufferAdapter.java63
-rw-r--r--nio/src/main/java/java/nio/InvalidMarkException.java5
-rw-r--r--nio/src/main/java/java/nio/LongArrayBuffer.java11
-rw-r--r--nio/src/main/java/java/nio/LongBuffer.java97
-rw-r--r--nio/src/main/java/java/nio/LongToByteBufferAdapter.java65
-rw-r--r--nio/src/main/java/java/nio/MappedByteBuffer.java35
-rw-r--r--nio/src/main/java/java/nio/MappedByteBufferAdapter.java54
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyBufferException.java5
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java18
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java25
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java16
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java16
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java26
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java16
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java16
-rw-r--r--nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java16
-rw-r--r--nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java17
-rw-r--r--nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java48
-rw-r--r--nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java18
-rw-r--r--nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java18
-rw-r--r--nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java36
-rw-r--r--nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java18
-rw-r--r--nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java18
-rw-r--r--nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java17
-rw-r--r--nio/src/main/java/java/nio/ShortArrayBuffer.java12
-rw-r--r--nio/src/main/java/java/nio/ShortBuffer.java95
-rw-r--r--nio/src/main/java/java/nio/ShortToByteBufferAdapter.java67
-rw-r--r--nio/src/main/java/java/nio/channels/AlreadyConnectedException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/AsynchronousCloseException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/ByteChannel.java5
-rw-r--r--nio/src/main/java/java/nio/channels/CancelledKeyException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/Channel.java11
-rw-r--r--nio/src/main/java/java/nio/channels/Channels.java144
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedByInterruptException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedChannelException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/ClosedSelectorException.java9
-rw-r--r--nio/src/main/java/java/nio/channels/ConnectionPendingException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/DatagramChannel.java54
-rw-r--r--nio/src/main/java/java/nio/channels/FileChannel.java129
-rw-r--r--nio/src/main/java/java/nio/channels/FileLock.java30
-rw-r--r--nio/src/main/java/java/nio/channels/FileLockInterruptionException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/GatheringByteChannel.java21
-rw-r--r--nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/IllegalSelectorException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/InterruptibleChannel.java7
-rw-r--r--nio/src/main/java/java/nio/channels/NoConnectionPendingException.java11
-rw-r--r--nio/src/main/java/java/nio/channels/NonReadableChannelException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/NonWritableChannelException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/NotYetBoundException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/NotYetConnectedException.java6
-rw-r--r--nio/src/main/java/java/nio/channels/OverlappingFileLockException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/Pipe.java14
-rw-r--r--nio/src/main/java/java/nio/channels/ReadableByteChannel.java12
-rw-r--r--nio/src/main/java/java/nio/channels/ScatteringByteChannel.java23
-rw-r--r--nio/src/main/java/java/nio/channels/SelectableChannel.java26
-rw-r--r--nio/src/main/java/java/nio/channels/SelectionKey.java30
-rw-r--r--nio/src/main/java/java/nio/channels/Selector.java21
-rw-r--r--nio/src/main/java/java/nio/channels/ServerSocketChannel.java15
-rw-r--r--nio/src/main/java/java/nio/channels/SocketChannel.java84
-rw-r--r--nio/src/main/java/java/nio/channels/UnresolvedAddressException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java5
-rw-r--r--nio/src/main/java/java/nio/channels/WritableByteChannel.java9
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java23
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java53
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java14
-rw-r--r--nio/src/main/java/java/nio/channels/spi/AbstractSelector.java29
-rw-r--r--nio/src/main/java/java/nio/channels/spi/SelectorProvider.java38
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/AddressUtil.java30
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java31
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java13
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java4
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java69
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java26
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java22
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java16
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java6
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java6
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java48
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java362
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java18
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java12
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java3
-rw-r--r--nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java12
105 files changed, 1535 insertions, 2020 deletions
diff --git a/nio/src/main/java/java/nio/BaseByteBuffer.java b/nio/src/main/java/java/nio/BaseByteBuffer.java
index 009bcb7..a4acc08 100644
--- a/nio/src/main/java/java/nio/BaseByteBuffer.java
+++ b/nio/src/main/java/java/nio/BaseByteBuffer.java
@@ -16,11 +16,9 @@
package java.nio;
-
/**
* Serves as the root of other byte buffer impl classes, implements common
* methods that can be shared by child classes.
- *
*/
abstract class BaseByteBuffer extends ByteBuffer {
@@ -28,42 +26,52 @@ abstract class BaseByteBuffer extends ByteBuffer {
super(capacity);
}
+ @Override
public final CharBuffer asCharBuffer() {
return CharToByteBufferAdapter.wrap(this);
}
+ @Override
public final DoubleBuffer asDoubleBuffer() {
return DoubleToByteBufferAdapter.wrap(this);
}
+ @Override
public final FloatBuffer asFloatBuffer() {
return FloatToByteBufferAdapter.wrap(this);
}
+ @Override
public final IntBuffer asIntBuffer() {
return IntToByteBufferAdapter.wrap(this);
}
+ @Override
public final LongBuffer asLongBuffer() {
return LongToByteBufferAdapter.wrap(this);
}
+ @Override
public final ShortBuffer asShortBuffer() {
return ShortToByteBufferAdapter.wrap(this);
}
+ @Override
public final char getChar() {
return (char) getShort();
}
+ @Override
public final char getChar(int index) {
return (char) getShort(index);
}
+ @Override
public final ByteBuffer putChar(char value) {
return putShort((short) value);
}
+ @Override
public final ByteBuffer putChar(int index, char value) {
return putShort(index, (short) value);
}
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java
index 19d8969..b4bdc1c 100644
--- a/nio/src/main/java/java/nio/Buffer.java
+++ b/nio/src/main/java/java/nio/Buffer.java
@@ -16,7 +16,6 @@
package java.nio;
-
/**
* A buffer is a list of elements of a specific primitive type.
* <p>
@@ -40,14 +39,10 @@ package java.nio;
* take advantage of native memory APIs and it may not stay in the Java heap,
* thus it is not affected by garbage collection.</li>
* </ul>
- * </p>
* <p>
* Buffers are not thread-safe. If concurrent access to a buffer instance is
* required, then the callers are responsible to take care of the
* synchronization issues.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class Buffer {
@@ -125,9 +120,9 @@ public abstract class Buffer {
/**
* Construct a buffer with the specified capacity.
- *
+ *
* @param capacity
- * the capacity of this buffer.
+ * The capacity of this buffer
*/
Buffer(int capacity) {
super();
@@ -141,7 +136,6 @@ public abstract class Buffer {
* Returns the capacity of this buffer.
*
* @return the number of elements that are contained in this buffer.
- * @since Android 1.0
*/
public final int capacity() {
return capacity;
@@ -154,10 +148,8 @@ public abstract class Buffer {
* changes take place: the current position is reset back to the start of
* the buffer, the value of the buffer limit is made equal to the capacity
* and mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
- * @since Android 1.0
*/
public final Buffer clear() {
position = 0;
@@ -171,13 +163,10 @@ public abstract class Buffer {
* <p>
* The limit is set to the current position, then the position is set to
* zero, and the mark is cleared.
- * </p>
* <p>
* The content of this buffer is not changed.
- * </p>
- *
+ *
* @return this buffer.
- * @since Android 1.0
*/
public final Buffer flip() {
limit = position;
@@ -192,7 +181,6 @@ public abstract class Buffer {
*
* @return {@code true} if there are elements remaining in this buffer,
* {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasRemaining() {
return position < limit;
@@ -203,7 +191,6 @@ public abstract class Buffer {
*
* @return {@code true} if this buffer is read-only, {@code false}
* otherwise.
- * @since Android 1.0
*/
public abstract boolean isReadOnly();
@@ -211,7 +198,6 @@ public abstract class Buffer {
* Returns the limit of this buffer.
*
* @return the limit of this buffer.
- * @since Android 1.0
*/
public final int limit() {
return limit;
@@ -224,15 +210,13 @@ public abstract class Buffer {
* <code>newLimit</code> then, on returning from this call, it will have
* been adjusted to be equivalent to <code>newLimit</code>. If the mark
* is set and is greater than the new limit, then it is cleared.
- * </p>
- *
+ *
* @param newLimit
* the new limit, must not be negative and not greater than
* capacity.
* @return this buffer.
* @exception IllegalArgumentException
* if <code>newLimit</code> is invalid.
- * @since Android 1.0
*/
public final Buffer limit(int newLimit) {
if (newLimit < 0 || newLimit > capacity) {
@@ -254,7 +238,6 @@ public abstract class Buffer {
* later by calling <code>reset()</code>.
*
* @return this buffer.
- * @since Android 1.0
*/
public final Buffer mark() {
mark = position;
@@ -265,7 +248,6 @@ public abstract class Buffer {
* Returns the position of this buffer.
*
* @return the value of this buffer's current position.
- * @since Android 1.0
*/
public final int position() {
return position;
@@ -276,15 +258,13 @@ public abstract class Buffer {
* <p>
* If the mark is set and it is greater than the new position, then it is
* cleared.
- * </p>
- *
+ *
* @param newPosition
* the new position, must be not negative and not greater than
* limit.
* @return this buffer.
* @exception IllegalArgumentException
* if <code>newPosition</code> is invalid.
- * @since Android 1.0
*/
public final Buffer position(int newPosition) {
if (newPosition < 0 || newPosition > limit) {
@@ -303,7 +283,6 @@ public abstract class Buffer {
* {@code limit - position}.
*
* @return the number of remaining elements in this buffer.
- * @since Android 1.0
*/
public final int remaining() {
return limit - position;
@@ -315,7 +294,6 @@ public abstract class Buffer {
* @return this buffer.
* @exception InvalidMarkException
* if the mark is not set.
- * @since Android 1.0
*/
public final Buffer reset() {
if (mark == UNSET_MARK) {
@@ -330,10 +308,8 @@ public abstract class Buffer {
* <p>
* The position is set to zero, and the mark is cleared. The content of this
* buffer is not changed.
- * </p>
- *
+ *
* @return this buffer.
- * @since Android 1.0
*/
public final Buffer rewind() {
position = 0;
diff --git a/nio/src/main/java/java/nio/BufferFactory.java b/nio/src/main/java/java/nio/BufferFactory.java
index acb2400..94f23ed 100644
--- a/nio/src/main/java/java/nio/BufferFactory.java
+++ b/nio/src/main/java/java/nio/BufferFactory.java
@@ -17,7 +17,6 @@
package java.nio;
-
/**
* Provide factory service of buffer classes.
* <p>
@@ -25,7 +24,6 @@ package java.nio;
* this factory is the only entrance to access buffer functions from outside of
* the impl package.
* </p>
- *
*/
final class BufferFactory {
diff --git a/nio/src/main/java/java/nio/BufferOverflowException.java b/nio/src/main/java/java/nio/BufferOverflowException.java
index a9ec60d..a1f7792 100644
--- a/nio/src/main/java/java/nio/BufferOverflowException.java
+++ b/nio/src/main/java/java/nio/BufferOverflowException.java
@@ -16,12 +16,9 @@
package java.nio;
-
/**
* A <code>BufferOverflowException</code> is thrown when elements are written
* to a buffer but there is not enough remaining space in the buffer.
- *
- * @since Android 1.0
*/
public class BufferOverflowException extends RuntimeException {
@@ -29,8 +26,6 @@ public class BufferOverflowException extends RuntimeException {
/**
* Constructs a <code>BufferOverflowException</code>.
- *
- * @since Android 1.0
*/
public BufferOverflowException() {
super();
diff --git a/nio/src/main/java/java/nio/BufferUnderflowException.java b/nio/src/main/java/java/nio/BufferUnderflowException.java
index f15a8db..14d413b 100644
--- a/nio/src/main/java/java/nio/BufferUnderflowException.java
+++ b/nio/src/main/java/java/nio/BufferUnderflowException.java
@@ -16,12 +16,9 @@
package java.nio;
-
/**
* A <code>BufferUnderflowException</code> is thrown when elements are read
* from a buffer but there are not enough remaining elements in the buffer.
- *
- * @since Android 1.0
*/
public class BufferUnderflowException extends RuntimeException {
@@ -29,8 +26,6 @@ public class BufferUnderflowException extends RuntimeException {
/**
* Constructs a <code>BufferUnderflowException</code>.
- *
- * @since Android 1.0
*/
public BufferUnderflowException() {
super();
diff --git a/nio/src/main/java/java/nio/ByteBuffer.java b/nio/src/main/java/java/nio/ByteBuffer.java
index a033298..821bbed 100644
--- a/nio/src/main/java/java/nio/ByteBuffer.java
+++ b/nio/src/main/java/java/nio/ByteBuffer.java
@@ -17,14 +17,12 @@
package java.nio;
-
import org.apache.harmony.luni.platform.Endianness;
/**
* A buffer for bytes.
* <p>
* A byte buffer can be created in either one of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new byte array and create a buffer
* based on it;</li>
@@ -33,9 +31,10 @@ import org.apache.harmony.luni.platform.Endianness;
* <li>{@link #wrap(byte[]) Wrap} an existing byte array to create a new
* buffer.</li>
* </ul>
- * @since Android 1.0
+ *
*/
-public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer> {
+public abstract class ByteBuffer extends Buffer implements
+ Comparable<ByteBuffer> {
/**
* Creates a byte buffer based on a newly allocated byte array.
@@ -45,7 +44,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the created byte buffer.
* @throws IllegalArgumentException
* if {@code capacity < 0}.
- * @since Android 1.0
*/
public static ByteBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -62,7 +60,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the created byte buffer.
* @throws IllegalArgumentException
* if {@code capacity < 0}.
- * @since Android 1.0
*/
public static ByteBuffer allocateDirect(int capacity) {
if (capacity < 0) {
@@ -76,12 +73,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the byte array which the new buffer will be based on
* @return the created byte buffer.
- * @since Android 1.0
*/
public static ByteBuffer wrap(byte[] array) {
return BufferFactory.newByteBuffer(array);
@@ -92,8 +87,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the byte array which the new buffer will be based on.
* @param start
@@ -105,7 +99,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the created byte buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static ByteBuffer wrap(byte[] array, int start, int len) {
int length = array.length;
@@ -130,7 +123,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
*
* @param capacity
* the capacity of the buffer.
- * @since Android 1.0
*/
ByteBuffer(int capacity) {
super(capacity);
@@ -147,7 +139,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if this buffer is based on a read-only array.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final byte[] array() {
return protectedArray();
@@ -159,21 +150,19 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The offset is the index of the array which corresponds to the zero
* position of the buffer.
- * </p>
- *
+ *
* @return the offset of the byte array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on a read-only array.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override
+ @Override
Object _array() {
if (hasArray()) {
return array();
@@ -181,7 +170,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
return null;
}
- @Override
+ @Override
int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
@@ -198,15 +187,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by two, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a char buffer which is based on the content of this byte buffer.
- * @since Android 1.0
*/
public abstract CharBuffer asCharBuffer();
@@ -218,16 +204,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by eight, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a double buffer which is based on the content of this byte
* buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer asDoubleBuffer();
@@ -239,15 +222,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by four, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a float buffer which is based on the content of this byte buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer asFloatBuffer();
@@ -259,15 +239,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by four, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a int buffer which is based on the content of this byte buffer.
- * @since Android 1.0
*/
public abstract IntBuffer asIntBuffer();
@@ -279,15 +256,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by eight, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a long buffer which is based on the content of this byte buffer.
- * @since Android 1.0
*/
public abstract LongBuffer asLongBuffer();
@@ -297,15 +271,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer asReadOnlyBuffer();
@@ -317,15 +288,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* of remaining bytes divided by two, and its mark is not set. The new
* buffer's read-only property and byte order are the same as this buffer's.
* The new buffer is direct if this byte buffer is direct.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a short buffer which is based on the content of this byte buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer asShortBuffer();
@@ -336,12 +304,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* buffer, starting from position zero. Then the position is set to
* {@code remaining()}; the limit is set to capacity; the mark is
* cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer compact();
@@ -356,7 +322,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* than {@code other}.
* @exception ClassCastException
* if {@code other} is not a byte buffer.
- * @since Android 1.0
*/
public int compareTo(ByteBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -383,15 +348,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer's. The duplicated buffer's read-only property and byte
* order are the same as this buffer's too.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer duplicate();
@@ -401,14 +363,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* If {@code other} is not a byte buffer then {@code false} is returned. Two
* byte buffers are equal if and only if their remaining bytes are exactly
* the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this byte buffer.
* @return {@code true} if this byte buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof ByteBuffer)) {
return false;
@@ -435,7 +396,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the byte at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract byte get();
@@ -445,14 +405,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination byte array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public ByteBuffer get(byte[] dest) {
return get(dest, 0, dest.length);
@@ -476,11 +434,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public ByteBuffer get(byte[] dest, int off, int len) {
int length = dest.length;
- if ((off < 0 ) || (len < 0) || ((long)off + (long)len > length)) {
+ if ((off < 0) || (len < 0) || ((long) off + (long) len > length)) {
throw new IndexOutOfBoundsException();
}
@@ -501,7 +458,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the byte at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract byte get(int index);
@@ -510,12 +466,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The 2 bytes starting at the current position are composed into a char
* according to the current byte order and returned.
- * </p>
- *
+ *
* @return the char at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 2}.
- * @since Android 1.0
*/
public abstract char getChar();
@@ -525,7 +479,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 2 bytes starting from the specified index are composed into a char
* according to the current byte order and returned. The position is not
* changed.
- * </p>
*
* @param index
* the index, must not be negative and equal or less than
@@ -533,7 +486,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the char at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract char getChar(int index);
@@ -542,13 +494,11 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* 8.
* <p>
* The 8 bytes starting from the current position are composed into a double
- * according to the current byte order and returned.
- * </p>
- *
+ * according to the current byte order and returned.
+ *
* @return the double at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 8}.
- * @since Android 1.0
*/
public abstract double getDouble();
@@ -558,15 +508,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 8 bytes starting at the specified index are composed into a double
* according to the current byte order and returned. The position is not
* changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 8}.
* @return the double at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract double getDouble(int index);
@@ -576,12 +524,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The 4 bytes starting at the current position are composed into a float
* according to the current byte order and returned.
- * </p>
- *
+ *
* @return the float at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 4}.
- * @since Android 1.0
*/
public abstract float getFloat();
@@ -591,15 +537,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 4 bytes starting at the specified index are composed into a float
* according to the current byte order and returned. The position is not
* changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 4}.
* @return the float at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract float getFloat(int index);
@@ -608,12 +552,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The 4 bytes starting at the current position are composed into a int
* according to the current byte order and returned.
- * </p>
- *
+ *
* @return the int at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 4}.
- * @since Android 1.0
*/
public abstract int getInt();
@@ -623,15 +565,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 4 bytes starting at the specified index are composed into a int
* according to the current byte order and returned. The position is not
* changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 4}.
* @return the int at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract int getInt(int index);
@@ -640,12 +580,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The 8 bytes starting at the current position are composed into a long
* according to the current byte order and returned.
- * </p>
- *
+ *
* @return the long at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 8}.
- * @since Android 1.0
*/
public abstract long getLong();
@@ -655,7 +593,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 8 bytes starting at the specified index are composed into a long
* according to the current byte order and returned. The position is not
* changed.
- * </p>
*
* @param index
* the index, must not be negative and equal or less than
@@ -663,7 +600,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* @return the long at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract long getLong(int index);
@@ -672,12 +608,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The 2 bytes starting at the current position are composed into a short
* according to the current byte order and returned.
- * </p>
- *
+ *
* @return the short at the current position.
* @exception BufferUnderflowException
* if the position is greater than {@code limit - 2}.
- * @since Android 1.0
*/
public abstract short getShort();
@@ -687,15 +621,13 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* The 2 bytes starting at the specified index are composed into a short
* according to the current byte order and returned. The position is not
* changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 2}.
* @return the short at the specified index.
* @exception IndexOutOfBoundsException
* if {@code index} is invalid.
- * @since Android 1.0
*/
public abstract short getShort(int index);
@@ -705,7 +637,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
*
* @return {@code true} if this buffer is based on a byte array and provides
* read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -714,10 +645,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining bytes.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -729,9 +660,8 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
/**
* Indicates whether this buffer is direct.
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -741,11 +671,9 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The default byte order of byte buffer is always
* {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting bytes from/to
* other primitive types.
- * @since Android 1.0
*/
public final ByteOrder order() {
return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN
@@ -760,7 +688,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* will be {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}.
* @return this buffer.
* @see ByteOrder
- * @since Android 1.0
*/
public final ByteBuffer order(ByteOrder byteOrder) {
return orderImpl(byteOrder);
@@ -776,7 +703,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* Child class implements this method to realize {@code array()}.
*
* @see #array()
- * @since Android 1.0
*/
abstract byte[] protectedArray();
@@ -784,7 +710,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* Child class implements this method to realize {@code arrayOffset()}.
*
* @see #arrayOffset()
- * @since Android 1.0
*/
abstract int protectedArrayOffset();
@@ -792,7 +717,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* Child class implements this method to realize {@code hasArray()}.
*
* @see #hasArray()
- * @since Android 1.0
*/
abstract boolean protectedHasArray();
@@ -807,7 +731,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer put(byte b);
@@ -817,8 +740,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source byte array.
* @return this buffer.
@@ -826,7 +748,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final ByteBuffer put(byte[] src) {
return put(src, 0, src.length);
@@ -852,7 +773,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public ByteBuffer put(byte[] src, int off, int len) {
int length = src.length;
@@ -884,7 +804,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public ByteBuffer put(ByteBuffer src) {
if (src == this) {
@@ -912,7 +831,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer put(int index, byte b);
@@ -921,8 +839,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* by 2.
* <p>
* The char is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the char to write.
* @return this buffer.
@@ -930,7 +847,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 2}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putChar(char value);
@@ -939,8 +855,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The char is converted to bytes using the current byte order. The position
* is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 2}.
@@ -951,7 +866,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putChar(int index, char value);
@@ -960,8 +874,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* by 8.
* <p>
* The double is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the double to write.
* @return this buffer.
@@ -969,7 +882,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 8}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putDouble(double value);
@@ -978,8 +890,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The double is converted to bytes using the current byte order. The
* position is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 8}.
@@ -990,7 +901,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putDouble(int index, double value);
@@ -999,8 +909,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* by 4.
* <p>
* The float is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the float to write.
* @return this buffer.
@@ -1008,7 +917,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 4}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putFloat(float value);
@@ -1017,8 +925,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The float is converted to bytes using the current byte order. The
* position is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 4}.
@@ -1029,7 +936,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putFloat(int index, float value);
@@ -1038,8 +944,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* 4.
* <p>
* The int is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the int to write.
* @return this buffer.
@@ -1047,7 +952,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 4}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putInt(int value);
@@ -1056,8 +960,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The int is converted to bytes using the current byte order. The position
* is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 4}.
@@ -1068,7 +971,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putInt(int index, int value);
@@ -1077,8 +979,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* by 8.
* <p>
* The long is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the long to write.
* @return this buffer.
@@ -1086,7 +987,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 8}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putLong(long value);
@@ -1095,8 +995,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The long is converted to bytes using the current byte order. The position
* is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 8}.
@@ -1107,7 +1006,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putLong(int index, long value);
@@ -1116,8 +1014,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* by 2.
* <p>
* The short is converted to bytes using the current byte order.
- * </p>
- *
+ *
* @param value
* the short to write.
* @return this buffer.
@@ -1125,7 +1022,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if position is greater than {@code limit - 2}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putShort(short value);
@@ -1134,8 +1030,7 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* <p>
* The short is converted to bytes using the current byte order. The
* position is not changed.
- * </p>
- *
+ *
* @param index
* the index, must not be negative and equal or less than
* {@code limit - 2}.
@@ -1146,7 +1041,6 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* if {@code index} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer putShort(int index, short value);
@@ -1158,15 +1052,12 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* this buffer's current position. The new buffer's position will be 0,
* limit will be its capacity, and its mark is cleared. The new buffer's
* read-only property and byte order are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract ByteBuffer slice();
@@ -1174,10 +1065,10 @@ public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer
* Returns a string representing the state of this byte buffer.
*
* @return a string representing the state of this byte buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
diff --git a/nio/src/main/java/java/nio/ByteOrder.java b/nio/src/main/java/java/nio/ByteOrder.java
index 870216f..c7c92ee 100644
--- a/nio/src/main/java/java/nio/ByteOrder.java
+++ b/nio/src/main/java/java/nio/ByteOrder.java
@@ -16,27 +16,20 @@
package java.nio;
-
import org.apache.harmony.luni.platform.Platform;
/**
* Defines byte order constants.
- *
- * @since Android 1.0
*/
public final class ByteOrder {
/**
* This constant represents big endian.
- *
- * @since Android 1.0
*/
public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); //$NON-NLS-1$
/**
* This constant represents little endian.
- *
- * @since Android 1.0
*/
public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); //$NON-NLS-1$
@@ -55,7 +48,6 @@ public final class ByteOrder {
*
* @return the byte order object, which is either LITTLE_ENDIAN or
* BIG_ENDIAN.
- * @since Android 1.0
*/
public static ByteOrder nativeOrder() {
return NATIVE_ORDER;
@@ -74,8 +66,8 @@ public final class ByteOrder {
* @return "BIG_ENDIAN" for {@link #BIG_ENDIAN ByteOrder.BIG_ENDIAN}
* objects, "LITTLE_ENDIAN" for
* {@link #LITTLE_ENDIAN ByteOrder.LITTLE_ENDIAN} objects.
- * @since Android 1.0
*/
+ @Override
public String toString() {
return name;
}
diff --git a/nio/src/main/java/java/nio/CharArrayBuffer.java b/nio/src/main/java/java/nio/CharArrayBuffer.java
index 516aada..0228eb7 100644
--- a/nio/src/main/java/java/nio/CharArrayBuffer.java
+++ b/nio/src/main/java/java/nio/CharArrayBuffer.java
@@ -49,6 +49,7 @@ abstract class CharArrayBuffer extends CharBuffer {
this.offset = offset;
}
+ @Override
public final char get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class CharArrayBuffer extends CharBuffer {
return backingArray[offset + position++];
}
+ @Override
public final char get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,38 +65,43 @@ abstract class CharArrayBuffer extends CharBuffer {
return backingArray[offset + index];
}
+ @Override
public final CharBuffer get(char[] dest, int off, int len) {
int length = dest.length;
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset+position, dest, off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
+ @Override
public final CharSequence subSequence(int start, int end) {
if (start < 0 || end < start || end > remaining()) {
throw new IndexOutOfBoundsException();
}
-
+
CharBuffer result = duplicate();
result.limit(position + end);
result.position(position + start);
return result;
}
+ @Override
public final String toString() {
return String.copyValueOf(backingArray, offset + position, remaining());
}
diff --git a/nio/src/main/java/java/nio/CharBuffer.java b/nio/src/main/java/java/nio/CharBuffer.java
index 289965a..4506614 100644
--- a/nio/src/main/java/java/nio/CharBuffer.java
+++ b/nio/src/main/java/java/nio/CharBuffer.java
@@ -23,7 +23,6 @@ import java.io.IOException;
* A buffer of chars.
* <p>
* A char buffer can be created in either one of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new char array and create a buffer
* based on it;</li>
@@ -34,11 +33,9 @@ import java.io.IOException;
* <li>Use {@link java.nio.ByteBuffer#asCharBuffer() ByteBuffer.asCharBuffer}
* to create a char buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
-public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer>,
- CharSequence, Appendable, Readable {
+public abstract class CharBuffer extends Buffer implements
+ Comparable<CharBuffer>, CharSequence, Appendable, Readable {
/**
* Creates a char buffer based on a newly allocated char array.
@@ -48,7 +45,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* @return the created char buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static CharBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -62,12 +58,10 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the char array which the new buffer will be based on.
* @return the created char buffer.
- * @since Android 1.0
*/
public static CharBuffer wrap(char[] array) {
return wrap(array, 0, array.length);
@@ -78,8 +72,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the char array which the new buffer will be based on.
* @param start
@@ -91,12 +84,10 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* @return the created char buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static CharBuffer wrap(char[] array, int start, int len) {
int length = array.length;
- if ((start < 0) || (len < 0)
- || (long) start + (long) len > length) {
+ if ((start < 0) || (len < 0) || (long) start + (long) len > length) {
throw new IndexOutOfBoundsException();
}
@@ -112,12 +103,10 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* Calling this method has the same effect as
* {@code wrap(chseq, 0, chseq.length())}.
- * </p>
- *
+ *
* @param chseq
* the char sequence which the new buffer will be based on.
* @return the created char buffer.
- * @since Android 1.0
*/
public static CharBuffer wrap(CharSequence chseq) {
return BufferFactory.newCharBuffer(chseq);
@@ -129,8 +118,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* The new buffer's position will be {@code start}, limit will be
* {@code end}, capacity will be the length of the char sequence. The new
* buffer is read-only.
- * </p>
- *
+ *
* @param chseq
* the char sequence which the new buffer will be based on.
* @param start
@@ -142,7 +130,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* @return the created char buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code end} is invalid.
- * @since Android 1.0
*/
public static CharBuffer wrap(CharSequence chseq, int start, int end) {
if (chseq == null) {
@@ -151,7 +138,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
if (start < 0 || end < start || end > chseq.length()) {
throw new IndexOutOfBoundsException();
}
-
+
CharBuffer result = BufferFactory.newCharBuffer(chseq);
result.position = start;
result.limit = end;
@@ -163,7 +150,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
*
* @param capacity
* the capacity of the buffer.
- * @since Android 1.0
*/
CharBuffer(int capacity) {
super(capacity);
@@ -180,7 +166,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final char[] array() {
return protectedArray();
@@ -192,21 +177,19 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* The offset is the index of the array corresponds to the zero position of
* the buffer.
- * </p>
- *
+ *
* @return the offset of the char array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override
+ @Override
Object _array() {
if (hasArray()) {
return array();
@@ -214,7 +197,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
return null;
}
- @Override
+ @Override
int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
@@ -229,15 +212,12 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer asReadOnlyBuffer();
@@ -253,7 +233,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* current position) in the buffer.
* @exception IndexOutOfBoundsException
* if the index is invalid.
- * @since Android 1.0
*/
public final char charAt(int index) {
if (index < 0 || index >= remaining()) {
@@ -268,12 +247,10 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* The remaining chars will be moved to the head of the buffer,
* starting from position zero. Then the position is set to
* {@code remaining()}; the limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer compact();
@@ -288,7 +265,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* greater than {@code otherBuffer}.
* @exception ClassCastException
* if {@code otherBuffer} is not a char buffer.
- * @since Android 1.0
*/
public int compareTo(CharBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -315,15 +291,12 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* The duplicated buffer's initial position, limit, capacity and mark are
* the same as this buffer's. The duplicated buffer's read-only property and
* byte order are the same as this buffer's, too.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer duplicate();
@@ -333,14 +306,13 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* If {@code other} is not a char buffer then {@code false} is returned. Two
* char buffers are equal if and only if their remaining chars are exactly
* the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this char buffer.
* @return {@code true} if this char buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof CharBuffer)) {
return false;
@@ -367,7 +339,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* @return the char at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract char get();
@@ -377,14 +348,12 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination char array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public CharBuffer get(char[] dest) {
return get(dest, 0, dest.length);
@@ -408,14 +377,13 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public CharBuffer get(char[] dest, int off, int len) {
int length = dest.length;
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -433,16 +401,14 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* @return a char at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract char get(int index);
/**
* Indicates whether this buffer is based on a char array and is read/write.
- *
+ *
* @return {@code true} if this buffer is based on a byte array and provides
* read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -451,10 +417,10 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining chars.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -471,10 +437,8 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* A char buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -482,7 +446,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* Returns the number of remaining chars.
*
* @return the number of remaining chars.
- * @since Android 1.0
*/
public final int length() {
return remaining();
@@ -494,11 +457,9 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* If this buffer is not based on a byte buffer, then this always returns
* the platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting chars from/to
* bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -534,7 +495,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer put(char c);
@@ -544,8 +504,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source char array.
* @return this buffer.
@@ -553,7 +512,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final CharBuffer put(char[] src) {
return put(src, 0, src.length);
@@ -579,14 +537,13 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public CharBuffer put(char[] src, int off, int len) {
int length = src.length;
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -611,7 +568,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public CharBuffer put(CharBuffer src) {
if (src == this) {
@@ -620,7 +576,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
if (src.remaining() > remaining()) {
throw new BufferOverflowException();
}
-
+
char[] contents = new char[src.remaining()];
src.get(contents);
put(contents);
@@ -640,7 +596,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer put(int index, char c);
@@ -650,8 +605,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* <p>
* Calling this method has the same effect as
* {@code put(str, 0, str.length())}.
- * </p>
- *
+ *
* @param str
* the string to write.
* @return this buffer.
@@ -659,7 +613,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if {@code remaining()} is less than the length of string.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final CharBuffer put(String str) {
return put(str, 0, str.length());
@@ -684,14 +637,13 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if either {@code start} or {@code end} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public CharBuffer put(String str, int start, int end) {
int length = str.length();
if (start < 0 || end < start || end > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (end - start > remaining()) {
throw new BufferOverflowException();
}
@@ -709,15 +661,12 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* same as this buffer.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract CharBuffer slice();
@@ -729,13 +678,11 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* be {@code position() + end}, capacity will be the same as this buffer.
* The new buffer's read-only property and byte order are the same as this
* buffer.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @param start
* the start index of the sub-sequence, referenced from the
* current buffer position. Must not be less than zero and not
@@ -750,7 +697,6 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* current remaining content.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code end} is invalid.
- * @since Android 1.0
*/
public abstract CharSequence subSequence(int start, int end);
@@ -758,8 +704,8 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* Returns a string representing the current remaining chars of this buffer.
*
* @return a string representing the current remaining chars of this buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
StringBuffer strbuf = new StringBuffer();
for (int i = position; i < limit; i++) {
@@ -771,7 +717,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Writes the given char to the current position and increases the position
* by 1.
- *
+ *
* @param c
* the char to write.
* @return this buffer.
@@ -779,9 +725,8 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
- public CharBuffer append(char c){
+ public CharBuffer append(char c) {
return put(c);
}
@@ -791,10 +736,9 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* of the csq.
* <p>
* Calling this method has the same effect as {@code append(csq.toString())}.
- * </p>
* If the {@code CharSequence} is {@code null} the string "null" will be
* written to the buffer.
- *
+ *
* @param csq
* the {@code CharSequence} to write.
* @return this buffer.
@@ -802,9 +746,8 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if {@code remaining()} is less than the length of csq.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
- public CharBuffer append(CharSequence csq){
+ public CharBuffer append(CharSequence csq) {
if (csq != null) {
return put(csq.toString());
}
@@ -814,7 +757,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
/**
* Writes chars of the given {@code CharSequence} to the current position of
* this buffer, and increases the position by the number of chars written.
- *
+ *
* @param csq
* the {@code CharSequence} to write.
* @param start
@@ -830,9 +773,8 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if either {@code start} or {@code end} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
- public CharBuffer append(CharSequence csq, int start, int end){
+ public CharBuffer append(CharSequence csq, int start, int end) {
if (csq == null) {
csq = "null"; //$NON-NLS-1$
}
@@ -848,7 +790,7 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* number of chars that are copied is either the number of remaining chars
* in this buffer or the number of remaining chars in {@code target},
* whichever is smaller.
- *
+ *
* @param target
* the target char buffer.
* @throws IllegalArgumentException
@@ -859,19 +801,24 @@ public abstract class CharBuffer extends Buffer implements Comparable<CharBuffer
* if no changes may be made to the contents of {@code target}.
* @return the number of chars copied or -1 if there are no chars left to be
* read from this buffer.
- * @since Android 1.0
*/
public int read(CharBuffer target) throws IOException {
- if(target == this){
+ int remaining = remaining();
+ if (target == this) {
+ if (remaining == 0) {
+ return -1;
+ }
throw new IllegalArgumentException();
}
- if (remaining() == 0) {
- return target.remaining()==0?0:-1;
+ if (remaining == 0) {
+ return limit > 0 && target.remaining() == 0 ? 0 : -1;
}
- int result = Math.min(target.remaining(), remaining());
- char[] chars = new char[result];
- get(chars);
- target.put(chars);
- return result;
- }
+ remaining = Math.min(target.remaining(), remaining);
+ if (remaining > 0) {
+ char[] chars = new char[remaining];
+ get(chars);
+ target.put(chars);
+ }
+ return remaining;
+ }
}
diff --git a/nio/src/main/java/java/nio/CharSequenceAdapter.java b/nio/src/main/java/java/nio/CharSequenceAdapter.java
index 32edc18..3f738b2 100644
--- a/nio/src/main/java/java/nio/CharSequenceAdapter.java
+++ b/nio/src/main/java/java/nio/CharSequenceAdapter.java
@@ -44,18 +44,22 @@ final class CharSequenceAdapter extends CharBuffer {
sequence = chseq;
}
+ @Override
public CharBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public CharBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer duplicate() {
return copy(this);
}
+ @Override
public char get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -63,6 +67,7 @@ final class CharSequenceAdapter extends CharBuffer {
return sequence.charAt(position++);
}
+ @Override
public char get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -70,9 +75,10 @@ final class CharSequenceAdapter extends CharBuffer {
return sequence.charAt(index);
}
+ @Override
public final CharBuffer get(char[] dest, int off, int len) {
int length = dest.length;
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -84,66 +90,79 @@ final class CharSequenceAdapter extends CharBuffer {
return this;
}
+ @Override
public boolean isDirect() {
return false;
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
public ByteOrder order() {
return ByteOrder.nativeOrder();
}
+ @Override
protected char[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public CharBuffer put(char c) {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer put(int index, char c) {
throw new ReadOnlyBufferException();
}
+ @Override
public final CharBuffer put(char[] src, int off, int len) {
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > src.length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > src.length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
-
+
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer put(String src, int start, int end) {
- if ((start < 0 ) || (end < 0) || (long)start + (long)end > src.length()) {
+ if ((start < 0) || (end < 0)
+ || (long) start + (long) end > src.length()) {
throw new IndexOutOfBoundsException();
}
throw new ReadOnlyBufferException();
- }
+ }
+ @Override
public CharBuffer slice() {
return new CharSequenceAdapter(sequence.subSequence(position, limit));
}
+ @Override
public CharSequence subSequence(int start, int end) {
if (end < start || start < 0 || end > remaining()) {
throw new IndexOutOfBoundsException();
}
-
+
CharSequenceAdapter result = copy(this);
result.position = position + start;
result.limit = position + end;
diff --git a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
index bd340be..e92ea57 100644
--- a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// Copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a char buffer.
@@ -35,10 +32,7 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* </p>
*
*/
-// BEGIN android-changed
-// Copied from newer version of harmony
final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
-// END android-changed
static CharBuffer wrap(ByteBuffer byteBuffer) {
return new CharToByteBufferAdapter(byteBuffer.slice());
@@ -51,18 +45,15 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
this.byteBuffer = byteBuffer;
this.byteBuffer.clear();
}
-
- // BEGIN android-added
- // Copied from newer version of harmony
+
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
-
+
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
// BEGIN android-changed
@@ -70,47 +61,44 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
+ @Override
public CharBuffer asReadOnlyBuffer() {
CharToByteBufferAdapter buf = new CharToByteBufferAdapter(byteBuffer
.asReadOnlyBuffer());
@@ -120,6 +108,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return buf;
}
+ @Override
public CharBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +123,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return this;
}
+ @Override
public CharBuffer duplicate() {
CharToByteBufferAdapter buf = new CharToByteBufferAdapter(byteBuffer
.duplicate());
@@ -143,6 +133,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return buf;
}
+ @Override
public char get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +141,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return byteBuffer.getChar(position++ << 1);
}
+ @Override
public char get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +149,37 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return byteBuffer.getChar(index << 1);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected char[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public CharBuffer put(char c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +188,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return this;
}
+ @Override
public CharBuffer put(int index, char c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -197,6 +197,7 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return this;
}
+ @Override
public CharBuffer slice() {
byteBuffer.limit(limit << 1);
byteBuffer.position(position << 1);
@@ -205,11 +206,12 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
return result;
}
+ @Override
public CharSequence subSequence(int start, int end) {
if (start < 0 || end < start || end > remaining()) {
throw new IndexOutOfBoundsException();
}
-
+
CharBuffer result = duplicate();
result.limit(position + end);
result.position(position + start);
diff --git a/nio/src/main/java/java/nio/DirectByteBuffer.java b/nio/src/main/java/java/nio/DirectByteBuffer.java
index dcdb3c1..9bf6813 100644
--- a/nio/src/main/java/java/nio/DirectByteBuffer.java
+++ b/nio/src/main/java/java/nio/DirectByteBuffer.java
@@ -22,7 +22,6 @@ import org.apache.harmony.luni.platform.PlatformAddressFactory;
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.nio.internal.nls.Messages;
-
/**
* DirectByteBuffer, ReadWriteDirectByteBuffer and ReadOnlyDirectByteBuffer
* compose the implementation of platform memory based byte buffers.
@@ -58,13 +57,14 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
/*
* Constructs a new direct byte buffer of the given capacity on newly
- * allocated OS memory. The memory will have been zeroed. When the
- * instance is discarded the OS memory will be freed if it has not
- * already been done so by an explicit call to #free(). Callers are
- * encouraged to explicitly free the memory where possible.
+ * allocated OS memory. The memory will have been zeroed. When the instance
+ * is discarded the OS memory will be freed if it has not already been done
+ * so by an explicit call to #free(). Callers are encouraged to explicitly
+ * free the memory where possible.
*/
DirectByteBuffer(int capacity) {
- this(new SafeAddress(PlatformAddressFactory.alloc(capacity, (byte)0)), capacity, 0);
+ this(new SafeAddress(PlatformAddressFactory.alloc(capacity, (byte) 0)),
+ capacity, 0);
safeAddress.address.autoFree();
}
@@ -79,7 +79,7 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
throw new IllegalArgumentException("slice out of range");
}
// END android-added
-
+
this.safeAddress = address;
this.offset = offset;
}
@@ -88,21 +88,24 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
* Override ByteBuffer.get(byte[], int, int) to improve performance.
*
* (non-Javadoc)
+ *
* @see java.nio.ByteBuffer#get(byte[], int, int)
*/
+ @Override
public final ByteBuffer get(byte[] dest, int off, int len) {
int length = dest.length;
- if ((off < 0 ) || (len < 0) || (long)off + (long)len > length) {
+ if ((off < 0) || (len < 0) || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- getBaseAddress().getByteArray(offset+position, dest, off, len);
+ getBaseAddress().getByteArray(offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final byte get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -110,6 +113,7 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return getBaseAddress().getByte(offset + position++);
}
+ @Override
public final byte get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -117,6 +121,7 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return getBaseAddress().getByte(offset + index);
}
+ @Override
public final double getDouble() {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -127,13 +132,15 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return result;
}
+ @Override
public final double getDouble(int index) {
- if (index < 0 || (long)index + 8 > limit) {
+ if (index < 0 || (long) index + 8 > limit) {
throw new IndexOutOfBoundsException();
}
return getBaseAddress().getDouble(offset + index, order);
}
+ @Override
public final float getFloat() {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -144,13 +151,15 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return result;
}
+ @Override
public final float getFloat(int index) {
- if (index < 0 || (long)index + 4 > limit) {
+ if (index < 0 || (long) index + 4 > limit) {
throw new IndexOutOfBoundsException();
}
return getBaseAddress().getFloat(offset + index, order);
}
+ @Override
public final int getInt() {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -161,13 +170,15 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return result;
}
+ @Override
public final int getInt(int index) {
- if (index < 0 || (long)index + 4 > limit) {
+ if (index < 0 || (long) index + 4 > limit) {
throw new IndexOutOfBoundsException();
}
return getBaseAddress().getInt(offset + index, order);
}
+ @Override
public final long getLong() {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -178,13 +189,15 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return result;
}
+ @Override
public final long getLong(int index) {
- if (index < 0 || (long)index + 8 > limit) {
+ if (index < 0 || (long) index + 8 > limit) {
throw new IndexOutOfBoundsException();
}
return getBaseAddress().getLong(offset + index, order);
}
+ @Override
public final short getShort() {
int newPosition = position + 2;
if (newPosition > limit) {
@@ -195,13 +208,15 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
return result;
}
+ @Override
public final short getShort(int index) {
- if (index < 0 || (long)index + 2 > limit) {
+ if (index < 0 || (long) index + 2 > limit) {
throw new IndexOutOfBoundsException();
}
return getBaseAddress().getShort(offset + index, order);
}
+ @Override
public final boolean isDirect() {
return true;
}
@@ -212,9 +227,9 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
public final void addressValidityCheck() {
if (!isAddressValid()) {
- // nio.08=Cannot use the direct byte buffer after it has been explicitly freed.
- throw new IllegalStateException(
- Messages.getString("nio.08")); //$NON-NLS-1$
+ // nio.08=Cannot use the direct byte buffer after it has been
+ // explicitly freed.
+ throw new IllegalStateException(Messages.getString("nio.08")); //$NON-NLS-1$
}
}
@@ -271,23 +286,23 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
safeAddress.address.free();
}
}
-
+
+ @Override
final protected byte[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
final protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
final protected boolean protectedHasArray() {
return false;
}
- // BEGIN android-added
- // copied from newer version of harmony
public final int getByteCapacity() {
return capacity;
}
- // END android-added
}
diff --git a/nio/src/main/java/java/nio/DirectByteBuffers.java b/nio/src/main/java/java/nio/DirectByteBuffers.java
index 03a0df7..77b6ebd 100644
--- a/nio/src/main/java/java/nio/DirectByteBuffers.java
+++ b/nio/src/main/java/java/nio/DirectByteBuffers.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package java.nio;
+package java.nio;
import org.apache.harmony.luni.platform.PlatformAddress;
@@ -31,13 +31,11 @@ class DirectByteBuffers {
* If the memory is known to already have been freed then this is a no-op.
* Once the memory has been freed then operations requiring access to the
* memory will throw an <code>IllegalStateException</code>.
- * </p>
* <p>
* Note this is is possible that the memory is freed by code that reaches
* into the address and explicitly frees it 'beneith' us -- this is bad
* form.
- * </p>
- *
+ *
* @param directBuffer
* the direct byte buffer memory to free
* @throws IllegalArgumentException
@@ -61,8 +59,7 @@ class DirectByteBuffers {
* If you can guarantee that you want to free the underlying memory call the
* #free() method on this instance -- generally applications will rely on
* the garbage collector to autofree this memory.
- * </p>
- *
+ *
* @param directBuffer
* the direct byte buffer
* @return the effective address of the start of the buffer.
diff --git a/nio/src/main/java/java/nio/DoubleArrayBuffer.java b/nio/src/main/java/java/nio/DoubleArrayBuffer.java
index ad488ea..ce1e3a6 100644
--- a/nio/src/main/java/java/nio/DoubleArrayBuffer.java
+++ b/nio/src/main/java/java/nio/DoubleArrayBuffer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package java.nio;
+package java.nio;
/**
* DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer
@@ -49,6 +49,7 @@ abstract class DoubleArrayBuffer extends DoubleBuffer {
this.offset = offset;
}
+ @Override
public final double get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class DoubleArrayBuffer extends DoubleBuffer {
return backingArray[offset + position++];
}
+ @Override
public final double get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,24 +65,26 @@ abstract class DoubleArrayBuffer extends DoubleBuffer {
return backingArray[offset + index];
}
+ @Override
public final DoubleBuffer get(double[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset + position, dest,
- off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
diff --git a/nio/src/main/java/java/nio/DoubleBuffer.java b/nio/src/main/java/java/nio/DoubleBuffer.java
index b3c261d..4e0ab01 100644
--- a/nio/src/main/java/java/nio/DoubleBuffer.java
+++ b/nio/src/main/java/java/nio/DoubleBuffer.java
@@ -21,7 +21,6 @@ package java.nio;
* A buffer of doubles.
* <p>
* A double buffer can be created in either one of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new double array and create a buffer
* based on it;</li>
@@ -31,10 +30,9 @@ package java.nio;
* {@link java.nio.ByteBuffer#asDoubleBuffer() ByteBuffer.asDoubleBuffer} to
* create a double buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
-public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBuffer> {
+public abstract class DoubleBuffer extends Buffer implements
+ Comparable<DoubleBuffer> {
/**
* Creates a double buffer based on a newly allocated double array.
@@ -44,7 +42,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* @return the created double buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static DoubleBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -58,12 +55,10 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the double array which the new buffer will be based on.
* @return the created double buffer.
- * @since Android 1.0
*/
public static DoubleBuffer wrap(double[] array) {
return wrap(array, 0, array.length);
@@ -74,8 +69,7 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the double array which the new buffer will be based on.
* @param start
@@ -87,11 +81,10 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* @return the created double buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static DoubleBuffer wrap(double[] array, int start, int len) {
int length = array.length;
- if (start < 0 || len < 0 || (long)start + (long)len > length) {
+ if (start < 0 || len < 0 || (long) start + (long) len > length) {
throw new IndexOutOfBoundsException();
}
@@ -123,7 +116,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if this buffer is based on an array but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final double[] array() {
return protectedArray();
@@ -135,21 +127,19 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* The offset is the index of the array corresponding to the zero position
* of the buffer.
- * </p>
- *
+ *
* @return the offset of the double array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
}
// BEGIN android-added
- @Override
+ @Override
Object _array() {
if (hasArray()) {
return array();
@@ -157,7 +147,7 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
return null;
}
- @Override
+ @Override
int _arrayOffset() {
if (hasArray()) {
return arrayOffset();
@@ -172,15 +162,12 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means that this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer asReadOnlyBuffer();
@@ -190,12 +177,10 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* The remaining doubles will be moved to the head of the buffer, staring
* from position zero. Then the position is set to {@code remaining()}; the
* limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer compact();
@@ -210,14 +195,12 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* than {@code other}.
* @exception ClassCastException
* if {@code other} is not a double buffer.
- * @since Android 1.0
*/
public int compareTo(DoubleBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- // BEGIN android-changed
double thisDouble, otherDouble;
while (compareRemaining > 0) {
thisDouble = get(thisPos);
@@ -231,7 +214,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
otherPos++;
compareRemaining--;
}
- // END android-changed
return remaining() - otherBuffer.remaining();
}
@@ -241,15 +223,12 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer's. The duplicated buffer's read-only property and byte
* order are the same as this buffer's, too.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer duplicate();
@@ -259,14 +238,13 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* If {@code other} is not a double buffer then {@code false} is returned.
* Two double buffers are equal if and only if their remaining doubles are
* exactly the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this double buffer.
* @return {@code true} if this double buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof DoubleBuffer)) {
return false;
@@ -294,7 +272,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* @return the double at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract double get();
@@ -304,14 +281,12 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination double array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public DoubleBuffer get(double[] dest) {
return get(dest, 0, dest.length);
@@ -335,14 +310,13 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public DoubleBuffer get(double[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -360,17 +334,15 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* @return a double at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract double get(int index);
/**
* Indicates whether this buffer is based on a double array and is
* read/write.
- *
+ *
* @return {@code true} if this buffer is based on a double array and
* provides read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -379,10 +351,10 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining chars.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -401,10 +373,8 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* A double buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
*
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -414,11 +384,9 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* If this buffer is not based on a byte buffer, then this always returns
* the platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting doubles
* from/to bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -454,7 +422,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer put(double d);
@@ -464,8 +431,7 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source double array.
* @return this buffer.
@@ -473,7 +439,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final DoubleBuffer put(double[] src) {
return put(src, 0, src.length);
@@ -499,14 +464,13 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public DoubleBuffer put(double[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -531,7 +495,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public DoubleBuffer put(DoubleBuffer src) {
if (src == this) {
@@ -559,7 +522,6 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer put(int index, double d);
@@ -571,15 +533,12 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract DoubleBuffer slice();
@@ -587,16 +546,16 @@ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBu
* Returns a string representing the state of this double buffer.
*
* @return A string representing the state of this double buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
buf.append(" position="); //$NON-NLS-1$
buf.append(position());
- buf.append(" limit="); //$NON-NLS-1$
+ buf.append(" limit="); //$NON-NLS-1$
buf.append(limit());
return buf.toString();
}
diff --git a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
index 70406ba..da53bdc 100644
--- a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// Copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a double buffer.
@@ -35,10 +32,8 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* </p>
*
*/
-// BEGIN android-changed
-// Copied from newer version of harmony
-final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuffer {
-// END android-changed
+final class DoubleToByteBufferAdapter extends DoubleBuffer implements
+ DirectBuffer {
static DoubleBuffer wrap(ByteBuffer byteBuffer) {
return new DoubleToByteBufferAdapter(byteBuffer.slice());
@@ -52,15 +47,12 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
this.byteBuffer.clear();
}
- // BEGIN android-added
- // Copied from newer version of harmony
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
public PlatformAddress getEffectiveAddress() {
@@ -70,47 +62,44 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
-
+
+ @Override
public DoubleBuffer asReadOnlyBuffer() {
DoubleToByteBufferAdapter buf = new DoubleToByteBufferAdapter(
byteBuffer.asReadOnlyBuffer());
@@ -120,6 +109,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return buf;
}
+ @Override
public DoubleBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +124,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return this;
}
+ @Override
public DoubleBuffer duplicate() {
DoubleToByteBufferAdapter buf = new DoubleToByteBufferAdapter(
byteBuffer.duplicate());
@@ -143,6 +134,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return buf;
}
+ @Override
public double get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +142,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return byteBuffer.getDouble(position++ << 3);
}
+ @Override
public double get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +150,37 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return byteBuffer.getDouble(index << 3);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected double[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public DoubleBuffer put(double c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +189,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return this;
}
+ @Override
public DoubleBuffer put(int index, double c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -197,6 +198,7 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
return this;
}
+ @Override
public DoubleBuffer slice() {
byteBuffer.limit(limit << 3);
byteBuffer.position(position << 3);
diff --git a/nio/src/main/java/java/nio/FloatArrayBuffer.java b/nio/src/main/java/java/nio/FloatArrayBuffer.java
index bb07e97..0dcc89c 100644
--- a/nio/src/main/java/java/nio/FloatArrayBuffer.java
+++ b/nio/src/main/java/java/nio/FloatArrayBuffer.java
@@ -49,6 +49,7 @@ abstract class FloatArrayBuffer extends FloatBuffer {
this.offset = offset;
}
+ @Override
public final float get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class FloatArrayBuffer extends FloatBuffer {
return backingArray[offset + position++];
}
+ @Override
public final float get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,23 +65,26 @@ abstract class FloatArrayBuffer extends FloatBuffer {
return backingArray[offset + index];
}
+ @Override
public final FloatBuffer get(float[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset+position, dest, off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
diff --git a/nio/src/main/java/java/nio/FloatBuffer.java b/nio/src/main/java/java/nio/FloatBuffer.java
index f7ee917..cab94c3 100644
--- a/nio/src/main/java/java/nio/FloatBuffer.java
+++ b/nio/src/main/java/java/nio/FloatBuffer.java
@@ -21,7 +21,6 @@ package java.nio;
* A buffer of floats.
* <p>
* A float buffer can be created in either of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new float array and create a buffer
* based on it;</li>
@@ -30,10 +29,9 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asFloatBuffer() ByteBuffer.asFloatBuffer}
* to create a float buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
-public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuffer> {
+public abstract class FloatBuffer extends Buffer implements
+ Comparable<FloatBuffer> {
/**
* Creates a float buffer based on a newly allocated float array.
@@ -43,7 +41,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* @return the created float buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static FloatBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -57,12 +54,10 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the float array which the new buffer will be based on.
* @return the created float buffer.
- * @since Android 1.0
*/
public static FloatBuffer wrap(float[] array) {
return wrap(array, 0, array.length);
@@ -73,8 +68,7 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the float array which the new buffer will be based on.
* @param start
@@ -88,15 +82,14 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if either {@code start} or {@code len} is invalid.
* @exception NullPointerException
* if {@code array} is null.
- * @since Android 1.0
*/
public static FloatBuffer wrap(float[] array, int start, int len) {
- if (array == null) {
- throw new NullPointerException();
- }
- if (start < 0 || len < 0 || (long)start + (long)len > array.length) {
- throw new IndexOutOfBoundsException();
- }
+ if (array == null) {
+ throw new NullPointerException();
+ }
+ if (start < 0 || len < 0 || (long) start + (long) len > array.length) {
+ throw new IndexOutOfBoundsException();
+ }
FloatBuffer buf = BufferFactory.newFloatBuffer(array);
buf.position = start;
@@ -125,7 +118,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final float[] array() {
return protectedArray();
@@ -137,14 +129,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* The offset is the index of the array and corresponds to the zero position
* of the buffer.
- * </p>
- *
+ *
* @return the offset of the float array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -172,15 +162,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer asReadOnlyBuffer();
@@ -190,12 +177,10 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* The remaining floats will be moved to the head of the buffer, starting
* from position zero. Then the position is set to {@code remaining()}; the
* limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer compact();
@@ -210,14 +195,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* greater than {@code otherBuffer}.
* @exception ClassCastException
* if {@code otherBuffer} is not a float buffer.
- * @since Android 1.0
*/
public int compareTo(FloatBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
: otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
- // BEGIN android-changed
float thisFloat, otherFloat;
while (compareRemaining > 0) {
thisFloat = get(thisPos);
@@ -231,7 +214,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
otherPos++;
compareRemaining--;
}
- // END android-changed
return remaining() - otherBuffer.remaining();
}
@@ -241,15 +223,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer. The duplicated buffer's read-only property and byte order
* are same as this buffer too.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer duplicate();
@@ -259,14 +238,13 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* If {@code other} is not a float buffer then {@code false} is returned.
* Two float buffers are equal if and only if their remaining floats are
* exactly the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this float buffer.
* @return {@code true} if this float buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof FloatBuffer)) {
return false;
@@ -294,7 +272,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* @return the float at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract float get();
@@ -304,14 +281,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination float array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public FloatBuffer get(float[] dest) {
return get(dest, 0, dest.length);
@@ -335,14 +310,13 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public FloatBuffer get(float[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -360,17 +334,15 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* @return a float at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract float get(int index);
/**
* Indicates whether this buffer is based on a float array and is
* read/write.
- *
+ *
* @return {@code true} if this buffer is based on a float array and
* provides read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -379,10 +351,10 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining floats.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -399,10 +371,8 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* A float buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -412,11 +382,9 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting floats from/to
* bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -452,7 +420,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer put(float f);
@@ -462,8 +429,7 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source float array.
* @return this buffer.
@@ -471,7 +437,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final FloatBuffer put(float[] src) {
return put(src, 0, src.length);
@@ -497,14 +462,13 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public FloatBuffer put(float[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -529,7 +493,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public FloatBuffer put(FloatBuffer src) {
if (src == this) {
@@ -557,7 +520,6 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer put(int index, float f);
@@ -569,15 +531,12 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
*
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract FloatBuffer slice();
@@ -585,10 +544,10 @@ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuff
* Returns a string representing the state of this float buffer.
*
* @return a string representing the state of this float buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
diff --git a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
index 75b9d84..d91ad0d 100644
--- a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a float buffer.
@@ -35,10 +32,8 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* </p>
*
*/
-// BEGIN android-changed
-// copied from newer version of harmony
-final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer {
-// END android-changed
+final class FloatToByteBufferAdapter extends FloatBuffer implements
+ DirectBuffer {
static FloatBuffer wrap(ByteBuffer byteBuffer) {
return new FloatToByteBufferAdapter(byteBuffer.slice());
@@ -52,15 +47,12 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
this.byteBuffer.clear();
}
- // BEGIN android-added
- // copied from newer version of harmony
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
public PlatformAddress getEffectiveAddress() {
@@ -70,47 +62,44 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
+ @Override
public FloatBuffer asReadOnlyBuffer() {
FloatToByteBufferAdapter buf = new FloatToByteBufferAdapter(byteBuffer
.asReadOnlyBuffer());
@@ -120,6 +109,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return buf;
}
+ @Override
public FloatBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +124,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return this;
}
+ @Override
public FloatBuffer duplicate() {
FloatToByteBufferAdapter buf = new FloatToByteBufferAdapter(byteBuffer
.duplicate());
@@ -143,6 +134,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return buf;
}
+ @Override
public float get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +142,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return byteBuffer.getFloat(position++ << 2);
}
+ @Override
public float get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +150,37 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return byteBuffer.getFloat(index << 2);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected float[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public FloatBuffer put(float c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +189,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return this;
}
+ @Override
public FloatBuffer put(int index, float c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -197,6 +198,7 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
return this;
}
+ @Override
public FloatBuffer slice() {
byteBuffer.limit(limit << 2);
byteBuffer.position(position << 2);
diff --git a/nio/src/main/java/java/nio/HeapByteBuffer.java b/nio/src/main/java/java/nio/HeapByteBuffer.java
index 49c4038..a87d5b3 100644
--- a/nio/src/main/java/java/nio/HeapByteBuffer.java
+++ b/nio/src/main/java/java/nio/HeapByteBuffer.java
@@ -62,9 +62,10 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
*
* @see java.nio.ByteBuffer#get(byte[], int, int)
*/
+ @Override
public final ByteBuffer get(byte[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -74,7 +75,8 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
position += len;
return this;
}
-
+
+ @Override
public final byte get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -82,6 +84,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return backingArray[offset + position++];
}
+ @Override
public final byte get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -89,22 +92,27 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return backingArray[offset + index];
}
+ @Override
public final double getDouble() {
return Double.longBitsToDouble(getLong());
}
+ @Override
public final double getDouble(int index) {
return Double.longBitsToDouble(getLong(index));
}
+ @Override
public final float getFloat() {
return Float.intBitsToFloat(getInt());
}
+ @Override
public final float getFloat(int index) {
return Float.intBitsToFloat(getInt(index));
}
+ @Override
public final int getInt() {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -115,6 +123,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return result;
}
+ @Override
public final int getInt(int index) {
if (index < 0 || index + 4 > limit) {
throw new IndexOutOfBoundsException();
@@ -122,6 +131,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return loadInt(index);
}
+ @Override
public final long getLong() {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -132,6 +142,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return result;
}
+ @Override
public final long getLong(int index) {
if (index < 0 || index + 8 > limit) {
throw new IndexOutOfBoundsException();
@@ -139,6 +150,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return loadLong(index);
}
+ @Override
public final short getShort() {
int newPosition = position + 2;
if (newPosition > limit) {
@@ -149,6 +161,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return result;
}
+ @Override
public final short getShort(int index) {
if (index < 0 || index + 2 > limit) {
throw new IndexOutOfBoundsException();
@@ -156,6 +169,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
return loadShort(index);
}
+ @Override
public final boolean isDirect() {
return false;
}
@@ -163,12 +177,12 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
protected final int loadInt(int index) {
int baseOffset = offset + index;
int bytes = 0;
- if(order == Endianness.BIG_ENDIAN){
+ if (order == Endianness.BIG_ENDIAN) {
for (int i = 0; i < 4; i++) {
bytes = bytes << 8;
bytes = bytes | (backingArray[baseOffset + i] & 0xFF);
- }
- }else{
+ }
+ } else {
for (int i = 3; i >= 0; i--) {
bytes = bytes << 8;
bytes = bytes | (backingArray[baseOffset + i] & 0xFF);
@@ -180,12 +194,12 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
protected final long loadLong(int index) {
int baseOffset = offset + index;
long bytes = 0;
- if(order == Endianness.BIG_ENDIAN){
+ if (order == Endianness.BIG_ENDIAN) {
for (int i = 0; i < 8; i++) {
bytes = bytes << 8;
bytes = bytes | (backingArray[baseOffset + i] & 0xFF);
- }
- }else{
+ }
+ } else {
for (int i = 7; i >= 0; i--) {
bytes = bytes << 8;
bytes = bytes | (backingArray[baseOffset + i] & 0xFF);
@@ -196,12 +210,12 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
protected final short loadShort(int index) {
int baseOffset = offset + index;
- short bytes = 0;
- if(order == Endianness.BIG_ENDIAN){
+ short bytes = 0;
+ if (order == Endianness.BIG_ENDIAN) {
bytes = (short) (backingArray[baseOffset] << 8);
- bytes |= (backingArray[baseOffset + 1] & 0xFF);
- }else{
- bytes = (short) (backingArray[baseOffset+1] << 8);
+ bytes |= (backingArray[baseOffset + 1] & 0xFF);
+ } else {
+ bytes = (short) (backingArray[baseOffset + 1] << 8);
bytes |= (backingArray[baseOffset] & 0xFF);
}
return bytes;
@@ -243,7 +257,7 @@ abstract class HeapByteBuffer extends BaseByteBuffer {
backingArray[baseOffset] = (byte) ((value >> 8) & 0xFF);
backingArray[baseOffset + 1] = (byte) (value & 0xFF);
} else {
- backingArray[baseOffset+1] = (byte) ((value >> 8) & 0xFF);
+ backingArray[baseOffset + 1] = (byte) ((value >> 8) & 0xFF);
backingArray[baseOffset] = (byte) (value & 0xFF);
}
}
diff --git a/nio/src/main/java/java/nio/IntArrayBuffer.java b/nio/src/main/java/java/nio/IntArrayBuffer.java
index d77268e..0352a0f 100644
--- a/nio/src/main/java/java/nio/IntArrayBuffer.java
+++ b/nio/src/main/java/java/nio/IntArrayBuffer.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package java.nio;
+package java.nio;
/**
* IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose
@@ -49,6 +49,7 @@ abstract class IntArrayBuffer extends IntBuffer {
this.offset = offset;
}
+ @Override
public final int get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class IntArrayBuffer extends IntBuffer {
return backingArray[offset + position++];
}
+ @Override
public final int get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,23 +65,26 @@ abstract class IntArrayBuffer extends IntBuffer {
return backingArray[offset + index];
}
+ @Override
public final IntBuffer get(int[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
- }
+ }
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset+position, dest, off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
diff --git a/nio/src/main/java/java/nio/IntBuffer.java b/nio/src/main/java/java/nio/IntBuffer.java
index 7a19dfd..d95783b 100644
--- a/nio/src/main/java/java/nio/IntBuffer.java
+++ b/nio/src/main/java/java/nio/IntBuffer.java
@@ -21,7 +21,6 @@ package java.nio;
* A buffer of ints.
* <p>
* A int buffer can be created in either of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new int array and create a buffer
* based on it;</li>
@@ -29,8 +28,6 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asIntBuffer() ByteBuffer.asIntBuffer} to
* create a int buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer> {
@@ -42,7 +39,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* @return the created int buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static IntBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -56,12 +52,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the int array which the new buffer will be based on.
* @return the created int buffer.
- * @since Android 1.0
*/
public static IntBuffer wrap(int[] array) {
return wrap(array, 0, array.length);
@@ -72,8 +66,7 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the int array which the new buffer will be based on.
* @param start
@@ -85,15 +78,14 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* @return the created int buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static IntBuffer wrap(int[] array, int start, int len) {
- if (array == null) {
- throw new NullPointerException();
- }
- if (start < 0 || len < 0 || (long)len + (long)start > array.length) {
- throw new IndexOutOfBoundsException();
- }
+ if (array == null) {
+ throw new NullPointerException();
+ }
+ if (start < 0 || len < 0 || (long) len + (long) start > array.length) {
+ throw new IndexOutOfBoundsException();
+ }
IntBuffer buf = BufferFactory.newIntBuffer(array);
buf.position = start;
@@ -123,7 +115,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int[] array() {
return protectedArray();
@@ -135,14 +126,12 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* The offset is the index of the array corresponds to the zero position of
* the buffer.
- * </p>
- *
+ *
* @return the offset of the int array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -170,15 +159,12 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* The returned buffer is guaranteed to be a new instance, even this buffer
* is read-only itself. The new buffer's position, limit, capacity and mark
* are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer asReadOnlyBuffer();
@@ -188,12 +174,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* The remaining ints will be moved to the head of the buffer, starting from
* position zero. Then the position is set to {@code remaining()}; the
* limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer compact();
@@ -208,7 +192,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* than {@code other}.
* @exception ClassCastException
* if {@code other} is not an int buffer.
- * @since Android 1.0
*/
public int compareTo(IntBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -237,15 +220,12 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer. The duplicated buffer's read-only property and byte order
* are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer duplicate();
@@ -255,14 +235,13 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* If {@code other} is not a int buffer then {@code false} is returned. Two
* int buffers are equal if and only if their remaining ints are exactly the
* same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this int buffer.
* @return {@code true} if this int buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof IntBuffer)) {
return false;
@@ -289,7 +268,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* @return the int at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract int get();
@@ -299,14 +277,12 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination int array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public IntBuffer get(int[] dest) {
return get(dest, 0, dest.length);
@@ -330,11 +306,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public IntBuffer get(int[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -354,16 +329,14 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* @return an int at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract int get(int index);
/**
* Indicates whether this buffer is based on a int array and is read/write.
- *
+ *
* @return {@code true} if this buffer is based on a int array and provides
* read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -372,10 +345,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining ints.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -392,11 +365,9 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* An int buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
- */
+ */
public abstract boolean isDirect();
/**
@@ -405,11 +376,9 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting ints from/to
* bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -445,7 +414,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer put(int i);
@@ -455,8 +423,7 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source int array.
* @return this buffer.
@@ -464,7 +431,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final IntBuffer put(int[] src) {
return put(src, 0, src.length);
@@ -490,14 +456,13 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public IntBuffer put(int[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -522,7 +487,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public IntBuffer put(IntBuffer src) {
if (src == this) {
@@ -550,7 +514,6 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer put(int index, int i);
@@ -562,15 +525,12 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
*
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract IntBuffer slice();
@@ -578,10 +538,10 @@ public abstract class IntBuffer extends Buffer implements Comparable<IntBuffer>
* Returns a string represents of the state of this int buffer.
*
* @return a string represents of the state of this int buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
diff --git a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
index e77bec6..0631de4 100644
--- a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a int buffer.
@@ -35,10 +32,7 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* </p>
*
*/
-// BEGIN android-changed
-// copied from newer version of harmony
final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
-// END android-changed
static IntBuffer wrap(ByteBuffer byteBuffer) {
return new IntToByteBufferAdapter(byteBuffer.slice());
@@ -52,15 +46,12 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
this.byteBuffer.clear();
}
- // BEGIN android-added
- // copied from newer version of harmony
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
public PlatformAddress getEffectiveAddress() {
@@ -70,47 +61,44 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
+ @Override
public IntBuffer asReadOnlyBuffer() {
IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
.asReadOnlyBuffer());
@@ -120,6 +108,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return buf;
}
+ @Override
public IntBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +123,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return this;
}
+ @Override
public IntBuffer duplicate() {
IntToByteBufferAdapter buf = new IntToByteBufferAdapter(byteBuffer
.duplicate());
@@ -143,6 +133,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return buf;
}
+ @Override
public int get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +141,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return byteBuffer.getInt(position++ << 2);
}
+ @Override
public int get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +149,37 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return byteBuffer.getInt(index << 2);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected int[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public IntBuffer put(int c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +188,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
return this;
}
+ @Override
public IntBuffer put(int index, int c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -212,6 +212,7 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
}
// END android-added
+ @Override
public IntBuffer slice() {
byteBuffer.limit(limit << 2);
byteBuffer.position(position << 2);
diff --git a/nio/src/main/java/java/nio/InvalidMarkException.java b/nio/src/main/java/java/nio/InvalidMarkException.java
index 530d9cf..ff41705 100644
--- a/nio/src/main/java/java/nio/InvalidMarkException.java
+++ b/nio/src/main/java/java/nio/InvalidMarkException.java
@@ -16,12 +16,9 @@
package java.nio;
-
/**
* An {@code InvalidMarkException} is thrown when {@code reset()} is called on a
* buffer, but no mark has been set previously.
- *
- * @since Android 1.0
*/
public class InvalidMarkException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class InvalidMarkException extends IllegalStateException {
/**
* Constructs an {@code InvalidMarkException}.
- *
- * @since Android 1.0
*/
public InvalidMarkException() {
super();
diff --git a/nio/src/main/java/java/nio/LongArrayBuffer.java b/nio/src/main/java/java/nio/LongArrayBuffer.java
index efd259c..46c36e4 100644
--- a/nio/src/main/java/java/nio/LongArrayBuffer.java
+++ b/nio/src/main/java/java/nio/LongArrayBuffer.java
@@ -49,6 +49,7 @@ abstract class LongArrayBuffer extends LongBuffer {
this.offset = offset;
}
+ @Override
public final long get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class LongArrayBuffer extends LongBuffer {
return backingArray[offset + position++];
}
+ @Override
public final long get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,23 +65,26 @@ abstract class LongArrayBuffer extends LongBuffer {
return backingArray[offset + index];
}
+ @Override
public final LongBuffer get(long[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset+position, dest, off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
diff --git a/nio/src/main/java/java/nio/LongBuffer.java b/nio/src/main/java/java/nio/LongBuffer.java
index b0bf7ea..eecbf5e 100644
--- a/nio/src/main/java/java/nio/LongBuffer.java
+++ b/nio/src/main/java/java/nio/LongBuffer.java
@@ -21,7 +21,6 @@ package java.nio;
* A buffer of longs.
* <p>
* A long buffer can be created in either of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new long array and create a buffer
* based on it;</li>
@@ -30,10 +29,9 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asLongBuffer() ByteBuffer.asLongBuffer}
* to create a long buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
-public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer> {
+public abstract class LongBuffer extends Buffer implements
+ Comparable<LongBuffer> {
/**
* Creates a long buffer based on a newly allocated long array.
@@ -43,7 +41,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* @return the created long buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static LongBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -57,12 +54,10 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the long array which the new buffer will be based on.
* @return the created long buffer.
- * @since Android 1.0
*/
public static LongBuffer wrap(long[] array) {
return wrap(array, 0, array.length);
@@ -73,8 +68,7 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the long array which the new buffer will be based on.
* @param start
@@ -86,15 +80,14 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* @return the created long buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static LongBuffer wrap(long[] array, int start, int len) {
- if (array == null) {
- throw new NullPointerException();
- }
- if (start < 0 || len < 0 || (long)len + (long)start > array.length) {
- throw new IndexOutOfBoundsException();
- }
+ if (array == null) {
+ throw new NullPointerException();
+ }
+ if (start < 0 || len < 0 || (long) len + (long) start > array.length) {
+ throw new IndexOutOfBoundsException();
+ }
LongBuffer buf = BufferFactory.newLongBuffer(array);
buf.position = start;
@@ -124,7 +117,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final long[] array() {
return protectedArray();
@@ -136,14 +128,12 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* The offset is the index of the array and corresponds to the zero position
* of the buffer.
- * </p>
- *
+ *
* @return the offset of the long array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -171,15 +161,12 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer asReadOnlyBuffer();
@@ -189,12 +176,10 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* The remaining longs will be moved to the head of the buffer, staring from
* position zero. Then the position is set to {@code remaining()}; the
* limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer compact();
@@ -209,7 +194,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* greater than {@code otherBuffer}
* @exception ClassCastException
* if {@code otherBuffer} is not a long buffer.
- * @since Android 1.0
*/
public int compareTo(LongBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -238,15 +222,12 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer. The duplicated buffer's read-only property and byte order
* are same as this buffer's, too.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer duplicate();
@@ -256,14 +237,13 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* If {@code other} is not a long buffer then {@code false} is returned. Two
* long buffers are equal if and only if their remaining longs are exactly
* the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this long buffer.
* @return {@code true} if this long buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof LongBuffer)) {
return false;
@@ -290,7 +270,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* @return the long at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract long get();
@@ -300,14 +279,12 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
*
* @param dest
* the destination long array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public LongBuffer get(long[] dest) {
return get(dest, 0, dest.length);
@@ -331,14 +308,13 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public LongBuffer get(long[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferUnderflowException();
}
@@ -356,16 +332,14 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* @return the long at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract long get(int index);
/**
* Indicates whether this buffer is based on a long array and is read/write.
- *
+ *
* @return {@code true} if this buffer is based on a long array and provides
* read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -374,10 +348,10 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining longs.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -396,10 +370,8 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* A long buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -409,11 +381,9 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting longs from/to
* bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -449,7 +419,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer put(long l);
@@ -459,8 +428,7 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source long array.
* @return this buffer.
@@ -468,7 +436,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final LongBuffer put(long[] src) {
return put(src, 0, src.length);
@@ -494,14 +461,13 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public LongBuffer put(long[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -526,7 +492,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public LongBuffer put(LongBuffer src) {
if (src == this) {
@@ -554,7 +519,6 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer put(int index, long l);
@@ -566,15 +530,12 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract LongBuffer slice();
@@ -582,10 +543,10 @@ public abstract class LongBuffer extends Buffer implements Comparable<LongBuffer
* Returns a string representing the state of this long buffer.
*
* @return a string representing the state of this long buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
diff --git a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
index bcdeb2b..8b07ac5 100644
--- a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a long buffer.
@@ -33,12 +30,9 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* The adapter extends Buffer, thus has its own position and limit.</li>
* </ul>
* </p>
- *
+ *
*/
-// BEGIN android-changed
-// copied from newer version of harmony
final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
-// END android-changed
static LongBuffer wrap(ByteBuffer byteBuffer) {
return new LongToByteBufferAdapter(byteBuffer.slice());
@@ -52,15 +46,12 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
this.byteBuffer.clear();
}
- // BEGIN android-added
- // copied from newer version of harmony
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
public PlatformAddress getEffectiveAddress() {
@@ -70,47 +61,44 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
- public void addressValidityCheck() {
+ public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
+ @Override
public LongBuffer asReadOnlyBuffer() {
LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
.asReadOnlyBuffer());
@@ -120,6 +108,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return buf;
}
+ @Override
public LongBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +123,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return this;
}
+ @Override
public LongBuffer duplicate() {
LongToByteBufferAdapter buf = new LongToByteBufferAdapter(byteBuffer
.duplicate());
@@ -143,6 +133,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return buf;
}
+ @Override
public long get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +141,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return byteBuffer.getLong(position++ << 3);
}
+ @Override
public long get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +149,37 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return byteBuffer.getLong(index << 3);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected long[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public LongBuffer put(long c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +188,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return this;
}
+ @Override
public LongBuffer put(int index, long c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -197,6 +197,7 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
return this;
}
+ @Override
public LongBuffer slice() {
byteBuffer.limit(limit << 3);
byteBuffer.position(position << 3);
diff --git a/nio/src/main/java/java/nio/MappedByteBuffer.java b/nio/src/main/java/java/nio/MappedByteBuffer.java
index 8f6727d..e995f67 100644
--- a/nio/src/main/java/java/nio/MappedByteBuffer.java
+++ b/nio/src/main/java/java/nio/MappedByteBuffer.java
@@ -21,7 +21,6 @@ import org.apache.harmony.luni.platform.MappedPlatformAddress;
import org.apache.harmony.luni.platform.PlatformAddress;
import org.apache.harmony.nio.internal.DirectBuffer;
-
/**
* {@code MappedByteBuffer} is a special kind of direct byte buffer which maps a
* region of file to memory.
@@ -30,15 +29,11 @@ import org.apache.harmony.nio.internal.DirectBuffer;
* {@link java.nio.channels.FileChannel#map(java.nio.channels.FileChannel.MapMode, long, long) FileChannel.map}.
* Once created, the mapping between the byte buffer and the file region remains
* valid until the byte buffer is garbage collected.
- * </p>
* <p>
* All or part of a {@code MappedByteBuffer}'s content may change or become
* inaccessible at any time, since the mapped file region can be modified by
* another thread or process at any time. If this happens, the behavior of the
* {@code MappedByteBuffer} is undefined.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class MappedByteBuffer extends ByteBuffer {
@@ -59,15 +54,15 @@ public abstract class MappedByteBuffer extends ByteBuffer {
super(capa);
mapMode = mode;
switch (mapMode) {
- case IMemorySystem.MMAP_READ_ONLY:
- wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset);
- break;
- case IMemorySystem.MMAP_READ_WRITE:
- case IMemorySystem.MMAP_WRITE_COPY:
- wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset);
- break;
- default:
- throw new IllegalArgumentException();
+ case IMemorySystem.MMAP_READ_ONLY:
+ wrapped = new ReadOnlyDirectByteBuffer(addr, capa, offset);
+ break;
+ case IMemorySystem.MMAP_READ_WRITE:
+ case IMemorySystem.MMAP_WRITE_COPY:
+ wrapped = new ReadWriteDirectByteBuffer(addr, capa, offset);
+ break;
+ default:
+ throw new IllegalArgumentException();
}
addr.autoFree();
}
@@ -79,10 +74,10 @@ public abstract class MappedByteBuffer extends ByteBuffer {
*
* @return {@code true} if this buffer's content is loaded, {@code false}
* otherwise.
- * @since Android 1.0
*/
public final boolean isLoaded() {
- return ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapIsLoaded();
+ return ((MappedPlatformAddress) ((DirectBuffer) wrapped)
+ .getBaseAddress()).mmapIsLoaded();
}
/**
@@ -90,10 +85,10 @@ public abstract class MappedByteBuffer extends ByteBuffer {
* succeed.
*
* @return this buffer.
- * @since Android 1.0
*/
public final MappedByteBuffer load() {
- ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapLoad();
+ ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress())
+ .mmapLoad();
return this;
}
@@ -104,11 +99,11 @@ public abstract class MappedByteBuffer extends ByteBuffer {
* a remote device.
*
* @return this buffer.
- * @since Android 1.0
*/
public final MappedByteBuffer force() {
if (mapMode == IMemorySystem.MMAP_READ_WRITE) {
- ((MappedPlatformAddress)((DirectBuffer) wrapped).getBaseAddress()).mmapFlush();
+ ((MappedPlatformAddress) ((DirectBuffer) wrapped).getBaseAddress())
+ .mmapFlush();
}
return this;
}
diff --git a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
index 84866dc..54e009b 100644
--- a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
@@ -16,7 +16,6 @@
*/
// BEGIN android-note
-// updated to a newer version of harmony
// added some missing updates on position and limit
// END android-note
@@ -25,8 +24,8 @@ package java.nio;
import org.apache.harmony.luni.platform.PlatformAddress;
import org.apache.harmony.nio.internal.DirectBuffer;
-
-final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBuffer {
+final class MappedByteBufferAdapter extends MappedByteBuffer implements
+ DirectBuffer {
private static final int CHAR_SIZE = 2;
@@ -39,7 +38,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
private static final int FLOAT_SIZE = 4;
private static final int DOUBLE_SIZE = 8;
-
+
public MappedByteBufferAdapter(ByteBuffer buffer) {
super(buffer);
}
@@ -49,26 +48,32 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
super(addr, capa, offset, mode);
}
+ @Override
public CharBuffer asCharBuffer() {
return this.wrapped.asCharBuffer();
}
+ @Override
public DoubleBuffer asDoubleBuffer() {
return this.wrapped.asDoubleBuffer();
}
+ @Override
public FloatBuffer asFloatBuffer() {
return this.wrapped.asFloatBuffer();
}
+ @Override
public IntBuffer asIntBuffer() {
return this.wrapped.asIntBuffer();
}
+ @Override
public LongBuffer asLongBuffer() {
return this.wrapped.asLongBuffer();
}
+ @Override
public ByteBuffer asReadOnlyBuffer() {
MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
.asReadOnlyBuffer());
@@ -78,10 +83,12 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return buf;
}
+ @Override
public ShortBuffer asShortBuffer() {
return this.wrapped.asShortBuffer();
}
+ @Override
public ByteBuffer compact() {
if (this.wrapped.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -96,6 +103,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer duplicate() {
MappedByteBufferAdapter buf = new MappedByteBufferAdapter(this.wrapped
.duplicate());
@@ -105,20 +113,23 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return buf;
}
+ @Override
public byte get() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
- byte result = this.wrapped.get();
+ byte result = this.wrapped.get();
this.position++;
return result;
}
+ @Override
public byte get(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.get(index);
}
+ @Override
public char getChar() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -127,12 +138,14 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public char getChar(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.getChar(index);
}
+ @Override
public double getDouble() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -141,6 +154,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public double getDouble(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -155,6 +169,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
// END android-changed
}
+ @Override
public float getFloat() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -163,12 +178,14 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public float getFloat(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.getFloat(index);
}
+ @Override
public int getInt() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -177,12 +194,14 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public int getInt(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.getInt(index);
}
+ @Override
public long getLong() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -191,12 +210,14 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public long getLong(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.getLong(index);
}
+ @Override
public short getShort() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -205,25 +226,30 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
public short getShort(int index) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
return this.wrapped.getShort(index);
}
+ @Override
public boolean isDirect() {
return true;
}
+ @Override
public boolean isReadOnly() {
return this.wrapped.isReadOnly();
}
+ @Override
ByteBuffer orderImpl(ByteOrder byteOrder) {
super.orderImpl(byteOrder);
return this.wrapped.order(byteOrder);
}
+ @Override
public ByteBuffer put(byte b) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -232,6 +258,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -240,6 +267,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer put(int index, byte b) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -247,6 +275,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putChar(char value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -255,6 +284,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putChar(int index, char value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -262,6 +292,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putDouble(double value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -270,6 +301,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putDouble(int index, double value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -277,6 +309,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putFloat(float value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -285,6 +318,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putFloat(int index, float value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -292,6 +326,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putInt(int index, int value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -299,6 +334,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putInt(int value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -307,6 +343,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putLong(int index, long value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -314,6 +351,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putLong(long value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -322,6 +360,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putShort(int index, short value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -329,6 +368,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer putShort(short value) {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -337,6 +377,7 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return this;
}
+ @Override
public ByteBuffer slice() {
this.wrapped.limit(this.limit);
this.wrapped.position(this.position);
@@ -346,14 +387,17 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
return result;
}
+ @Override
byte[] protectedArray() {
return this.wrapped.protectedArray();
}
+ @Override
int protectedArrayOffset() {
return this.wrapped.protectedArrayOffset();
}
+ @Override
boolean protectedHasArray() {
return this.wrapped.protectedHasArray();
}
diff --git a/nio/src/main/java/java/nio/ReadOnlyBufferException.java b/nio/src/main/java/java/nio/ReadOnlyBufferException.java
index 62e2d5f..f860e3c 100644
--- a/nio/src/main/java/java/nio/ReadOnlyBufferException.java
+++ b/nio/src/main/java/java/nio/ReadOnlyBufferException.java
@@ -16,12 +16,9 @@
package java.nio;
-
/**
* A {@code ReadOnlyBufferException} is thrown when some write operation is
* called on a read-only buffer.
- *
- * @since Android 1.0
*/
public class ReadOnlyBufferException extends UnsupportedOperationException {
@@ -29,8 +26,6 @@ public class ReadOnlyBufferException extends UnsupportedOperationException {
/**
* Constructs a {@code ReadOnlyBufferException}.
- *
- * @since Android 1.0
*/
public ReadOnlyBufferException() {
super();
diff --git a/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java
index 461ea4f..54ef89f 100644
--- a/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyCharArrayBuffer.java
@@ -44,57 +44,71 @@ final class ReadOnlyCharArrayBuffer extends CharArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public CharBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public CharBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected char[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public CharBuffer put(char c) {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer put(int index, char c) {
throw new ReadOnlyBufferException();
}
+ @Override
public final CharBuffer put(char[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public final CharBuffer put(CharBuffer src) {
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer put(String src, int start, int end) {
- if ((start < 0 ) || (end < 0) || (long)start + (long)end > src.length()) {
+ if ((start < 0) || (end < 0)
+ || (long) start + (long) end > src.length()) {
throw new IndexOutOfBoundsException();
}
throw new ReadOnlyBufferException();
}
+ @Override
public CharBuffer slice() {
return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java b/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java
index bc0e1cc..ffa6e41 100644
--- a/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyDirectByteBuffer.java
@@ -52,79 +52,98 @@ final class ReadOnlyDirectByteBuffer extends DirectByteBuffer {
int offset) {
super(new SafeAddress(address), capacity, offset);
}
-
+
+ @Override
public ByteBuffer asReadOnlyBuffer() {
return copy(this, mark);
}
+ @Override
public ByteBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
public ByteBuffer put(byte value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer put(int index, byte value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ByteBuffer putDouble(double value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putDouble(int index, double value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putFloat(float value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putFloat(int index, float value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putInt(int value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putInt(int index, int value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putLong(int index, long value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putLong(long value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putShort(int index, short value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putShort(short value) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ByteBuffer put(ByteBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer slice() {
ReadOnlyDirectByteBuffer buf = new ReadOnlyDirectByteBuffer(
safeAddress, remaining(), offset + position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java
index 4f0b5d2..f71899b 100644
--- a/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyDoubleArrayBuffer.java
@@ -46,50 +46,62 @@ final class ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public DoubleBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public DoubleBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public DoubleBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected double[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public DoubleBuffer put(double c) {
throw new ReadOnlyBufferException();
}
+ @Override
public DoubleBuffer put(int index, double c) {
throw new ReadOnlyBufferException();
}
+ @Override
public final DoubleBuffer put(double[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public final DoubleBuffer put(DoubleBuffer buf) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public DoubleBuffer slice() {
return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
index 7559ffa..e8fb7d8 100644
--- a/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyFloatArrayBuffer.java
@@ -44,50 +44,62 @@ final class ReadOnlyFloatArrayBuffer extends FloatArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public FloatBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public FloatBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public FloatBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected float[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public FloatBuffer put(float c) {
throw new ReadOnlyBufferException();
}
+ @Override
public FloatBuffer put(int index, float c) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public FloatBuffer put(FloatBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final FloatBuffer put(float[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public FloatBuffer slice() {
return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java b/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java
index 857ecff..fba5e04 100644
--- a/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyHeapByteBuffer.java
@@ -45,90 +45,112 @@ final class ReadOnlyHeapByteBuffer extends HeapByteBuffer {
super(backingArray, capacity, arrayOffset);
}
+ @Override
public ByteBuffer asReadOnlyBuffer() {
return copy(this, mark);
}
+ @Override
public ByteBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected byte[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public ByteBuffer put(byte b) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer put(int index, byte b) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ByteBuffer putDouble(double value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putDouble(int index, double value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putFloat(float value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putFloat(int index, float value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putInt(int value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putInt(int index, int value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putLong(int index, long value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putLong(long value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putShort(int index, short value) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer putShort(short value) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ByteBuffer put(ByteBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public ByteBuffer slice() {
ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray,
remaining(), offset + position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
index ba9380e..cece133 100644
--- a/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyIntArrayBuffer.java
@@ -44,50 +44,62 @@ final class ReadOnlyIntArrayBuffer extends IntArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public IntBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public IntBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public IntBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected int[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public IntBuffer put(int c) {
throw new ReadOnlyBufferException();
}
+ @Override
public IntBuffer put(int index, int c) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public IntBuffer put(IntBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final IntBuffer put(int[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public IntBuffer slice() {
return new ReadOnlyIntArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java
index 76c1a4a..671f84f 100644
--- a/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyLongArrayBuffer.java
@@ -44,50 +44,62 @@ final class ReadOnlyLongArrayBuffer extends LongArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public LongBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public LongBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public LongBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected long[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public LongBuffer put(long c) {
throw new ReadOnlyBufferException();
}
+ @Override
public LongBuffer put(int index, long c) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public LongBuffer put(LongBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public final LongBuffer put(long[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public LongBuffer slice() {
return new ReadOnlyLongArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java b/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java
index 1a3bfd3..9730eb5 100644
--- a/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadOnlyShortArrayBuffer.java
@@ -44,50 +44,62 @@ final class ReadOnlyShortArrayBuffer extends ShortArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public ShortBuffer asReadOnlyBuffer() {
return duplicate();
}
+ @Override
public ShortBuffer compact() {
throw new ReadOnlyBufferException();
}
+ @Override
public ShortBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return true;
}
+ @Override
protected short[] protectedArray() {
throw new ReadOnlyBufferException();
}
+ @Override
protected int protectedArrayOffset() {
throw new ReadOnlyBufferException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
-
+
+ @Override
public ShortBuffer put(ShortBuffer buf) {
throw new ReadOnlyBufferException();
}
+ @Override
public ShortBuffer put(short c) {
throw new ReadOnlyBufferException();
}
+ @Override
public ShortBuffer put(int index, short c) {
throw new ReadOnlyBufferException();
}
+ @Override
public final ShortBuffer put(short[] src, int off, int len) {
throw new ReadOnlyBufferException();
}
-
+
+ @Override
public ShortBuffer slice() {
return new ReadOnlyShortArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java
index 08f79b2..584df53 100644
--- a/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteCharArrayBuffer.java
@@ -51,10 +51,12 @@ final class ReadWriteCharArrayBuffer extends CharArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public CharBuffer asReadOnlyBuffer() {
return ReadOnlyCharArrayBuffer.copy(this, mark);
}
+ @Override
public CharBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -64,26 +66,32 @@ final class ReadWriteCharArrayBuffer extends CharArrayBuffer {
return this;
}
+ @Override
public CharBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected char[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public CharBuffer put(char c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -92,6 +100,7 @@ final class ReadWriteCharArrayBuffer extends CharArrayBuffer {
return this;
}
+ @Override
public CharBuffer put(int index, char c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -100,19 +109,21 @@ final class ReadWriteCharArrayBuffer extends CharArrayBuffer {
return this;
}
+ @Override
public CharBuffer put(char[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)len + (long)off > length) {
+ if (off < 0 || len < 0 || (long) len + (long) off > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset+position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public CharBuffer slice() {
return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java b/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
index 95b4ebc..d976994 100644
--- a/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteDirectByteBuffer.java
@@ -65,17 +65,19 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
int anOffset) {
super(new SafeAddress(address), aCapacity, anOffset);
}
-
+
// BEGIN android-added
int getAddress() {
return this.safeAddress.address.toInt();
}
// END android-added
-
+
+ @Override
public ByteBuffer asReadOnlyBuffer() {
return ReadOnlyDirectByteBuffer.copy(this, mark);
}
+ @Override
public ByteBuffer compact() {
PlatformAddress effectiveAddress = getEffectiveAddress();
effectiveAddress.offsetBytes(position).moveTo(effectiveAddress,
@@ -86,14 +88,17 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
public ByteBuffer put(byte value) {
if (position == limit) {
throw new BufferOverflowException();
@@ -102,6 +107,7 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer put(int index, byte value) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -117,29 +123,26 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
*
* @see java.nio.ByteBuffer#put(byte[], int, int)
*/
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- if (isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
- getBaseAddress().setByteArray(offset + position, src, off,
- len);
+ getBaseAddress().setByteArray(offset + position, src, off, len);
position += len;
return this;
}
-
+
// BEGIN android-added
/**
* Writes <code>short</code>s in the given short array, starting from the
* specified offset, to the current position and increase the position by
* the number of <code>short</code>s written.
- *
+ *
* @param src
* The source short array
* @param off
@@ -179,7 +182,7 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
* Writes <code>int</code>s in the given int array, starting from the
* specified offset, to the current position and increase the position by
* the number of <code>int</code>s written.
- *
+ *
* @param src
* The source int array
* @param off
@@ -215,7 +218,8 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
// END android-added
-
+
+ @Override
public ByteBuffer putDouble(double value) {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -226,14 +230,16 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer putDouble(int index, double value) {
- if (index < 0 || (long)index + 8 > limit) {
+ if (index < 0 || (long) index + 8 > limit) {
throw new IndexOutOfBoundsException();
}
getBaseAddress().setDouble(offset + index, value, order);
return this;
}
+ @Override
public ByteBuffer putFloat(float value) {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -244,14 +250,16 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer putFloat(int index, float value) {
- if (index < 0 || (long)index + 4 > limit) {
+ if (index < 0 || (long) index + 4 > limit) {
throw new IndexOutOfBoundsException();
}
getBaseAddress().setFloat(offset + index, value, order);
return this;
}
+ @Override
public ByteBuffer putInt(int value) {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -262,14 +270,16 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer putInt(int index, int value) {
- if (index < 0 || (long)index + 4 > limit) {
+ if (index < 0 || (long) index + 4 > limit) {
throw new IndexOutOfBoundsException();
}
getBaseAddress().setInt(offset + index, value, order);
return this;
}
+ @Override
public ByteBuffer putLong(long value) {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -280,14 +290,16 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer putLong(int index, long value) {
- if (index < 0 || (long)index + 8 > limit) {
+ if (index < 0 || (long) index + 8 > limit) {
throw new IndexOutOfBoundsException();
}
getBaseAddress().setLong(offset + index, value, order);
return this;
}
+ @Override
public ByteBuffer putShort(short value) {
int newPosition = position + 2;
if (newPosition > limit) {
@@ -298,14 +310,16 @@ final class ReadWriteDirectByteBuffer extends DirectByteBuffer {
return this;
}
+ @Override
public ByteBuffer putShort(int index, short value) {
- if (index < 0 || (long)index + 2 > limit) {
+ if (index < 0 || (long) index + 2 > limit) {
throw new IndexOutOfBoundsException();
}
getBaseAddress().setShort(offset + index, value, order);
return this;
}
+ @Override
public ByteBuffer slice() {
ReadWriteDirectByteBuffer buf = new ReadWriteDirectByteBuffer(
safeAddress, remaining(), offset + position);
diff --git a/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java
index 2933178..689f3a1 100644
--- a/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteDoubleArrayBuffer.java
@@ -54,10 +54,12 @@ final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public DoubleBuffer asReadOnlyBuffer() {
return ReadOnlyDoubleArrayBuffer.copy(this, mark);
}
+ @Override
public DoubleBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -67,26 +69,32 @@ final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer {
return this;
}
+ @Override
public DoubleBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected double[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public DoubleBuffer put(double c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -95,6 +103,7 @@ final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer {
return this;
}
+ @Override
public DoubleBuffer put(int index, double c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -103,20 +112,21 @@ final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer {
return this;
}
+ @Override
public DoubleBuffer put(double[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public DoubleBuffer slice() {
return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java
index 49b0b11..50e8ce5 100644
--- a/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteFloatArrayBuffer.java
@@ -54,10 +54,12 @@ final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public FloatBuffer asReadOnlyBuffer() {
return ReadOnlyFloatArrayBuffer.copy(this, mark);
}
+ @Override
public FloatBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -67,26 +69,32 @@ final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer {
return this;
}
+ @Override
public FloatBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected float[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public FloatBuffer put(float c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -95,6 +103,7 @@ final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer {
return this;
}
+ @Override
public FloatBuffer put(int index, float c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -103,20 +112,21 @@ final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer {
return this;
}
+ @Override
public FloatBuffer put(float[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public FloatBuffer slice() {
return new ReadWriteFloatArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java b/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java
index af74054..677b439 100644
--- a/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteHeapByteBuffer.java
@@ -16,8 +16,6 @@
package java.nio;
-
-
/**
* HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose
* the implementation of array based byte buffers.
@@ -53,10 +51,12 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
super(backingArray, capacity, arrayOffset);
}
+ @Override
public ByteBuffer asReadOnlyBuffer() {
return ReadOnlyHeapByteBuffer.copy(this, mark);
}
+ @Override
public ByteBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -66,26 +66,32 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
return this;
}
+ @Override
public ByteBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected byte[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public ByteBuffer put(byte b) {
if (position == limit) {
throw new BufferOverflowException();
@@ -94,6 +100,7 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
return this;
}
+ @Override
public ByteBuffer put(int index, byte b) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -109,8 +116,9 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
*
* @see java.nio.ByteBuffer#put(byte[], int, int)
*/
+ @Override
public ByteBuffer put(byte[] src, int off, int len) {
- if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > src.length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -119,28 +127,32 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
if (isReadOnly()) {
throw new ReadOnlyBufferException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public ByteBuffer putDouble(double value) {
return putLong(Double.doubleToRawLongBits(value));
}
+ @Override
public ByteBuffer putDouble(int index, double value) {
return putLong(index, Double.doubleToRawLongBits(value));
}
+ @Override
public ByteBuffer putFloat(float value) {
return putInt(Float.floatToIntBits(value));
}
+ @Override
public ByteBuffer putFloat(int index, float value) {
return putInt(index, Float.floatToIntBits(value));
}
+ @Override
public ByteBuffer putInt(int value) {
int newPosition = position + 4;
if (newPosition > limit) {
@@ -151,22 +163,25 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
return this;
}
+ @Override
public ByteBuffer putInt(int index, int value) {
- if (index < 0 || (long)index + 4 > limit) {
+ if (index < 0 || (long) index + 4 > limit) {
throw new IndexOutOfBoundsException();
}
store(index, value);
return this;
}
+ @Override
public ByteBuffer putLong(int index, long value) {
- if (index < 0 || (long)index + 8 > limit) {
+ if (index < 0 || (long) index + 8 > limit) {
throw new IndexOutOfBoundsException();
}
store(index, value);
return this;
}
+ @Override
public ByteBuffer putLong(long value) {
int newPosition = position + 8;
if (newPosition > limit) {
@@ -177,14 +192,16 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
return this;
}
+ @Override
public ByteBuffer putShort(int index, short value) {
- if (index < 0 || (long)index + 2 > limit) {
+ if (index < 0 || (long) index + 2 > limit) {
throw new IndexOutOfBoundsException();
}
store(index, value);
return this;
}
+ @Override
public ByteBuffer putShort(short value) {
int newPosition = position + 2;
if (newPosition > limit) {
@@ -195,6 +212,7 @@ final class ReadWriteHeapByteBuffer extends HeapByteBuffer {
return this;
}
+ @Override
public ByteBuffer slice() {
ReadWriteHeapByteBuffer slice = new ReadWriteHeapByteBuffer(
backingArray, remaining(), offset + position);
diff --git a/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java
index 005e45b..a4be0b5 100644
--- a/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteIntArrayBuffer.java
@@ -51,10 +51,12 @@ final class ReadWriteIntArrayBuffer extends IntArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public IntBuffer asReadOnlyBuffer() {
return ReadOnlyIntArrayBuffer.copy(this, mark);
}
+ @Override
public IntBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -64,26 +66,32 @@ final class ReadWriteIntArrayBuffer extends IntArrayBuffer {
return this;
}
+ @Override
public IntBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected int[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public IntBuffer put(int c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -92,6 +100,7 @@ final class ReadWriteIntArrayBuffer extends IntArrayBuffer {
return this;
}
+ @Override
public IntBuffer put(int index, int c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -100,20 +109,21 @@ final class ReadWriteIntArrayBuffer extends IntArrayBuffer {
return this;
}
+ @Override
public IntBuffer put(int[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public IntBuffer slice() {
return new ReadWriteIntArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java
index ff2c588..2d8cdb0 100644
--- a/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteLongArrayBuffer.java
@@ -51,10 +51,12 @@ final class ReadWriteLongArrayBuffer extends LongArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public LongBuffer asReadOnlyBuffer() {
return ReadOnlyLongArrayBuffer.copy(this, mark);
}
+ @Override
public LongBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -64,26 +66,32 @@ final class ReadWriteLongArrayBuffer extends LongArrayBuffer {
return this;
}
+ @Override
public LongBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected long[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public LongBuffer put(long c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -92,6 +100,7 @@ final class ReadWriteLongArrayBuffer extends LongArrayBuffer {
return this;
}
+ @Override
public LongBuffer put(int index, long c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -100,20 +109,21 @@ final class ReadWriteLongArrayBuffer extends LongArrayBuffer {
return this;
}
+ @Override
public LongBuffer put(long[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset
- + position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public LongBuffer slice() {
return new ReadWriteLongArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java b/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java
index 193bdb3..0abbaf4 100644
--- a/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ReadWriteShortArrayBuffer.java
@@ -54,10 +54,12 @@ final class ReadWriteShortArrayBuffer extends ShortArrayBuffer {
super(capacity, backingArray, arrayOffset);
}
+ @Override
public ShortBuffer asReadOnlyBuffer() {
return ReadOnlyShortArrayBuffer.copy(this, mark);
}
+ @Override
public ShortBuffer compact() {
System.arraycopy(backingArray, position + offset, backingArray, offset,
remaining());
@@ -67,26 +69,32 @@ final class ReadWriteShortArrayBuffer extends ShortArrayBuffer {
return this;
}
+ @Override
public ShortBuffer duplicate() {
return copy(this, mark);
}
+ @Override
public boolean isReadOnly() {
return false;
}
+ @Override
protected short[] protectedArray() {
return backingArray;
}
+ @Override
protected int protectedArrayOffset() {
return offset;
}
+ @Override
protected boolean protectedHasArray() {
return true;
}
+ @Override
public ShortBuffer put(short c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -95,6 +103,7 @@ final class ReadWriteShortArrayBuffer extends ShortArrayBuffer {
return this;
}
+ @Override
public ShortBuffer put(int index, short c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -103,19 +112,21 @@ final class ReadWriteShortArrayBuffer extends ShortArrayBuffer {
return this;
}
+ @Override
public ShortBuffer put(short[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
- System.arraycopy(src, off, backingArray, offset+position, len);
+ System.arraycopy(src, off, backingArray, offset + position, len);
position += len;
return this;
}
-
+
+ @Override
public ShortBuffer slice() {
return new ReadWriteShortArrayBuffer(remaining(), backingArray, offset
+ position);
diff --git a/nio/src/main/java/java/nio/ShortArrayBuffer.java b/nio/src/main/java/java/nio/ShortArrayBuffer.java
index 54f8adb..e7d42a0 100644
--- a/nio/src/main/java/java/nio/ShortArrayBuffer.java
+++ b/nio/src/main/java/java/nio/ShortArrayBuffer.java
@@ -49,6 +49,7 @@ abstract class ShortArrayBuffer extends ShortBuffer {
this.offset = offset;
}
+ @Override
public final short get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -56,6 +57,7 @@ abstract class ShortArrayBuffer extends ShortBuffer {
return backingArray[offset + position++];
}
+ @Override
public final short get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -63,24 +65,26 @@ abstract class ShortArrayBuffer extends ShortBuffer {
return backingArray[offset + index];
}
+ @Override
public final ShortBuffer get(short[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
- System.arraycopy(backingArray, offset + position, dest,
- off, len);
+ System.arraycopy(backingArray, offset + position, dest, off, len);
position += len;
return this;
}
-
+
+ @Override
public final boolean isDirect() {
return false;
}
+ @Override
public final ByteOrder order() {
return ByteOrder.nativeOrder();
}
diff --git a/nio/src/main/java/java/nio/ShortBuffer.java b/nio/src/main/java/java/nio/ShortBuffer.java
index 39f9ddf..22d1b25 100644
--- a/nio/src/main/java/java/nio/ShortBuffer.java
+++ b/nio/src/main/java/java/nio/ShortBuffer.java
@@ -21,7 +21,6 @@ package java.nio;
* A buffer of shorts.
* <p>
* A short buffer can be created in either of the following ways:
- * </p>
* <ul>
* <li>{@link #allocate(int) Allocate} a new short array and create a buffer
* based on it;</li>
@@ -30,10 +29,9 @@ package java.nio;
* <li>Use {@link java.nio.ByteBuffer#asShortBuffer() ByteBuffer.asShortBuffer}
* to create a short buffer based on a byte buffer.</li>
* </ul>
- *
- * @since Android 1.0
*/
-public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuffer> {
+public abstract class ShortBuffer extends Buffer implements
+ Comparable<ShortBuffer> {
/**
* Creates a short buffer based on a newly allocated short array.
@@ -43,7 +41,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* @return the created short buffer.
* @throws IllegalArgumentException
* if {@code capacity} is less than zero.
- * @since Android 1.0
*/
public static ShortBuffer allocate(int capacity) {
if (capacity < 0) {
@@ -57,12 +54,10 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* Calling this method has the same effect as
* {@code wrap(array, 0, array.length)}.
- * </p>
- *
+ *
* @param array
* the short array which the new buffer will be based on.
* @return the created short buffer.
- * @since Android 1.0
*/
public static ShortBuffer wrap(short[] array) {
return wrap(array, 0, array.length);
@@ -73,8 +68,7 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* The new buffer's position will be {@code start}, limit will be
* {@code start + len}, capacity will be the length of the array.
- * </p>
- *
+ *
* @param array
* the short array which the new buffer will be based on.
* @param start
@@ -86,15 +80,14 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* @return the created short buffer.
* @exception IndexOutOfBoundsException
* if either {@code start} or {@code len} is invalid.
- * @since Android 1.0
*/
public static ShortBuffer wrap(short[] array, int start, int len) {
- if (array == null) {
- throw new NullPointerException();
- }
- if (start< 0 || len < 0 || (long)start + (long)len > array.length) {
- throw new IndexOutOfBoundsException();
- }
+ if (array == null) {
+ throw new NullPointerException();
+ }
+ if (start < 0 || len < 0 || (long) start + (long) len > array.length) {
+ throw new IndexOutOfBoundsException();
+ }
ShortBuffer buf = BufferFactory.newShortBuffer(array);
buf.position = start;
@@ -124,7 +117,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final short[] array() {
return protectedArray();
@@ -136,14 +128,12 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* The offset is the index of the array corresponding to the zero position
* of the buffer.
- * </p>
- *
+ *
* @return the offset of the short array which this buffer is based on.
* @exception ReadOnlyBufferException
* if this buffer is based on an array, but it is read-only.
* @exception UnsupportedOperationException
* if this buffer is not based on an array.
- * @since Android 1.0
*/
public final int arrayOffset() {
return protectedArrayOffset();
@@ -171,15 +161,12 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* The returned buffer is guaranteed to be a new instance, even if this
* buffer is read-only itself. The new buffer's position, limit, capacity
* and mark are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means this
* buffer's change of content will be visible to the new buffer. The two
* buffer's position, limit and mark are independent.
- * </p>
- *
+ *
* @return a read-only version of this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer asReadOnlyBuffer();
@@ -189,12 +176,10 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* The remaining shorts will be moved to the head of the buffer, starting
* from position zero. Then the position is set to {@code remaining()}; the
* limit is set to capacity; the mark is cleared.
- * </p>
- *
+ *
* @return this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer compact();
@@ -209,7 +194,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* greater than {@code otherBuffer}.
* @exception ClassCastException
* if {@code otherBuffer} is not a short buffer.
- * @since Android 1.0
*/
public int compareTo(ShortBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining()
@@ -236,15 +220,12 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* The duplicated buffer's position, limit, capacity and mark are the same
* as this buffer. The duplicated buffer's read-only property and byte order
* are the same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
- *
+ *
* @return a duplicated buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer duplicate();
@@ -254,14 +235,13 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* If {@code other} is not a short buffer then {@code false} is returned.
* Two short buffers are equal if and only if their remaining shorts are
* exactly the same. Position, limit, capacity and mark are not considered.
- * </p>
- *
+ *
* @param other
* the object to compare with this short buffer.
* @return {@code true} if this short buffer is equal to {@code other},
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
public boolean equals(Object other) {
if (!(other instanceof ShortBuffer)) {
return false;
@@ -289,7 +269,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* @return the short at the current position.
* @exception BufferUnderflowException
* if the position is equal or greater than limit.
- * @since Android 1.0
*/
public abstract short get();
@@ -299,14 +278,12 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* Calling this method has the same effect as
* {@code get(dest, 0, dest.length)}.
- * </p>
- *
+ *
* @param dest
* the destination short array.
* @return this buffer.
* @exception BufferUnderflowException
* if {@code dest.length} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public ShortBuffer get(short[] dest) {
return get(dest, 0, dest.length);
@@ -330,11 +307,10 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if either {@code off} or {@code len} is invalid.
* @exception BufferUnderflowException
* if {@code len} is greater than {@code remaining()}.
- * @since Android 1.0
*/
public ShortBuffer get(short[] dest, int off, int len) {
int length = dest.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
@@ -354,17 +330,15 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* @return a short at the specified index.
* @exception IndexOutOfBoundsException
* if index is invalid.
- * @since Android 1.0
*/
public abstract short get(int index);
/**
* Indicates whether this buffer is based on a short array and is
* read/write.
- *
+ *
* @return {@code true} if this buffer is based on a short array and
* provides read/write access, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean hasArray() {
return protectedHasArray();
@@ -373,10 +347,10 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
/**
* Calculates this buffer's hash code from the remaining chars. The
* position, limit, capacity and mark don't affect the hash code.
- *
+ *
* @return the hash code calculated from the remaining shorts.
- * @since Android 1.0
*/
+ @Override
public int hashCode() {
int myPosition = position;
int hash = 0;
@@ -393,10 +367,8 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* A short buffer is direct if it is based on a byte buffer and the byte
* buffer is direct.
- * </p>
- *
+ *
* @return {@code true} if this buffer is direct, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isDirect();
@@ -406,11 +378,9 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* If this buffer is not based on a byte buffer, then always return the
* platform's native byte order.
- * </p>
- *
+ *
* @return the byte order used by this buffer when converting shorts from/to
* bytes.
- * @since Android 1.0
*/
public abstract ByteOrder order();
@@ -446,7 +416,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if position is equal or greater than limit.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer put(short s);
@@ -456,8 +425,7 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* <p>
* Calling this method has the same effect as
* {@code put(src, 0, src.length)}.
- * </p>
- *
+ *
* @param src
* the source short array.
* @return this buffer.
@@ -465,7 +433,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if {@code remaining()} is less than {@code src.length}.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public final ShortBuffer put(short[] src) {
return put(src, 0, src.length);
@@ -491,14 +458,13 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if either {@code off} or {@code len} is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public ShortBuffer put(short[] src, int off, int len) {
int length = src.length;
- if (off < 0 || len < 0 || (long)off + (long)len > length) {
+ if (off < 0 || len < 0 || (long) off + (long) len > length) {
throw new IndexOutOfBoundsException();
}
-
+
if (len > remaining()) {
throw new BufferOverflowException();
}
@@ -523,7 +489,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if {@code src} is this buffer.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public ShortBuffer put(ShortBuffer src) {
if (src == this) {
@@ -551,7 +516,6 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* if index is invalid.
* @exception ReadOnlyBufferException
* if no changes may be made to the contents of this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer put(int index, short s);
@@ -563,15 +527,12 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* The new buffer's position will be 0, limit will be its capacity, and its
* mark is cleared. The new buffer's read-only property and byte order are
* same as this buffer's.
- * </p>
* <p>
* The new buffer shares its content with this buffer, which means either
* buffer's change of content will be visible to the other. The two buffer's
* position, limit and mark are independent.
- * </p>
*
* @return a sliced buffer that shares its content with this buffer.
- * @since Android 1.0
*/
public abstract ShortBuffer slice();
@@ -579,10 +540,10 @@ public abstract class ShortBuffer extends Buffer implements Comparable<ShortBuff
* Returns a string representing the state of this short buffer.
*
* @return a string representing the state of this short buffer.
- * @since Android 1.0
*/
+ @Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append(", status: capacity="); //$NON-NLS-1$
buf.append(capacity());
diff --git a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
index a608bc9..f2a795f 100644
--- a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
@@ -16,11 +16,8 @@
package java.nio;
-// BEGIN android-added
-// Copied from newer version of harmony
import org.apache.harmony.nio.internal.DirectBuffer;
import org.apache.harmony.luni.platform.PlatformAddress;
-// END android-added
/**
* This class wraps a byte buffer to be a short buffer.
@@ -33,12 +30,9 @@ import org.apache.harmony.luni.platform.PlatformAddress;
* The adapter extends Buffer, thus has its own position and limit.</li>
* </ul>
* </p>
- *
*/
-// BEGIN android-changed
-// Copied from newer version of harmony
-final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer {
-// END android-changed
+final class ShortToByteBufferAdapter extends ShortBuffer implements
+ DirectBuffer {
static ShortBuffer wrap(ByteBuffer byteBuffer) {
return new ShortToByteBufferAdapter(byteBuffer.slice());
@@ -52,15 +46,12 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
this.byteBuffer.clear();
}
-// BEGIN android-added
-// Copied from newer version of harmony
public int getByteCapacity() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getByteCapacity();
- } else {
- assert false : byteBuffer;
- return -1;
- }
+ return ((DirectBuffer) byteBuffer).getByteCapacity();
+ }
+ assert false : byteBuffer;
+ return -1;
}
public PlatformAddress getEffectiveAddress() {
@@ -70,47 +61,44 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
effectiveDirectAddress = addr.toInt();
return addr;
// END android-changed
- } else {
- assert false : byteBuffer;
- return null;
}
+ assert false : byteBuffer;
+ return null;
}
public PlatformAddress getBaseAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getBaseAddress();
- } else {
- assert false : byteBuffer;
- return null;
+ return ((DirectBuffer) byteBuffer).getBaseAddress();
}
+ assert false : byteBuffer;
+ return null;
}
-
+
public boolean isAddressValid() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).isAddressValid();
- } else {
- assert false : byteBuffer;
- return false;
+ return ((DirectBuffer) byteBuffer).isAddressValid();
}
+ assert false : byteBuffer;
+ return false;
}
public void addressValidityCheck() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).addressValidityCheck();
+ ((DirectBuffer) byteBuffer).addressValidityCheck();
} else {
assert false : byteBuffer;
}
}
-
+
public void free() {
if (byteBuffer instanceof DirectBuffer) {
- ((DirectBuffer)byteBuffer).free();
+ ((DirectBuffer) byteBuffer).free();
} else {
assert false : byteBuffer;
- }
+ }
}
- // END android-added
+ @Override
public ShortBuffer asReadOnlyBuffer() {
ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer
.asReadOnlyBuffer());
@@ -120,6 +108,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return buf;
}
+ @Override
public ShortBuffer compact() {
if (byteBuffer.isReadOnly()) {
throw new ReadOnlyBufferException();
@@ -134,6 +123,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return this;
}
+ @Override
public ShortBuffer duplicate() {
ShortToByteBufferAdapter buf = new ShortToByteBufferAdapter(byteBuffer
.duplicate());
@@ -143,6 +133,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return buf;
}
+ @Override
public short get() {
if (position == limit) {
throw new BufferUnderflowException();
@@ -150,6 +141,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return byteBuffer.getShort(position++ << 1);
}
+ @Override
public short get(int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -157,30 +149,37 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return byteBuffer.getShort(index << 1);
}
+ @Override
public boolean isDirect() {
return byteBuffer.isDirect();
}
+ @Override
public boolean isReadOnly() {
return byteBuffer.isReadOnly();
}
+ @Override
public ByteOrder order() {
return byteBuffer.order();
}
+ @Override
protected short[] protectedArray() {
throw new UnsupportedOperationException();
}
+ @Override
protected int protectedArrayOffset() {
throw new UnsupportedOperationException();
}
+ @Override
protected boolean protectedHasArray() {
return false;
}
+ @Override
public ShortBuffer put(short c) {
if (position == limit) {
throw new BufferOverflowException();
@@ -189,6 +188,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
return this;
}
+ @Override
public ShortBuffer put(int index, short c) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
@@ -196,7 +196,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
byteBuffer.putShort(index << 1, c);
return this;
}
-
+
// BEGIN android-added
@Override
public ShortBuffer put(short[] s, int off, int len) {
@@ -212,6 +212,7 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
}
// END android-added
+ @Override
public ShortBuffer slice() {
byteBuffer.limit(limit << 1);
byteBuffer.position(position << 1);
diff --git a/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java b/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
index d558492..5e09b1c 100644
--- a/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
+++ b/nio/src/main/java/java/nio/channels/AlreadyConnectedException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code AlreadyConnectedException} is thrown when an attempt is made to
* connect a SocketChannel that is already connected.
- *
- * @since Android 1.0
*/
public class AlreadyConnectedException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class AlreadyConnectedException extends IllegalStateException {
/**
* Constructs an {@code AlreadyConnectedException}.
- *
- * @since Android 1.0
*/
public AlreadyConnectedException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java b/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
index e34d8d0..c2d285a 100644
--- a/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
+++ b/nio/src/main/java/java/nio/channels/AsynchronousCloseException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code AsynchronousCloseException} is thrown when the underlying channel
* for an I/O operation is closed by another thread.
- *
- * @since Android 1.0
*/
public class AsynchronousCloseException extends ClosedChannelException {
@@ -29,11 +26,8 @@ public class AsynchronousCloseException extends ClosedChannelException {
/**
* Constructs an {@code AsynchronousCloseException}.
- *
- * @since Android 1.0
*/
public AsynchronousCloseException() {
super();
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/ByteChannel.java b/nio/src/main/java/java/nio/channels/ByteChannel.java
index 97f5d23..383d350 100644
--- a/nio/src/main/java/java/nio/channels/ByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ByteChannel.java
@@ -16,17 +16,14 @@
package java.nio.channels;
-
/**
* A ByteChannel is both readable and writable.
* <p>
* The methods for the byte channel are precisely those defined by readable and
* writable byte channels.
- * </p>
- *
+ *
* @see ReadableByteChannel
* @see WritableByteChannel
- * @since Android 1.0
*/
public interface ByteChannel extends ReadableByteChannel, WritableByteChannel {
// No methods defined.
diff --git a/nio/src/main/java/java/nio/channels/CancelledKeyException.java b/nio/src/main/java/java/nio/channels/CancelledKeyException.java
index ebb7c76..e955b3c 100644
--- a/nio/src/main/java/java/nio/channels/CancelledKeyException.java
+++ b/nio/src/main/java/java/nio/channels/CancelledKeyException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* A {@code CancelledKeyException} is thrown when an invalid selection key is
* used.
- *
- * @since Android 1.0
*/
public class CancelledKeyException extends IllegalStateException {
@@ -32,8 +29,6 @@ public class CancelledKeyException extends IllegalStateException {
/**
* Constructs a {@code CancelledKeyException}.
- *
- * @since Android 1.0
*/
public CancelledKeyException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/Channel.java b/nio/src/main/java/java/nio/channels/Channel.java
index 585ce29..f31c565 100644
--- a/nio/src/main/java/java/nio/channels/Channel.java
+++ b/nio/src/main/java/java/nio/channels/Channel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.Closeable;
import java.io.IOException;
@@ -27,13 +26,9 @@ import java.io.IOException;
* Channels are open upon creation, and can be closed explicitly. Once a channel
* is closed it cannot be re-opened, and any attempts to perform I/O operations
* on the closed channel result in a <code>ClosedChannelException</code>.
- * </p>
* <p>
* Particular implementations or sub-interfaces of {@code Channel} dictate
* whether they are thread-safe or not.
- * </p>
- *
- * @since Android 1.0
*/
public interface Channel extends Closeable {
@@ -41,7 +36,6 @@ public interface Channel extends Closeable {
* Returns whether this channel is open or not.
*
* @return true if the channel is open, otherwise returns false.
- * @since Android 1.0
*/
public boolean isOpen();
@@ -53,16 +47,13 @@ public interface Channel extends Closeable {
* <p>
* If an attempt is made to perform an operation on a closed channel then a
* {@link ClosedChannelException} will be thrown on that attempt.
- * </p>
* <p>
* If multiple threads attempt to simultaneously close a channel, then only
* one thread will run the closure code, and others will be blocked until
* the first returns.
- * </p>
- *
+ *
* @throws IOException
* if a problem occurs closing the channel.
- * @since Android 1.0
*/
public void close() throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/Channels.java b/nio/src/main/java/java/nio/channels/Channels.java
index fa70dc0..f29ca74 100644
--- a/nio/src/main/java/java/nio/channels/Channels.java
+++ b/nio/src/main/java/java/nio/channels/Channels.java
@@ -32,14 +32,9 @@ import org.apache.harmony.nio.internal.IOUtil;
/**
* This class provides several utilities to get I/O streams from channels.
- *
- * @since Android 1.0
*/
public final class Channels {
- // -------------------------------------------------------------------
- // Constructor
- // -------------------------------------------------------------------
/*
* Not intended to be instantiated.
*/
@@ -47,10 +42,6 @@ public final class Channels {
super();
}
- // -------------------------------------------------------------------
- // Public Methods
- // -------------------------------------------------------------------
-
/**
* Returns an input stream on the given channel. The resulting stream has
* the following properties:
@@ -67,7 +58,6 @@ public final class Channels {
* @param channel
* the channel to be wrapped by an InputStream.
* @return an InputStream that takes bytes from the given byte channel.
- * @since Android 1.0
*/
public static InputStream newInputStream(ReadableByteChannel channel) {
return new ReadableByteChannelInputStream(channel);
@@ -88,7 +78,6 @@ public final class Channels {
* @param channel
* the channel to be wrapped by an OutputStream.
* @return an OutputStream that puts bytes onto the given byte channel.
- * @since Android 1.0
*/
public static OutputStream newOutputStream(WritableByteChannel channel) {
return new WritableByteChannelOutputStream(channel);
@@ -106,7 +95,6 @@ public final class Channels {
* @param inputStream
* the stream to be wrapped by a byte channel.
* @return a byte channel that reads bytes from the input stream.
- * @since Android 1.0
*/
public static ReadableByteChannel newChannel(InputStream inputStream) {
return new ReadableByteChannelImpl(inputStream);
@@ -121,11 +109,10 @@ public final class Channels {
* well.</li>
* <li>It is not buffered.</li>
* </ul>
- *
+ *
* @param outputStream
* the stream to be wrapped by a byte channel.
* @return a byte channel that writes bytes to the output stream.
- * @since Android 1.0
*/
public static WritableByteChannel newChannel(OutputStream outputStream) {
return new WritableByteChannelImpl(outputStream);
@@ -142,12 +129,10 @@ public final class Channels {
* The minimum size of the byte buffer, -1 means to use the
* default size.
* @return the reader.
- * @since Android 1.0
*/
public static Reader newReader(ReadableByteChannel channel,
CharsetDecoder decoder, int minBufferCapacity) {
- return new ByteChannelReader(
- new ReaderInputStream(channel), decoder,
+ return new ByteChannelReader(new ReaderInputStream(channel), decoder,
minBufferCapacity);
}
@@ -162,7 +147,6 @@ public final class Channels {
* @return the reader.
* @throws java.nio.charset.UnsupportedCharsetException
* if the given charset name is not supported.
- * @since Android 1.0
*/
public static Reader newReader(ReadableByteChannel channel,
String charsetName) {
@@ -181,7 +165,6 @@ public final class Channels {
* the minimum size of the byte buffer, -1 means to use the
* default size.
* @return the writer.
- * @since Android 1.0
*/
public static Writer newWriter(WritableByteChannel channel,
CharsetEncoder encoder, int minBufferCapacity) {
@@ -201,16 +184,12 @@ public final class Channels {
* @return the writer.
* @throws java.nio.charset.UnsupportedCharsetException
* if the given charset name is not supported.
- * @since Android 1.0
*/
public static Writer newWriter(WritableByteChannel channel,
String charsetName) {
return newWriter(channel, Charset.forName(charsetName).newEncoder(), -1);
}
- // -------------------------------------------------------------------
- // share routine
- // -------------------------------------------------------------------
/*
* wrap a byte array to a ByteBuffer
*/
@@ -223,10 +202,6 @@ public final class Channels {
return buffer;
}
- // -------------------------------------------------------------------
- // Wrapper classes
- // -------------------------------------------------------------------
-
private static class ChannelInputStream extends InputStream {
protected ReadableByteChannel channel;
@@ -236,9 +211,6 @@ public final class Channels {
channel = aChannel;
}
- /*
- * @see java.io.InputStream#read()
- */
@Override
public synchronized int read() throws IOException {
byte[] oneByte = new byte[1];
@@ -250,9 +222,6 @@ public final class Channels {
return -1;
}
- /*
- * @see java.io.InputStream#close()
- */
@Override
public synchronized void close() throws IOException {
channel.close();
@@ -265,16 +234,10 @@ public final class Channels {
private static class ReadableByteChannelInputStream extends
ChannelInputStream {
- /*
- * @param someChannel
- */
public ReadableByteChannelInputStream(ReadableByteChannel aChannel) {
super(aChannel);
}
- /*
- * @see java.io.InputStream#read(byte[], int, int)
- */
@Override
public synchronized int read(byte[] target, int offset, int length)
throws IOException {
@@ -301,16 +264,10 @@ public final class Channels {
*/
private static class ReaderInputStream extends ChannelInputStream {
- /*
- * @param someChannel
- */
public ReaderInputStream(ReadableByteChannel aChannel) {
super(aChannel);
}
- /*
- * @see java.io.InputStream#read(byte[], int, int)
- */
@Override
public synchronized int read(byte[] target, int offset, int length)
throws IOException {
@@ -333,26 +290,19 @@ public final class Channels {
private WritableByteChannel channel;
- /*
- * @param someChannel
- */
public WritableByteChannelOutputStream(WritableByteChannel aChannel) {
super();
channel = aChannel;
}
- /*
- * @see java.io.OutputStream#write(int)
- */
+ @Override
public synchronized void write(int oneByte) throws IOException {
byte[] wrappedByte = new byte[1];
wrappedByte[0] = (byte) oneByte;
write(wrappedByte);
}
- /*
- * @see java.io.OutputStream#write(byte[], int, int)
- */
+ @Override
public synchronized void write(byte[] source, int offset, int length)
throws IOException {
// avoid int overflow, check null source
@@ -371,9 +321,7 @@ public final class Channels {
channel.write(buffer);
}
- /*
- * @see java.io.OutputStream#close()
- */
+ @Override
public synchronized void close() throws IOException {
channel.close();
}
@@ -391,9 +339,6 @@ public final class Channels {
inputStream = aInputStream;
}
- /*
- * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
- */
public synchronized int read(ByteBuffer target) throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
@@ -413,9 +358,7 @@ public final class Channels {
return readCount;
}
- /*
- * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
- */
+ @Override
protected void implCloseChannel() throws IOException {
inputStream.close();
}
@@ -433,9 +376,6 @@ public final class Channels {
outputStream = aOutputStream;
}
- /*
- * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
- */
public synchronized int write(ByteBuffer source) throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
@@ -455,9 +395,7 @@ public final class Channels {
return bytesRemain;
}
- /*
- * @see java.nio.channels.spi.AbstractInterruptibleChannel#implCloseChannel()
- */
+ @Override
protected void implCloseChannel() throws IOException {
outputStream.close();
}
@@ -479,9 +417,6 @@ public final class Channels {
CharBuffer chars;
- /*
- * @param inputStream @param dec @param minBufferCapacity
- */
public ByteChannelReader(InputStream aInputStream,
CharsetDecoder aDecoder, int minBufferCapacity) {
super(aInputStream);
@@ -494,9 +429,7 @@ public final class Channels {
chars.limit(0);
}
- /*
- * @see java.io.Reader#close()
- */
+ @Override
public void close() throws IOException {
synchronized (lock) {
decoder = null;
@@ -507,9 +440,7 @@ public final class Channels {
}
}
- /*
- * @see java.io.Reader#ready()
- */
+ @Override
public boolean ready() {
synchronized (lock) {
if (null == inputStream) {
@@ -524,20 +455,16 @@ public final class Channels {
}
}
- /*
- * @see java.io.Reader#read()
- */
+ @Override
public int read() throws IOException {
- return IOUtil.readInputStreamReader(inputStream,
- bytes, chars, decoder, lock);
+ return IOUtil.readInputStreamReader(inputStream, bytes, chars,
+ decoder, lock);
}
- /*
- * @see java.io.Reader#read(char[], int, int)
- */
+ @Override
public int read(char[] buf, int offset, int length) throws IOException {
- return IOUtil.readInputStreamReader(buf, offset,
- length, inputStream, bytes, chars, decoder, lock);
+ return IOUtil.readInputStreamReader(buf, offset, length,
+ inputStream, bytes, chars, decoder, lock);
}
}
@@ -555,9 +482,6 @@ public final class Channels {
private ByteBuffer byteBuf;
- /*
- * @param outputStream @param enc @param minBufferCap
- */
public ByteChannelWriter(OutputStream aOutputStream,
CharsetEncoder aEncoder, int minBufferCap) {
super(aOutputStream);
@@ -567,9 +491,7 @@ public final class Channels {
encoder = aEncoder;
}
- /*
- * @see java.io.Writer#close()
- */
+ @Override
public void close() throws IOException {
synchronized (lock) {
if (encoder != null) {
@@ -582,37 +504,29 @@ public final class Channels {
}
}
- /*
- * @see java.io.Writer#flush()
- */
+ @Override
public void flush() throws IOException {
- IOUtil.flushOutputStreamWriter(outputStream,
- byteBuf, encoder, lock);
+ IOUtil
+ .flushOutputStreamWriter(outputStream, byteBuf, encoder,
+ lock);
}
- /*
- * @see java.io.Writer#write(char[], int, int)
- */
+ @Override
public void write(char[] buf, int offset, int count) throws IOException {
- IOUtil.writeOutputStreamWriter(buf, offset, count,
- outputStream, byteBuf, encoder, lock);
+ IOUtil.writeOutputStreamWriter(buf, offset, count, outputStream,
+ byteBuf, encoder, lock);
}
- /*
- * @see java.io.Writer#write(int)
- */
+ @Override
public void write(int oneChar) throws IOException {
- IOUtil.writeOutputStreamWriter(oneChar,
- outputStream, byteBuf, encoder, lock);
+ IOUtil.writeOutputStreamWriter(oneChar, outputStream, byteBuf,
+ encoder, lock);
}
- /*
- * @see java.io.Writer#write(java.lang.String, int, int)
- */
+ @Override
public void write(String str, int offset, int count) throws IOException {
- IOUtil.writeOutputStreamWriter(str, offset, count,
- outputStream, byteBuf, encoder, lock);
+ IOUtil.writeOutputStreamWriter(str, offset, count, outputStream,
+ byteBuf, encoder, lock);
}
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java b/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
index c7d5c6a..cc4c5eb 100644
--- a/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedByInterruptException.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
/**
* A {@code ClosedByInterruptException} is thrown when a thread is interrupted
* in a blocking I/O operation.
@@ -24,9 +23,6 @@ package java.nio.channels;
* When the thread is interrupted by a call to {@code interrupt()}, it closes
* the channel, sets the interrupt status of the thread to {@code true} and
* throws a {@code ClosedByInterruptException}.
- * </p>
- *
- * @since Android 1.0
*/
public class ClosedByInterruptException extends AsynchronousCloseException {
@@ -34,8 +30,6 @@ public class ClosedByInterruptException extends AsynchronousCloseException {
/**
* Constructs a {@code ClosedByInterruptException}.
- *
- * @since Android 1.0
*/
public ClosedByInterruptException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/ClosedChannelException.java b/nio/src/main/java/java/nio/channels/ClosedChannelException.java
index 4cf4b38..2b77601 100644
--- a/nio/src/main/java/java/nio/channels/ClosedChannelException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedChannelException.java
@@ -16,14 +16,11 @@
package java.nio.channels;
-
import java.io.IOException;
/**
* A {@code ClosedChannelException} is thrown when a channel is closed for the
* type of operation attempted.
- *
- * @since Android 1.0
*/
public class ClosedChannelException extends IOException {
@@ -31,11 +28,8 @@ public class ClosedChannelException extends IOException {
/**
* Constructs a {@code ClosedChannelException}.
- *
- * @since Android 1.0
*/
public ClosedChannelException() {
super();
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/ClosedSelectorException.java b/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
index 0fb16d3..5acc878 100644
--- a/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
+++ b/nio/src/main/java/java/nio/channels/ClosedSelectorException.java
@@ -16,25 +16,18 @@
package java.nio.channels;
-
/**
* A {@code ClosedSelectorException} is thrown when a {@link Selector selector}
* is closed and an I/O operation is attempted.
- *
- * @since Android 1.0
*/
public class ClosedSelectorException extends IllegalStateException {
private static final long serialVersionUID = 6466297122317847835L;
-
+
/**
* Constructs a {@code ClosedSelectorException}.
- *
- * @since Android 1.0
*/
public ClosedSelectorException() {
super();
}
}
-
-
diff --git a/nio/src/main/java/java/nio/channels/ConnectionPendingException.java b/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
index c535925..43ff65cd 100644
--- a/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
+++ b/nio/src/main/java/java/nio/channels/ConnectionPendingException.java
@@ -16,13 +16,10 @@
package java.nio.channels;
-
/**
* A {@code ConnectionPendingException} is thrown when an attempt is made to
* connect a {@link SocketChannel} that has a non-blocking connection already
* underway.
- *
- * @since Android 1.0
*/
public class ConnectionPendingException extends IllegalStateException {
@@ -30,11 +27,8 @@ public class ConnectionPendingException extends IllegalStateException {
/**
* Constructs a {@code ConnectionPendingException}.
- *
- * @since Android 1.0
*/
public ConnectionPendingException() {
super();
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/DatagramChannel.java b/nio/src/main/java/java/nio/channels/DatagramChannel.java
index 534155a..31b0825 100644
--- a/nio/src/main/java/java/nio/channels/DatagramChannel.java
+++ b/nio/src/main/java/java/nio/channels/DatagramChannel.java
@@ -37,13 +37,9 @@ import org.apache.harmony.luni.platform.Platform;
* status until it is disconnected or closed. The benefit of a connected channel
* is the reduced effort of security checks during send and receive. When
* invoking {@code read} or {@code write}, a connected channel is required.
- * </p>
* <p>
* Datagram channels are thread-safe; only one thread can read or write at the
* same time.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class DatagramChannel extends AbstractSelectableChannel
implements ByteChannel, ScatteringByteChannel, GatheringByteChannel {
@@ -51,13 +47,12 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
static {
Platform.getNetworkSystem().oneTimeInitialization(true);
}
-
+
/**
* Constructs a new {@code DatagramChannel}.
*
* @param selectorProvider
* an instance of SelectorProvider.
- * @since Android 1.0
*/
protected DatagramChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
@@ -68,12 +63,10 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* <p>
* This channel is created by calling the <code>openDatagramChannel</code>
* method of the default {@link SelectorProvider} instance.
- * </p>
- *
+ *
* @return the new channel which is open but not connected.
* @throws IOException
* if some I/O error occurs.
- * @since Android 1.0
*/
public static DatagramChannel open() throws IOException {
return SelectorProvider.provider().openDatagramChannel();
@@ -86,8 +79,8 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
*
* @see java.nio.channels.SelectableChannel#validOps()
* @return valid operations in bit-set.
- * @since Android 1.0
*/
+ @Override
public final int validOps() {
return (SelectionKey.OP_READ | SelectionKey.OP_WRITE);
}
@@ -98,7 +91,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* {@link DatagramSocket}.
*
* @return the related DatagramSocket instance.
- * @since Android 1.0
*/
public abstract DatagramSocket socket();
@@ -107,7 +99,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
*
* @return <code>true</code> if this channel's socket is connected;
* <code>false</code> otherwise.
- * @since Android 1.0
*/
public abstract boolean isConnected();
@@ -120,12 +111,10 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* write operations being processed at the time the method is called. The
* connection status does not change until the channel is disconnected or
* closed.
- * </p>
* <p>
* This method executes the same security checks as the connect method of
* the {@link DatagramSocket} class.
- * </p>
- *
+ *
* @param address
* the address to be connected to.
* @return this channel.
@@ -143,7 +132,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* permitted to be accessed.
* @throws IOException
* if some other I/O error occurrs.
- * @since Android 1.0
*/
public abstract DatagramChannel connect(SocketAddress address)
throws IOException;
@@ -155,12 +143,10 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* This method can be called at any time without affecting the read and
* write operations being underway. It does not have any effect if the
* socket is not connected or the channel is closed.
- * </p>
- *
+ *
* @return this channel.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract DatagramChannel disconnect() throws IOException;
@@ -174,16 +160,13 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* immediately. The transfer starts at the current position of the buffer,
* and if there is not enough space remaining in the buffer to store the
* datagram then the part of the datagram that does not fit is discarded.
- * </p>
* <p>
* This method can be called at any time and it will block if there is
* another thread that has started a read operation on the channel.
- * </p>
* <p>
* This method executes the same security checks as the receive method of
* the {@link DatagramSocket} class.
- * </p>
- *
+ *
* @param target
* the byte buffer to store the received datagram.
* @return the address of the datagram if the transfer is performed, or null
@@ -203,7 +186,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* permitted to be accessed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract SocketAddress receive(ByteBuffer target) throws IOException;
@@ -216,16 +198,13 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* in non-blocking mode then the datagram is only sent if there is enough
* space in the underlying output buffer at that moment. The transfer action
* is just like a regular write operation.
- * </p>
* <p>
* This method can be called at any time and it will block if another thread
* has started a send operation on this channel.
- * </p>
* <p>
* This method executes the same security checks as the send method of the
* {@link DatagramSocket} class.
- * </p>
- *
+ *
* @param source
* the byte buffer with the datagram to be sent.
* @param address
@@ -248,7 +227,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* permitted to access.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract int send(ByteBuffer source, SocketAddress address)
throws IOException;
@@ -262,8 +240,7 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* not fit in the buffer is discarded. Otherwise, this method has the same
* behavior as the {@code read} method in the {@link ReadableByteChannel}
* interface.
- * </p>
- *
+ *
* @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
* @param target
* the byte buffer to store the received datagram.
@@ -282,7 +259,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract int read(ByteBuffer target) throws IOException;
@@ -295,8 +271,7 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* datagram that does not fit in the buffers is discarded. Otherwise, this
* method has the same behavior as the {@code read} method in the
* {@link ScatteringByteChannel} interface.
- * </p>
- *
+ *
* @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
* int, int)
* @param targets
@@ -324,7 +299,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract long read(ByteBuffer[] targets, int offset, int length)
throws IOException;
@@ -338,8 +312,7 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* datagram that does not fit in the buffers is discarded. Otherwise, this
* method has the same behavior as the {@code read} method in the
* {@link ScatteringByteChannel} interface.
- * </p>
- *
+ *
* @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[])
* @param targets
* the byte buffers to store the received datagram.
@@ -358,7 +331,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public synchronized final long read(ByteBuffer[] targets)
throws IOException {
@@ -372,8 +344,7 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* and the datagram is sent to the connected address. Otherwise, this method
* has the same behavior as the {@code write} method in the
* {@link WritableByteChannel} interface.
- * </p>
- *
+ *
* @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
* @param source
* the byte buffer as the source of the datagram.
@@ -391,7 +362,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract int write(ByteBuffer source) throws IOException;
@@ -432,7 +402,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public abstract long write(ByteBuffer[] sources, int offset, int length)
throws IOException;
@@ -465,7 +434,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
* interrupt state set and the channel will be closed.
* @throws IOException
* some other I/O error occurs.
- * @since Android 1.0
*/
public synchronized final long write(ByteBuffer[] sources)
throws IOException {
diff --git a/nio/src/main/java/java/nio/channels/FileChannel.java b/nio/src/main/java/java/nio/channels/FileChannel.java
index 0518fd3..2c30bae 100644
--- a/nio/src/main/java/java/nio/channels/FileChannel.java
+++ b/nio/src/main/java/java/nio/channels/FileChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
@@ -30,7 +29,6 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
* does not have a method for opening files, since this behavior has been
* delegated to the {@link java.io.FileInputStream},
* {@link java.io.FileOutputStream} and {@link java.io.RandomAccessFile} types.
- * </p>
* <p>
* FileChannels created from a {@code FileInputStream} or a
* {@code RandomAccessFile} created in mode "r", are read-only. FileChannels
@@ -39,19 +37,16 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
* FileChannels created from a {@code RandomAccessFile} that was opened in
* append-mode will also be in append-mode -- meaning that each write will be
* proceeded by a seek to the end of file.
- * </p>
* <p>
* FileChannels have a virtual pointer into the file which is referred to as a
* file <em>position</em>. The position can be manipulated by moving it
* within the file, and the current position can be queried.
- * </p>
* <p>
* FileChannels also have an associated <em>size</em>. The size of the file
* is the number of bytes that it currently contains. The size can be
* manipulated by adding more bytes to the end of the file (which increases the
* size) or truncating the file (which decreases the size). The current size can
* also be queried.
- * </p>
* <p>
* FileChannels have operations beyond the simple read, write, and close. They
* can also:
@@ -65,55 +60,41 @@ import java.nio.channels.spi.AbstractInterruptibleChannel;
* <li>read and write to the file at absolute byte offsets in a fashion that
* does not modify the current position.</li>
* </ul>
- * </p>
* <p>
* FileChannels are thread-safe. Only one operation involving manipulation of
* the file position may be executed at the same time. Subsequent calls to such
* operations will block, and one of those blocked will be freed to continue
* when the first operation has completed. There is no ordered queue or fairness
* applied to the blocked threads.
- * </p>
* <p>
* It is undefined whether operations that do not manipulate the file position
* will also block when there are any other operations in-flight.
- * </p>
* <p>
* The logical view of the underlying file is consistent across all FileChannels
* and I/O streams opened on the same file by the same virtual machine process.
* Therefore, modifications performed via a channel will be visible to the
* stream and vice versa; this includes modifications to the file position,
* content, size, etc.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class FileChannel extends AbstractInterruptibleChannel
implements GatheringByteChannel, ScatteringByteChannel, ByteChannel {
/**
* {@code MapMode} defines file mapping mode constants.
- *
- * @since Android 1.0
*/
public static class MapMode {
/**
* Private mapping mode (equivalent to copy on write).
- *
- * @since Android 1.0
*/
public static final MapMode PRIVATE = new MapMode("PRIVATE"); //$NON-NLS-1$
/**
* Read-only mapping mode.
- *
- * @since Android 1.0
*/
public static final MapMode READ_ONLY = new MapMode("READ_ONLY"); //$NON-NLS-1$
/**
* Read-write mapping mode.
- *
- * @since Android 1.0
*/
public static final MapMode READ_WRITE = new MapMode("READ_WRITE"); //$NON-NLS-1$
@@ -132,8 +113,8 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* Returns a string version of the mapping mode.
*
* @return this map mode as string.
- * @since Android 1.0
*/
+ @Override
public String toString() {
return displayName;
}
@@ -141,8 +122,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
/**
* Protected default constructor.
- *
- * @since Android 1.0
*/
protected FileChannel() {
super();
@@ -157,12 +136,10 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* local storage device. If the file is not hosted locally, for example on a
* networked file system, then applications cannot be certain that the
* modifications have been committed.
- * </p>
* <p>
* There are no assurances given that changes made to the file using methods
* defined elsewhere will be committed. For example, changes made via a
* mapped byte buffer may not be committed.
- * </p>
* <p>
* The <code>metadata</code> parameter indicates whether the update should
* include the file's metadata such as last modification time, last access
@@ -177,7 +154,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if this channel is already closed.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract void force(boolean metadata) throws IOException;
@@ -187,7 +163,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* This is a convenience method for acquiring a maximum length lock on a
* file. It is equivalent to:
* {@code fileChannel.lock(0L, Long.MAX_VALUE, false);}
- *
+ *
* @return the lock object representing the locked file area.
* @throws ClosedChannelException
* the file channel is closed.
@@ -206,7 +182,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws IOException
* if another I/O error occurs while obtaining the requested
* lock.
- * @since Android 1.0
*/
public final FileLock lock() throws IOException {
return lock(0L, Long.MAX_VALUE, false);
@@ -217,41 +192,34 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* This is the blocking version of lock acquisition, see also the
* <code>tryLock()</code> methods.
- * </p>
* <p>
* Attempts to acquire an overlapping lock region will fail. The attempt
* will fail if the overlapping lock has already been obtained, or if
* another thread is currently waiting to acquire the overlapping lock.
- * </p>
* <p>
* If the request is not for an overlapping lock, the thread calling this
* method will block until the lock is obtained (likely by no contention or
* another process releasing a lock), or until this thread is interrupted or
* the channel is closed.
- * </p>
* <p>
* If the lock is obtained successfully then the {@link FileLock} object
* returned represents the lock for subsequent operations on the locked
* region.
- * </p>
* <p>
* If the thread is interrupted while waiting for the lock, the thread is
* set to the interrupted state and throws a
* {@link FileLockInterruptionException}. If this channel is closed while
* the thread is waiting to obtain the lock then the thread throws a
* {@link AsynchronousCloseException}.
- * </p>
* <p>
* There is no requirement for the position and size to be within the
* current start and length of the file.
- * </p>
* <p>
* Some platforms do not support shared locks, and if a request is made for
* a shared lock on such a platform, this method will attempt to acquire an
* exclusive lock instead. It is undefined whether the lock obtained is
* advisory or mandatory.
- * </p>
- *
+ *
* @param position
* the starting position for the locked region.
* @param size
@@ -280,7 +248,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* the desired file lock.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract FileLock lock(long position, long size, boolean shared)
throws IOException;
@@ -291,8 +258,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* channel do not affect the other storage place.
* <p>
* Note: mapping a file into memory is usually expensive.
- * </p>
- *
+ *
* @param mode
* one of the three mapping modes.
* @param position
@@ -312,7 +278,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* bigger than max integer.
* @throws IOException
* if any I/O error occurs.
- * @since Android 1.0
*/
public abstract MappedByteBuffer map(FileChannel.MapMode mode,
long position, long size) throws IOException;
@@ -326,7 +291,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if this channel is closed.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract long position() throws IOException;
@@ -349,7 +313,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if this channel is closed.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract FileChannel position(long offset) throws IOException;
@@ -359,16 +322,13 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* The maximum number of bytes that will be read is the remaining number of
* bytes in the buffer when the method is invoked. The bytes will be copied
* into the buffer starting at the buffer's current position.
- * </p>
* <p>
* The call may block if other threads are also attempting to read from this
* channel.
- * </p>
* <p>
* Upon completion, the buffer's position is set to the end of the bytes
* that have been read. The buffer's limit is not changed.
- * </p>
- *
+ *
* @param buffer
* the byte buffer to receive the bytes.
* @return the number of bytes actually read.
@@ -384,7 +344,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws NonReadableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public abstract int read(ByteBuffer buffer) throws IOException;
@@ -395,15 +354,12 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* The bytes are read starting at the given file position (up to the
* remaining number of bytes in the buffer). The number of bytes actually
* read is returned.
- * </p>
* <p>
* If {@code position} is beyond the current end of file, then no bytes are
* read.
- * </p>
* <p>
* Note that the file position is unmodified by this method.
- * </p>
- *
+ *
* @param buffer
* the buffer to receive the bytes.
* @param position
@@ -425,7 +381,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws NonReadableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public abstract int read(ByteBuffer buffer, long position)
throws IOException;
@@ -439,12 +394,10 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* If a read operation is in progress, subsequent threads will block until
* the read is completed and will then contend for the ability to read.
- * </p>
* <p>
* Calling this method is equivalent to calling
* {@code read(buffers, 0, buffers.length);}
- * </p>
- *
+ *
* @param buffers
* the array of byte buffers into which the bytes will be copied.
* @return the number of bytes actually read.
@@ -461,24 +414,21 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws NonReadableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public final long read(ByteBuffer[] buffers) throws IOException {
return read(buffers, 0, buffers.length);
}
/**
- * Reads bytes from this file channel and stores them in a subset of the
- * specified array of buffers. The subset is defined by {@code start} and
- * {@code number}, indicating the first buffer and the number of buffers to
- * use. This method attempts to read as many bytes as can be stored in the
- * buffer subset from this channel and returns the number of bytes actually
- * read. It also increases the file position by the number of bytes read.
+ * Reads bytes from this file channel into a subset of the given buffers.
+ * This method attempts to read all {@code remaining()} bytes from {@code
+ * length} byte buffers, in order, starting at {@code targets[offset]}. It
+ * increases the file position by the number of bytes actually read. The
+ * number of bytes actually read is returned.
* <p>
* If a read operation is in progress, subsequent threads will block until
* the read is completed and will then contend for the ability to read.
- * </p>
- *
+ *
* @param buffers
* the array of byte buffers into which the bytes will be copied.
* @param start
@@ -503,7 +453,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws NonReadableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public abstract long read(ByteBuffer[] buffers, int start, int number)
throws IOException;
@@ -516,7 +465,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if this channel is closed.
* @throws IOException
* if an I/O error occurs while getting the size of the file.
- * @since Android 1.0
*/
public abstract long size() throws IOException;
@@ -530,8 +478,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* buffer.
* <p>
* Note that this channel's position is not modified.
- * </p>
- *
+ *
* @param src
* the source channel to read bytes from.
* @param position
@@ -554,7 +501,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if the thread is interrupted during this operation.
* @throws IOException
* if any I/O error occurs.
- * @since Android 1.0
*/
public abstract long transferFrom(ReadableByteChannel src, long position,
long count) throws IOException;
@@ -569,8 +515,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* buffer.
* <p>
* Note that this channel's position is not modified.
- * </p>
- *
+ *
* @param position
* the non-negative position to begin.
* @param count
@@ -593,7 +538,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if the thread is interrupted during this operation.
* @throws IOException
* if any I/O error occurs.
- * @since Android 1.0
*/
public abstract long transferTo(long position, long count,
WritableByteChannel target) throws IOException;
@@ -605,8 +549,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* If the file position is currently greater than the given size, then it is
* set to the new size.
- * </p>
- *
+ *
* @param size
* the maximum size of the underlying file.
* @throws IllegalArgumentException
@@ -618,7 +561,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* @throws IOException
* if another I/O error occurs.
* @return this channel.
- * @since Android 1.0
*/
public abstract FileChannel truncate(long size) throws IOException;
@@ -628,12 +570,10 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* This is a convenience method for attempting to acquire a maximum length
* lock on the file. It is equivalent to:
* {@code fileChannel.tryLock(0L, Long.MAX_VALUE, false);}
- * </p>
* <p>
* The method returns {@code null} if the acquisition would result in an
* overlapped lock with another OS process.
- * </p>
- *
+ *
* @return the file lock object, or {@code null} if the lock would overlap
* with an existing exclusive lock in another OS process.
* @throws ClosedChannelException
@@ -644,7 +584,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* with this request.
* @throws IOException
* if any I/O error occurs.
- * @since Android 1.0
*/
public final FileLock tryLock() throws IOException {
return tryLock(0L, Long.MAX_VALUE, false);
@@ -659,8 +598,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* outside of the file's size. The size of the lock is fixed. If the file
* grows outside of the lock that region of the file won't be locked by this
* lock.
- * </p>
- *
+ *
* @param position
* the starting position.
* @param size
@@ -679,7 +617,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* with this request.
* @throws IOException
* if any I/O error occurs.
- * @since Android 1.0
*/
public abstract FileLock tryLock(long position, long size, boolean shared)
throws IOException;
@@ -703,11 +640,11 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if another thread closes the channel during the write.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while this
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws IOException
* if another I/O error occurs, details are in the message.
- * @since Android 1.0
+ * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
*/
public abstract int write(ByteBuffer src) throws IOException;
@@ -718,16 +655,13 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* The bytes are written starting at the given file position (up to the
* remaining number of bytes in the buffer). The number of bytes actually
* written is returned.
- * </p>
* <p>
* If the position is beyond the current end of file, then the file is first
* extended up to the given position by the required number of unspecified
* byte values.
- * </p>
* <p>
* Note that the file position is not modified by this method.
- * </p>
- *
+ *
* @param buffer
* the buffer containing the bytes to be written.
* @param position
@@ -748,7 +682,6 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* thread is set and the channel is closed.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract int write(ByteBuffer buffer, long position)
throws IOException;
@@ -763,8 +696,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* <p>
* Calling this method is equivalent to calling
* {@code write(buffers, 0, buffers.length);}
- * </p>
- *
+ *
* @param buffers
* the buffers containing bytes to write.
* @return the number of bytes actually written.
@@ -773,7 +705,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while this
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if this channel is closed.
@@ -781,21 +713,20 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if another I/O error occurs; details are in the message.
* @throws NonWritableChannelException
* if this channel was not opened for writing.
- * @since Android 1.0
*/
public final long write(ByteBuffer[] buffers) throws IOException {
return write(buffers, 0, buffers.length);
}
/**
- * Writes bytes from a subset of the specified array of buffers into this
- * file channel. The subset is defined by {@code offset} and {@code length},
- * indicating the first buffer and the number of buffers to use.
+ * Attempts to write a subset of the given bytes from the buffers to this
+ * file channel. This method attempts to write all {@code remaining()}
+ * bytes from {@code length} byte buffers, in order, starting at {@code
+ * sources[offset]}. The number of bytes actually written is returned.
* <p>
* If a write operation is in progress, subsequent threads will block until
* the write is completed and then contend for the ability to write.
- * </p>
- *
+ *
* @param buffers
* the array of byte buffers that is the source for bytes written
* to this channel.
@@ -810,7 +741,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while this
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if this channel is closed.
@@ -822,9 +753,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
* if another I/O error occurs; details are in the message.
* @throws NonWritableChannelException
* if this channel was not opened for writing.
- * @since Android 1.0
*/
public abstract long write(ByteBuffer[] buffers, int offset, int length)
throws IOException;
-
}
diff --git a/nio/src/main/java/java/nio/channels/FileLock.java b/nio/src/main/java/java/nio/channels/FileLock.java
index e9aae1f..1bc71a8 100644
--- a/nio/src/main/java/java/nio/channels/FileLock.java
+++ b/nio/src/main/java/java/nio/channels/FileLock.java
@@ -30,7 +30,6 @@ import java.io.IOException;
* simultaneously hold a shared lock overlapping the exclusive lock. An
* application can determine whether a {@code FileLock} is shared or exclusive
* via the {@code isShared()} method.
- * </p>
* <p>
* Locks held by a particular process cannot overlap one another. Applications
* can determine whether a proposed lock will overlap by using the {@code
@@ -38,19 +37,16 @@ import java.io.IOException;
* locks held in this process. Locks are shared amongst all threads in the
* acquiring process, and are therefore unsuitable for intra-process
* synchronization.
- * </p>
* <p>
* Once a lock is acquired, it is immutable in all its state except {@code
* isValid()}. The lock will initially be valid, but may be rendered invalid by
* explicit removal of the lock, using {@code release()}, or implicitly by
* closing the channel or exiting the process (terminating the virtual machine).
- * </p>
* <h3>Platform dependencies</h3>
* <p>
* Locks are intended to be true platform operating system file locks, and
* therefore locks held by the virtual machine process will be visible to other
* operating system processes.
- * </p>
* <p>
* The characteristics of the underlying operating system locks will show
* through in the Java implementation. For example, some platforms' locks are
@@ -61,7 +57,6 @@ import java.io.IOException;
* processes to not play well. To be on the safe side, it is best to assume that
* the platform is adopting advisory locks and always acquire shared locks when
* reading a region of a file.
- * </p>
* <p>
* On some platforms, the presence of a lock will prevent the file from being
* memory-mapped. On some platforms, closing a channel on a given file handle
@@ -69,13 +64,9 @@ import java.io.IOException;
* channels open on the same file; their locks will also be released. The safe
* option here is to ensure that you only acquire locks on a single channel for
* a particular file and that becomes the synchronization point.
- * </p>
* <p>
* Further care should be exercised when locking files maintained on network
* file systems, since they often have further limitations.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class FileLock {
@@ -104,7 +95,6 @@ public abstract class FileLock {
* @param shared
* the lock's sharing mode of lock; {@code true} is shared,
* {@code false} is exclusive.
- * @since Android 1.0
*/
protected FileLock(FileChannel channel, long position, long size,
boolean shared) {
@@ -122,7 +112,6 @@ public abstract class FileLock {
* Returns the lock's {@link FileChannel}.
*
* @return the channel.
- * @since Android 1.0
*/
public final FileChannel channel() {
return channel;
@@ -132,7 +121,6 @@ public abstract class FileLock {
* Returns the lock's starting position in the file.
*
* @return the lock position.
- * @since Android 1.0
*/
public final long position() {
return position;
@@ -142,7 +130,6 @@ public abstract class FileLock {
* Returns the length of the file lock in bytes.
*
* @return the size of the file lock in bytes.
- * @since Android 1.0
*/
public final long size() {
return size;
@@ -154,7 +141,6 @@ public abstract class FileLock {
*
* @return {@code true} if the lock is a shared lock, {@code false} if it is
* exclusive.
- * @since Android 1.0
*/
public final boolean isShared() {
return shared;
@@ -169,7 +155,6 @@ public abstract class FileLock {
* @param length
* the length of the comparative lock.
* @return {@code true} if there is an overlap, {@code false} otherwise.
- * @since Android 1.0
*/
public final boolean overlaps(long start, long length) {
final long end = position + size - 1;
@@ -186,7 +171,6 @@ public abstract class FileLock {
* explicitly released.
*
* @return {@code true} if the lock is valid, {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isValid();
@@ -199,7 +183,6 @@ public abstract class FileLock {
* the lock is made.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
*/
public abstract void release() throws IOException;
@@ -208,17 +191,18 @@ public abstract class FileLock {
* to an end user.
*
* @return the display string.
- * @since Android 1.0
*/
+ @Override
+ @SuppressWarnings("nls")
public final String toString() {
- StringBuffer buffer = new StringBuffer(64); // Guess length of string
- buffer.append("FileLock: [position="); //$NON-NLS-1$
+ StringBuilder buffer = new StringBuilder(64); // Guess length of string
+ buffer.append("FileLock: [position=");
buffer.append(position);
- buffer.append(", size="); //$NON-NLS-1$
+ buffer.append(", size=");
buffer.append(size);
- buffer.append(", shared="); //$NON-NLS-1$
+ buffer.append(", shared=");
buffer.append(Boolean.toString(shared));
- buffer.append("]"); //$NON-NLS-1$
+ buffer.append("]");
return buffer.toString();
}
}
diff --git a/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java b/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
index 0920f52..71cc0c6 100644
--- a/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
+++ b/nio/src/main/java/java/nio/channels/FileLockInterruptionException.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
/**
@@ -24,9 +23,6 @@ import java.io.IOException;
* interrupted while waiting to acquire a file lock.
* <p>
* Note that the thread will also be in the 'interrupted' state.
- * </p>
- *
- * @since Android 1.0
*/
public class FileLockInterruptionException extends IOException {
@@ -34,8 +30,6 @@ public class FileLockInterruptionException extends IOException {
/**
* Constructs a {@code FileLockInterruptionException}.
- *
- * @since Android 1.0
*/
public FileLockInterruptionException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/GatheringByteChannel.java b/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
index e8a6c73..8e52075 100644
--- a/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/GatheringByteChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -24,8 +23,6 @@ import java.nio.ByteBuffer;
* The interface for channels that can write a set of buffers in a single
* operation. The corresponding interface for read operations is
* {@link ScatteringByteChannel}.
- *
- * @since Android 1.0
*/
public interface GatheringByteChannel extends WritableByteChannel {
@@ -33,8 +30,7 @@ public interface GatheringByteChannel extends WritableByteChannel {
* Writes bytes from all the given buffers to a channel.
* <p>
* This method is equivalent to: {@code write(buffers, 0, buffers.length);}
- * </p>
- *
+ *
* @param buffers
* the buffers containing bytes to be written.
* @return the number of bytes actually written.
@@ -43,7 +39,7 @@ public interface GatheringByteChannel extends WritableByteChannel {
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while the
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
@@ -56,19 +52,17 @@ public interface GatheringByteChannel extends WritableByteChannel {
* @throws NonWritableChannelException
* if the channel has not been opened in a mode that permits
* writing.
- * @since Android 1.0
*/
public long write(ByteBuffer[] buffers) throws IOException;
/**
- * Writes bytes from a subset of the specified array of buffers to a
- * channel. The subset is defined by {@code offset} and {@code length},
- * indicating the first buffer and the number of buffers to use.
+ * Attempts to write all <code>remaining()</code> bytes from {@code length}
+ * byte buffers, in order, starting at {@code buffers[offset]}. The number
+ * of bytes actually written is returned.
* <p>
* If a write operation is in progress, subsequent threads will block until
* the write is completed and then contend for the ability to write.
- * </p>
- *
+ *
* @param buffers
* the array of byte buffers that is the source for bytes written
* to the channel.
@@ -83,7 +77,7 @@ public interface GatheringByteChannel extends WritableByteChannel {
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while the
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
@@ -95,7 +89,6 @@ public interface GatheringByteChannel extends WritableByteChannel {
* if another I/O error occurs; details are in the message.
* @throws NonWritableChannelException
* if the channel was not opened for writing.
- * @since Android 1.0
*/
public long write(ByteBuffer[] buffers, int offset, int length)
throws IOException;
diff --git a/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java b/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
index 3efd94a..5495321 100644
--- a/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
+++ b/nio/src/main/java/java/nio/channels/IllegalBlockingModeException.java
@@ -16,13 +16,10 @@
package java.nio.channels;
-
/**
* An {@code IllegalBlockingModeException} is thrown when an operation that
* requires a specific blocking mode is invoked on a channel that is in a
* different blocking mode.
- *
- * @since Android 1.0
*/
public class IllegalBlockingModeException extends IllegalStateException {
@@ -30,8 +27,6 @@ public class IllegalBlockingModeException extends IllegalStateException {
/**
* Constructs a {@code IllegalBlockingModeException}.
- *
- * @since Android 1.0
*/
public IllegalBlockingModeException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/IllegalSelectorException.java b/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
index 0cffd22..a40e2cb 100644
--- a/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
+++ b/nio/src/main/java/java/nio/channels/IllegalSelectorException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code IllegalSelectorException} is thrown when a call is made to register
* a channel on a selector that has been created by a different provider.
- *
- * @since Android 1.0
*/
public class IllegalSelectorException extends IllegalArgumentException {
@@ -29,11 +26,8 @@ public class IllegalSelectorException extends IllegalArgumentException {
/**
* Constructs a {@code IllegalSelectorException}.
- *
- * @since Android 1.0
*/
public IllegalSelectorException() {
super();
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/InterruptibleChannel.java b/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
index 0375618..b871c41 100644
--- a/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
+++ b/nio/src/main/java/java/nio/channels/InterruptibleChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
/**
@@ -27,7 +26,6 @@ import java.io.IOException;
* an I/O operation (the I/O thread) can be released by another thread calling
* the channel's {@link #close()} method. The I/O thread will throw an
* {@link AsynchronousCloseException} and the channel will be closed.
- * </p>
* <p>
* A channel that is interruptible permits a thread blocked on an I/O operation
* (the I/O thread) to be interrupted by another thread (by invoking
@@ -36,8 +34,6 @@ import java.io.IOException;
* its interrupted status set and the channel will be closed. If the I/O thread
* attempts to make an I/O call with the interrupt status set the call will
* immediately fail with a {@link ClosedByInterruptException}.
- *
- * @since Android 1.0
*/
public interface InterruptibleChannel extends Channel {
@@ -47,12 +43,9 @@ public interface InterruptibleChannel extends Channel {
* Any threads that are blocked on I/O operations on this channel will be
* interrupted with an {@link AsynchronousCloseException}. Otherwise, this
* method behaves the same as defined in the {@code Channel} interface.
- * </p>
*
* @throws IOException
* if an I/O error occurs while closing the channel.
- * @since Android 1.0
*/
public void close() throws IOException;
-
}
diff --git a/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java b/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
index 3434b87..34b3e5a 100644
--- a/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
+++ b/nio/src/main/java/java/nio/channels/NoConnectionPendingException.java
@@ -16,15 +16,12 @@
package java.nio.channels;
-
/**
* A {@code NoConnectionPendingException} is thrown if {@code SocketChannel}'s
* {@link SocketChannel#finishConnect() finishConnect} method is called before
- * the {@code SocketChannel}'s
- * {@link SocketChannel#connect(SocketAddress) connect} method completed without
- * error.
- *
- * @since Android 1.0
+ * the {@code SocketChannel}'s {@link
+ * SocketChannel#connect(java.net.SocketAddress)} connect} method completed
+ * without error.
*/
public class NoConnectionPendingException extends IllegalStateException {
@@ -32,8 +29,6 @@ public class NoConnectionPendingException extends IllegalStateException {
/**
* Constructs a {@code NoConnectionPendingException}.
- *
- * @since Android 1.0
*/
public NoConnectionPendingException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NonReadableChannelException.java b/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
index c436682..51e3cd3 100644
--- a/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
+++ b/nio/src/main/java/java/nio/channels/NonReadableChannelException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* A {@code NonReadableChannelException} is thrown when attempting to read from
* a channel that is not open for reading.
- *
- * @since Android 1.0
*/
public class NonReadableChannelException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class NonReadableChannelException extends IllegalStateException {
/**
* Constructs a {@code NonReadableChannelException}.
- *
- * @since Android 1.0
*/
public NonReadableChannelException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NonWritableChannelException.java b/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
index 81549cb..acc6305 100644
--- a/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
+++ b/nio/src/main/java/java/nio/channels/NonWritableChannelException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* A {@code NonWritableChannelException} is thrown when attempting to write to a
* channel that is not open for writing.
- *
- * @since Android 1.0
*/
public class NonWritableChannelException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class NonWritableChannelException extends IllegalStateException {
/**
* Constructs a {@code NonWritableChannelException}.
- *
- * @since Android 1.0
*/
public NonWritableChannelException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NotYetBoundException.java b/nio/src/main/java/java/nio/channels/NotYetBoundException.java
index 2210903..d2ffc55 100644
--- a/nio/src/main/java/java/nio/channels/NotYetBoundException.java
+++ b/nio/src/main/java/java/nio/channels/NotYetBoundException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* A {@code NotYetBoundException} is thrown if the server socket channel is not
* bound before an I/O operation is made.
- *
- * @since Android 1.0
*/
public class NotYetBoundException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class NotYetBoundException extends IllegalStateException {
/**
* Constructs a {@code NotYetBoundException}.
- *
- * @since Android 1.0
*/
public NotYetBoundException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/NotYetConnectedException.java b/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
index 393c77f..da3523a 100644
--- a/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
+++ b/nio/src/main/java/java/nio/channels/NotYetConnectedException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* A {@code NotYetConnectedException} is thrown if the socket channel is not
* connected before an I/O operation is invoked.
- *
- * @since Android 1.0
*/
public class NotYetConnectedException extends IllegalStateException {
@@ -29,11 +26,8 @@ public class NotYetConnectedException extends IllegalStateException {
/**
* Constructs a {@code NotYetConnectedException}.
- *
- * @since Android 1.0
*/
public NotYetConnectedException() {
super();
}
-
}
diff --git a/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java b/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
index 6a00a6b..98fab94 100644
--- a/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
+++ b/nio/src/main/java/java/nio/channels/OverlappingFileLockException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code OverlappingFileLockException} is thrown when attempting to acquire
* a lock that overlaps an existing or pending lock held by this process.
- *
- * @since Android 1.0
*/
public class OverlappingFileLockException extends IllegalStateException {
@@ -29,8 +26,6 @@ public class OverlappingFileLockException extends IllegalStateException {
/**
* Constructs a {@code OverlappingFileLockException}.
- *
- * @since Android 1.0
*/
public OverlappingFileLockException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/Pipe.java b/nio/src/main/java/java/nio/channels/Pipe.java
index e28812c..956e69b 100644
--- a/nio/src/main/java/java/nio/channels/Pipe.java
+++ b/nio/src/main/java/java/nio/channels/Pipe.java
@@ -25,13 +25,11 @@ import java.nio.channels.spi.SelectorProvider;
* is the readable source channel. When bytes are written into the writable
* channel they can be read from the readable channel. The order of these bytes
* remains unchanged.
- * @since Android 1.0
*/
public abstract class Pipe {
/**
* Writable sink channel used to write to a pipe.
- * @since Android 1.0
*/
public static abstract class SinkChannel extends AbstractSelectableChannel
implements WritableByteChannel, GatheringByteChannel {
@@ -41,7 +39,6 @@ public abstract class Pipe {
*
* @param provider
* the provider of the channel.
- * @since Android 1.0
*/
protected SinkChannel(SelectorProvider provider) {
super(provider);
@@ -51,8 +48,8 @@ public abstract class Pipe {
* Indicates that this channel only supports writing.
*
* @return a static value of OP_WRITE.
- * @since Android 1.0
*/
+ @Override
public final int validOps() {
return SelectionKey.OP_WRITE;
}
@@ -60,7 +57,6 @@ public abstract class Pipe {
/**
* Readable source channel used to read from a pipe.
- * @since Android 1.0
*/
public static abstract class SourceChannel extends
AbstractSelectableChannel implements ReadableByteChannel,
@@ -71,7 +67,6 @@ public abstract class Pipe {
*
* @param provider
* the provider of the channel.
- * @since Android 1.0
*/
protected SourceChannel(SelectorProvider provider) {
super(provider);
@@ -81,8 +76,8 @@ public abstract class Pipe {
* Indicates that this channel only supports reading.
*
* @return a static value of OP_READ.
- * @since Android 1.0
*/
+ @Override
public final int validOps() {
return SelectionKey.OP_READ;
}
@@ -96,7 +91,6 @@ public abstract class Pipe {
*
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public static Pipe open() throws IOException {
return SelectorProvider.provider().openPipe();
@@ -104,8 +98,6 @@ public abstract class Pipe {
/**
* The protected default constructor.
- *
- * @since Android 1.0
*/
protected Pipe() {
super();
@@ -115,7 +107,6 @@ public abstract class Pipe {
* Returns the sink channel of the pipe.
*
* @return a writable sink channel of the pipe.
- * @since Android 1.0
*/
public abstract SinkChannel sink();
@@ -123,7 +114,6 @@ public abstract class Pipe {
* Returns the source channel of the pipe.
*
* @return a readable source channel of the pipe.
- * @since Android 1.0
*/
public abstract SourceChannel source();
diff --git a/nio/src/main/java/java/nio/channels/ReadableByteChannel.java b/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
index 9be1a72..649b64c 100644
--- a/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ReadableByteChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -28,9 +27,6 @@ import java.nio.ByteBuffer;
* if a read is already in progress on the channel then subsequent reads will
* block until the first read completes. It is undefined whether non-read
* operations will block.
- * </p>
- *
- * @since Android 1.0
*/
public interface ReadableByteChannel extends Channel {
@@ -42,17 +38,14 @@ public interface ReadableByteChannel extends Channel {
* buffer when the method is invoked. The bytes will be read into the buffer
* starting at the buffer's current
* {@link java.nio.Buffer#position() position}.
- * </p>
* <p>
* The call may block if other threads are also attempting to read from the
* same channel.
- * </p>
* <p>
* Upon completion, the buffer's {@code position} is updated to the end of
* the bytes that were read. The buffer's
* {@link java.nio.Buffer#limit() limit} is not changed.
- * </p>
- *
+ *
* @param buffer
* the byte buffer to receive the bytes.
* @return the number of bytes actually read.
@@ -60,7 +53,7 @@ public interface ReadableByteChannel extends Channel {
* if another thread closes the channel during the read.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while the
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
@@ -68,7 +61,6 @@ public interface ReadableByteChannel extends Channel {
* another I/O error occurs, details are in the message.
* @throws NonReadableChannelException
* if the channel was not opened for reading.
- * @since Android 1.0
*/
public int read(ByteBuffer buffer) throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java b/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
index 2e654db..d25f69c 100644
--- a/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/ScatteringByteChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -24,8 +23,6 @@ import java.nio.ByteBuffer;
* The interface for channels that can read data into a set of buffers in a
* single operation. The corresponding interface for writes is
* {@link GatheringByteChannel}.
- *
- * @since Android 1.0
*/
public interface ScatteringByteChannel extends ReadableByteChannel {
@@ -33,8 +30,7 @@ public interface ScatteringByteChannel extends ReadableByteChannel {
* Reads bytes from this channel into the specified array of buffers.
* <p>
* This method is equivalent to {@code read(buffers, 0, buffers.length);}
- * </p>
- *
+ *
* @param buffers
* the array of byte buffers to store the bytes being read.
* @return the number of bytes actually read.
@@ -43,7 +39,7 @@ public interface ScatteringByteChannel extends ReadableByteChannel {
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while the
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
@@ -52,21 +48,16 @@ public interface ScatteringByteChannel extends ReadableByteChannel {
* @throws NonWritableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public long read(ByteBuffer[] buffers) throws IOException;
/**
- * Reads bytes from this channel and stores them in a subset of the
- * specified array of buffers. The subset is defined by {@code offset} and
- * {@code length}, indicating the first buffer and the number of buffers to
- * use. This method attempts to read as many bytes as can be stored in the
- * buffer subset from the channel and returns the number of bytes actually
- * read.
+ * Attempts to read all {@code remaining()} bytes from {@code length} byte
+ * buffers, in order, starting at {@code buffers[offset]}. The number of
+ * bytes actually read is returned.
* <p>
* If a read operation is in progress, subsequent threads will block until
* the read is completed and will then contend for the ability to read.
- * </p>
*
* @param buffers
* the array of byte buffers into which the bytes will be copied.
@@ -80,7 +71,7 @@ public interface ScatteringByteChannel extends ReadableByteChannel {
* operation.
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while the
- * operation is in progress. The interrupt state of the calling
+ * operation is in progress. The interrupt state of the calling
* thread is set and the channel is closed.
* @throws ClosedChannelException
* if the channel is closed.
@@ -93,9 +84,7 @@ public interface ScatteringByteChannel extends ReadableByteChannel {
* @throws NonWritableChannelException
* if the channel has not been opened in a mode that permits
* reading.
- * @since Android 1.0
*/
public long read(ByteBuffer[] buffers, int offset, int length)
throws IOException;
-
}
diff --git a/nio/src/main/java/java/nio/channels/SelectableChannel.java b/nio/src/main/java/java/nio/channels/SelectableChannel.java
index ded66e6..6ac9a51 100644
--- a/nio/src/main/java/java/nio/channels/SelectableChannel.java
+++ b/nio/src/main/java/java/nio/channels/SelectableChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.channels.spi.AbstractInterruptibleChannel;
import java.nio.channels.spi.SelectorProvider;
@@ -31,16 +30,12 @@ import java.nio.channels.spi.SelectorProvider;
* <p>
* A channel may be registered with several selectors at the same time but only
* once for any given selector.
- * </p>
- * @since Android 1.0
*/
public abstract class SelectableChannel extends AbstractInterruptibleChannel
implements Channel {
/**
* Constructs a new {@code SelectableChannel}.
- *
- * @since Android 1.0
*/
protected SelectableChannel() {
super();
@@ -51,7 +46,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* and {@code register} methods.
*
* @return the blocking object as lock.
- * @since Android 1.0
*/
public abstract Object blockingLock();
@@ -74,7 +68,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* registered with at least one selector.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract SelectableChannel configureBlocking(boolean block)
throws IOException;
@@ -84,7 +77,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
*
* @return {@code true} if this channel is blocking, undefined if this
* channel is closed.
- * @since Android 1.0
*/
public abstract boolean isBlocking();
@@ -93,7 +85,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
*
* @return {@code true} if this channel is registered, {@code false}
* otherwise.
- * @since Android 1.0
*/
public abstract boolean isRegistered();
@@ -104,7 +95,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* the selector with which this channel has been registered.
* @return the selection key for the channel or {@code null} if this channel
* has not been registered with {@code sel}.
- * @since Android 1.0
*/
public abstract SelectionKey keyFor(Selector sel);
@@ -112,7 +102,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* Gets the provider of this channel.
*
* @return the provider of this channel.
- * @since Android 1.0
*/
public abstract SelectorProvider provider();
@@ -129,12 +118,10 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* blocked until the other call finishes. After that, it will synchronize on
* the key set of the selector and thus may again block if other threads
* also hold locks on the key set of the same selector.
- * </p>
* <p>
* Calling this method is equivalent to calling
* {@code register(selector, operations, null)}.
- * </p>
- *
+ *
* @param selector
* the selector with which to register this channel.
* @param operations
@@ -151,7 +138,6 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* if this channel is registered but its key has been canceled.
* @throws IllegalArgumentException
* if the operation given is not supported by this channel.
- * @since Android 1.0
*/
public final SelectionKey register(Selector selector, int operations)
throws ClosedChannelException {
@@ -171,8 +157,7 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* blocked until the other call finishes. After that, it will synchronize on
* the key set of the selector and thus may again block if other threads
* also hold locks on the key set of the same selector.
- * </p>
- *
+ *
* @param sel
* the selector with which to register this channel.
* @param ops
@@ -191,18 +176,15 @@ public abstract class SelectableChannel extends AbstractInterruptibleChannel
* selector.
* @throws CancelledKeyException
* if this channel is registered but its key has been canceled.
- * @since Android 1.0
*/
public abstract SelectionKey register(Selector sel, int ops, Object att)
throws ClosedChannelException;
/**
* Gets the set of valid {@link SelectionKey operations} of this channel.
- * Instances of a concrete channel class always return the same value.
- *
+ * Instances of a concrete channel class always return the same value.
+ *
* @return the set of operations that this channel supports.
- * @since Android 1.0
*/
public abstract int validOps();
-
}
diff --git a/nio/src/main/java/java/nio/channels/SelectionKey.java b/nio/src/main/java/java/nio/channels/SelectionKey.java
index b3773fa..d00627e 100644
--- a/nio/src/main/java/java/nio/channels/SelectionKey.java
+++ b/nio/src/main/java/java/nio/channels/SelectionKey.java
@@ -32,36 +32,26 @@ import java.nio.channels.Selector;
* <h4>Ready set</h4>
* The ready set is an operation set that shows the operations that a
* {@code channel} is ready to execute.
- *
- * @since Android 1.0
*/
public abstract class SelectionKey {
/**
* Interest set mask bit for socket-accept operations.
- *
- * @since Android 1.0
*/
public static final int OP_ACCEPT = 16;
/**
* Interest set mask bit for socket-connect operations.
- *
- * @since Android 1.0
*/
public static final int OP_CONNECT = 8;
/**
* Interesting operation mask bit for read operations.
- *
- * @since Android 1.0
*/
public static final int OP_READ = 1;
/**
* Interest set mask bit for write operations.
- *
- * @since Android 1.0
*/
public static final int OP_WRITE = 4;
@@ -69,8 +59,6 @@ public abstract class SelectionKey {
/**
* Constructs a new {@code SelectionKey}.
- *
- * @since Android 1.0
*/
protected SelectionKey() {
super();
@@ -85,7 +73,6 @@ public abstract class SelectionKey {
* attachment.
* @return the last attached object or {@code null} if no object has been
* attached.
- * @since Android 1.0
*/
public final Object attach(Object anObject) {
Object oldAttachment = attachment;
@@ -98,7 +85,6 @@ public abstract class SelectionKey {
*
* @return the attached object or {@code null} if no object has been
* attached.
- * @since Android 1.0
*/
public final Object attachment() {
return attachment;
@@ -109,7 +95,6 @@ public abstract class SelectionKey {
* <p>
* A key that has been canceled is no longer valid. Calling this method on
* an already canceled key does nothing.
- * </p>
* <p>
* Calling this method is safe at any time. The call might block until
* another ongoing call to a method of this selector has finished. The
@@ -117,9 +102,6 @@ public abstract class SelectionKey {
* this call finishes, the key will have been added to the selectors
* canceled-keys set and will not be included in any future selects of this
* selector.
- * </p>
- *
- * @since Android 1.0
*/
public abstract void cancel();
@@ -127,7 +109,6 @@ public abstract class SelectionKey {
* Gets the channel of this key.
*
* @return the channel of this key.
- * @since Android 1.0
*/
public abstract SelectableChannel channel();
@@ -138,7 +119,6 @@ public abstract class SelectionKey {
* @return the interest set of this key.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public abstract int interestOps();
@@ -154,7 +134,6 @@ public abstract class SelectionKey {
* key's channel.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public abstract SelectionKey interestOps(int operations);
@@ -167,7 +146,6 @@ public abstract class SelectionKey {
* and is ready to accept new connections, {@code false} otherwise.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public final boolean isAcceptable() {
return (readyOps() & OP_ACCEPT) == OP_ACCEPT;
@@ -182,8 +160,7 @@ public abstract class SelectionKey {
* operation and is ready to connect, {@code false} otherwise.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
- */
+ */
public final boolean isConnectable() {
return (readyOps() & OP_CONNECT) == OP_CONNECT;
}
@@ -197,7 +174,6 @@ public abstract class SelectionKey {
* and is ready to read, {@code false} otherwise.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public final boolean isReadable() {
return (readyOps() & OP_READ) == OP_READ;
@@ -209,7 +185,6 @@ public abstract class SelectionKey {
*
* @return {@code true} if this key has not been canceled, {@code false}
* otherwise.
- * @since Android 1.0
*/
public abstract boolean isValid();
@@ -222,7 +197,6 @@ public abstract class SelectionKey {
* and is ready to write, {@code false} otherwise.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public final boolean isWritable() {
return (readyOps() & OP_WRITE) == OP_WRITE;
@@ -235,7 +209,6 @@ public abstract class SelectionKey {
* @return the operations for which this key's channel is ready.
* @throws CancelledKeyException
* if the key has already been canceled.
- * @since Android 1.0
*/
public abstract int readyOps();
@@ -243,7 +216,6 @@ public abstract class SelectionKey {
* Gets the selector for which this key's channel is registered.
*
* @return the related selector.
- * @since Android 1.0
*/
public abstract Selector selector();
}
diff --git a/nio/src/main/java/java/nio/channels/Selector.java b/nio/src/main/java/java/nio/channels/Selector.java
index d417f51..8d43f4b 100644
--- a/nio/src/main/java/java/nio/channels/Selector.java
+++ b/nio/src/main/java/java/nio/channels/Selector.java
@@ -32,9 +32,6 @@ import java.util.Set;
* canceled keys. During the select operation, the channels registered with this
* selector are checked to see whether they are ready for operation according to
* their {@link SelectionKey interest set}.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class Selector {
@@ -46,7 +43,6 @@ public abstract class Selector {
* @return a new selector.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public static Selector open() throws IOException {
return SelectorProvider.provider().openSelector();
@@ -54,8 +50,6 @@ public abstract class Selector {
/**
* Constructs a new {@code Selector}.
- *
- * @since Android 1.0
*/
protected Selector() {
super();
@@ -71,11 +65,9 @@ public abstract class Selector {
* Any further attempt of using this selector after this method has been
* called (except calling {@link #close()} or {@link #wakeup()}) results in
* a {@link ClosedSelectorException} being thrown.
- * </p>
- *
+ *
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract void close() throws IOException;
@@ -84,7 +76,6 @@ public abstract class Selector {
*
* @return {@code true} if this selector is not closed, {@code false}
* otherwise.
- * @since Android 1.0
*/
public abstract boolean isOpen();
@@ -93,7 +84,6 @@ public abstract class Selector {
* safe.
*
* @return the set of registered keys.
- * @since Android 1.0
*/
public abstract Set<SelectionKey> keys();
@@ -101,7 +91,6 @@ public abstract class Selector {
* Gets the provider of this selector.
*
* @return the provider of this selector.
- * @since Android 1.0
*/
public abstract SelectorProvider provider();
@@ -116,7 +105,6 @@ public abstract class Selector {
* if an I/O error occurs.
* @throws ClosedSelectorException
* if the selector is closed.
- * @since Android 1.0
*/
public abstract int select() throws IOException;
@@ -137,7 +125,6 @@ public abstract class Selector {
* if the given timeout argument is less than zero.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract int select(long timeout) throws IOException;
@@ -149,7 +136,6 @@ public abstract class Selector {
* @return the selection keys whose channels are ready for operation.
* @throws ClosedSelectorException
* if the selector is closed.
- * @since Android 1.0
*/
public abstract Set<SelectionKey> selectedKeys();
@@ -164,7 +150,6 @@ public abstract class Selector {
* if an I/O error occurrs.
* @throws ClosedSelectorException
* if the selector is closed.
- * @since Android 1.0
*/
public abstract int selectNow() throws IOException;
@@ -176,12 +161,10 @@ public abstract class Selector {
* be undone by a call to {@code selectNow()}; after calling
* {@code selectNow()}, a subsequent call of {@code select} can block
* again.
- * </p>
- *
+ *
* @return this selector.
* @throws ClosedSelectorException
* if the selector is closed.
- * @since Android 1.0
*/
public abstract Selector wakeup();
}
diff --git a/nio/src/main/java/java/nio/channels/ServerSocketChannel.java b/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
index 8ecb183..b0508fa 100644
--- a/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
+++ b/nio/src/main/java/java/nio/channels/ServerSocketChannel.java
@@ -33,9 +33,6 @@ import java.nio.channels.spi.SelectorProvider;
* open()} method. Calling {@code accept} before bound will cause a
* {@link NotYetBoundException}. It can be bound by calling the bind method of a
* related {@code ServerSocket} instance.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class ServerSocketChannel extends AbstractSelectableChannel {
@@ -44,7 +41,6 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
*
* @param selectorProvider
* an instance of SelectorProvider.
- * @since Android 1.0
*/
protected ServerSocketChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
@@ -55,12 +51,10 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
* <p>
* This channel is created by calling {@code openServerSocketChannel} method
* of the default {@code SelectorProvider} instance.
- * </p>
- *
+ *
* @return the new channel which is open but unbound.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public static ServerSocketChannel open() throws IOException {
return SelectorProvider.provider().openServerSocketChannel();
@@ -73,8 +67,8 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
*
* @see java.nio.channels.SelectableChannel#validOps()
* @return the operations supported by this channel.
- * @since Android 1.0
*/
+ @Override
public final int validOps() {
return SelectionKey.OP_ACCEPT;
}
@@ -84,7 +78,6 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
* any public methods that are not declared in {@code ServerSocket}.
*
* @return the server-socket assigned to this channel.
- * @since Android 1.0
*/
public abstract ServerSocket socket();
@@ -95,11 +88,9 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
* connection is available, otherwise it blocks until a new connection is
* available or an I/O error occurs. The socket channel returned by this
* method will always be in blocking mode.
- * </p>
* <p>
* This method just executes the same security checks as the {@code
* accept()} method of the {@link ServerSocket} class.
- * </p>
*
* @return the accepted {@code SocketChannel} instance, or {@code null} if
* the channel is non-blocking and no connection is available.
@@ -119,8 +110,6 @@ public abstract class ServerSocketChannel extends AbstractSelectableChannel {
* @throws SecurityException
* if there is a security manager and it does not permit to
* access the new connection.
- * @since Android 1.0
*/
public abstract SocketChannel accept() throws IOException;
-
}
diff --git a/nio/src/main/java/java/nio/channels/SocketChannel.java b/nio/src/main/java/java/nio/channels/SocketChannel.java
index a709dee..40003ea 100644
--- a/nio/src/main/java/java/nio/channels/SocketChannel.java
+++ b/nio/src/main/java/java/nio/channels/SocketChannel.java
@@ -39,7 +39,6 @@ import org.apache.harmony.luni.platform.Platform;
* connecting. {@code isConnectionPending()} indicates if the connection is
* blocked or not; {@code isConnected()} indicates if the socket is finally
* connected or not.
- * </p>
* <p>
* The input and output sides of a channel can be shut down independently and
* asynchronously without closing the channel. The {@code shutdownInput} method
@@ -51,15 +50,11 @@ import org.apache.harmony.luni.platform.Platform;
* {@link ClosedChannelException}. If the output is shut down and another thread
* is blocked in a write operation, an {@link AsynchronousCloseException} will
* be thrown to the pending thread.
- * </p>
* <p>
* Socket channels are thread-safe, no more than one thread can read or write at
* any given time. The {@code connect(SocketAddress)} and {@code
* finishConnect()} methods are synchronized against each other; when they are
* processing, calls to {@code read} and {@code write} will block.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class SocketChannel extends AbstractSelectableChannel implements
ByteChannel, ScatteringByteChannel, GatheringByteChannel {
@@ -67,13 +62,12 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
static {
Platform.getNetworkSystem().oneTimeInitialization(true);
}
-
+
/**
* Constructs a new {@code SocketChannel}.
*
* @param selectorProvider
* an instance of SelectorProvider.
- * @since Android 1.0
*/
protected SocketChannel(SelectorProvider selectorProvider) {
super(selectorProvider);
@@ -84,12 +78,10 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* <p>
* This channel is created by calling {@code openSocketChannel()} of the
* default {@link SelectorProvider} instance.
- * </p>
- *
+ *
* @return the new channel which is open but unconnected.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public static SocketChannel open() throws IOException {
return SelectorProvider.provider().openSocketChannel();
@@ -100,8 +92,7 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* <p>
* This method performs a call to {@code open()} followed by a call to
* {@code connect(SocketAdress)}.
- * </p>
- *
+ *
* @param address
* the socket address to be connected to.
* @return the new connected channel.
@@ -121,7 +112,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if the address type is not supported.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public static SocketChannel open(SocketAddress address) throws IOException {
SocketChannel socketChannel = open();
@@ -138,8 +128,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
*
* @return the operations supported by this channel.
* @see java.nio.channels.SelectableChannel#validOps()
- * @since Android 1.0
*/
+ @Override
public final int validOps() {
return (SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE);
}
@@ -149,7 +139,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* methods that are not declared in {@code Socket}.
*
* @return the socket assigned to this channel.
- * @since Android 1.0
*/
public abstract Socket socket();
@@ -158,7 +147,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
*
* @return {@code true} if this channel's socket is connected, {@code false}
* otherwise.
- * @since Android 1.0
*/
public abstract boolean isConnected();
@@ -167,7 +155,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
*
* @return {@code true} if the connection is initiated but not finished;
* {@code false} otherwise.
- * @since Android 1.0
*/
public abstract boolean isConnectionPending();
@@ -179,13 +166,11 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* this method will return {@code true} if the connection is finished at
* once or return {@code false} when the connection must be finished later
* by calling {@code finishConnect()}.
- * </p>
* <p>
* This method can be called at any moment and can block other read and
* write operations while connecting. It executes the same security checks
* as the connect method of the {@code Socket} class.
- * </p>
- *
+ *
* @param address
* the address to connect with.
* @return {@code true} if the connection is finished, {@code false}
@@ -213,7 +198,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* {@code address}.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract boolean connect(SocketAddress address) throws IOException;
@@ -224,17 +208,14 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* This method returns {@code true} if the connection is finished already
* and returns {@code false} if the channel is non-blocking and the
* connection is not finished yet.
- * </p>
* <p>
* If this channel is in blocking mode, this method will suspend and return
* {@code true} when the connection is finished. It closes this channel and
* throws an exception if the connection fails.
- * </p>
* <p>
* This method can be called at any moment and it can block other {@code
* read} and {@code write} operations while connecting.
- * </p>
- *
+ *
* @return {@code true} if the connection is successfully finished, {@code
* false} otherwise.
* @throws NoConnectionPendingException
@@ -251,7 +232,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* interrupt state set, and this channel is closed.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract boolean finishConnect() throws IOException;
@@ -261,16 +241,13 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* The maximum number of bytes that will be read is the remaining number of
* bytes in the buffer when the method is invoked. The bytes will be copied
* into the buffer starting at the buffer's current position.
- * </p>
* <p>
* The call may block if other threads are also attempting to read from this
* channel.
- * </p>
* <p>
* Upon completion, the buffer's position is set to the end of the bytes
* that have been read. The buffer's limit is not changed.
- * </p>
- *
+ *
* @param target
* the byte buffer to receive the bytes.
* @return the number of bytes actually read.
@@ -286,22 +263,19 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if this channel is closed.
* @throws IOException
* if another I/O error occurs.
- * @since Android 1.0
+ * @see java.nio.channels.ReadableByteChannel#read(java.nio.ByteBuffer)
*/
public abstract int read(ByteBuffer target) throws IOException;
/**
- * Reads bytes from this socket channel and stores them in a subset of the
- * specified array of buffers. The subset is defined by {@code offset} and
- * {@code length}, indicating the first buffer and the number of buffers to
- * use. This method attempts to read as many bytes as can be stored in the
- * buffer subset from this channel and returns the number of bytes actually
- * read.
+ * Reads bytes from this socket channel into a subset of the given buffers.
+ * This method attempts to read all {@code remaining()} bytes from {@code
+ * length} byte buffers, in order, starting at {@code targets[offset]}. The
+ * number of bytes actually read is returned.
* <p>
* If a read operation is in progress, subsequent threads will block until
* the read is completed and will then contend for the ability to read.
- * </p>
- *
+ *
* @param targets
* the array of byte buffers into which the bytes will be copied.
* @param offset
@@ -325,7 +299,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if another I/O error occurs.
* @throws NotYetConnectedException
* if this channel is not yet connected.
- * @since Android 1.0
+ * @see java.nio.channels.ScatteringByteChannel#read(java.nio.ByteBuffer[],
+ * int, int)
*/
public abstract long read(ByteBuffer[] targets, int offset, int length)
throws IOException;
@@ -338,12 +313,10 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* <p>
* If a read operation is in progress, subsequent threads will block until
* the read is completed and will then contend for the ability to read.
- * </p>
* <p>
* Calling this method is equivalent to calling {@code read(targets, 0,
* targets.length);}
- * </p>
- *
+ *
* @param targets
* the array of byte buffers into which the bytes will be copied.
* @return the number of bytes actually read.
@@ -360,7 +333,6 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if another I/O error occurs.
* @throws NotYetConnectedException
* if this channel is not yet connected.
- * @since Android 1.0
*/
public synchronized final long read(ByteBuffer[] targets)
throws IOException {
@@ -375,12 +347,10 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* <p>
* The call may block if other threads are also attempting to write to the
* same channel.
- * </p>
* <p>
* Upon completion, the buffer's position is updated to the end of the bytes
* that have been written. The buffer's limit is not changed.
- * </p>
- *
+ *
* @param source
* the byte buffer containing the bytes to be written.
* @return the number of bytes actually written.
@@ -396,19 +366,19 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if another I/O error occurs.
* @throws NotYetConnectedException
* if this channel is not connected yet.
- * @since Android 1.0
+ * @see java.nio.channels.WritableByteChannel#write(java.nio.ByteBuffer)
*/
public abstract int write(ByteBuffer source) throws IOException;
/**
- * Writes bytes from a subset of the specified array of buffers into this
- * socket channel. The subset is defined by {@code offset} and {@code
- * length}, indicating the first buffer and the number of buffers to use.
+ * Attempts to write a subset of the given bytes from the buffers to this
+ * socket channel. This method attempts to write all {@code remaining()}
+ * bytes from {@code length} byte buffers, in order, starting at {@code
+ * sources[offset]}. The number of bytes actually written is returned.
* <p>
* If a write operation is in progress, subsequent threads will block until
* the write is completed and then contend for the ability to write.
- * </p>
- *
+ *
* @param sources
* the array of byte buffers that is the source for bytes written
* to this channel.
@@ -434,7 +404,8 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if another I/O error occurs.
* @throws NotYetConnectedException
* if this channel is not yet connected.
- * @since Android 1.0
+ * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[],
+ * int, int)
*/
public abstract long write(ByteBuffer[] sources, int offset, int length)
throws IOException;
@@ -444,8 +415,7 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* <p>
* Calling this method is equivalent to calling {@code write(sources, 0,
* sources.length);}
- * </p>
- *
+ *
* @param sources
* the buffers containing bytes to write.
* @return the number of bytes actually written.
@@ -462,7 +432,7 @@ public abstract class SocketChannel extends AbstractSelectableChannel implements
* if another I/O error occurs.
* @throws NotYetConnectedException
* if this channel is not yet connected.
- * @since Android 1.0
+ * @see java.nio.channels.GatheringByteChannel#write(java.nio.ByteBuffer[])
*/
public synchronized final long write(ByteBuffer[] sources)
throws IOException {
diff --git a/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java b/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
index dfb475b..426e84c 100644
--- a/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
+++ b/nio/src/main/java/java/nio/channels/UnresolvedAddressException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code UnresolvedAddressException} is thrown when trying to use an
* unresolved network address in a network operation.
- *
- * @since Android 1.0
*/
public class UnresolvedAddressException extends IllegalArgumentException {
@@ -29,8 +26,6 @@ public class UnresolvedAddressException extends IllegalArgumentException {
/**
* Constructs an {@code UnresolvedAddressException}.
- *
- * @since Android 1.0
*/
public UnresolvedAddressException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java b/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
index ba613ac..62c1515 100644
--- a/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
+++ b/nio/src/main/java/java/nio/channels/UnsupportedAddressTypeException.java
@@ -16,12 +16,9 @@
package java.nio.channels;
-
/**
* An {@code UnsupportedAddressTypeException} is thrown when connecting or
* binding to an unsupported address type.
- *
- * @since Android 1.0
*/
public class UnsupportedAddressTypeException extends IllegalArgumentException {
@@ -29,8 +26,6 @@ public class UnsupportedAddressTypeException extends IllegalArgumentException {
/**
* Constructs an {@code UnsupportedAddressTypeException}.
- *
- * @since Android 1.0
*/
public UnsupportedAddressTypeException() {
super();
diff --git a/nio/src/main/java/java/nio/channels/WritableByteChannel.java b/nio/src/main/java/java/nio/channels/WritableByteChannel.java
index f8ea77f..4a9779a 100644
--- a/nio/src/main/java/java/nio/channels/WritableByteChannel.java
+++ b/nio/src/main/java/java/nio/channels/WritableByteChannel.java
@@ -16,7 +16,6 @@
package java.nio.channels;
-
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -28,8 +27,6 @@ import java.nio.ByteBuffer;
* if a write is already in progress on the channel then subsequent writes will
* block until the first write completes. It is undefined whether non-write
* operations will block.
- *
- * @since Android 1.0
*/
public interface WritableByteChannel extends Channel {
@@ -40,17 +37,14 @@ public interface WritableByteChannel extends Channel {
* <code>remaining()</code> number of bytes in the buffer when the method
* invoked. The bytes will be written from the buffer starting at the
* buffer's <code>position</code>.
- * </p>
* <p>
* The call may block if other threads are also attempting to write on the
* same channel.
- * </p>
* <p>
* Upon completion, the buffer's <code>position()</code> is updated to the
* end of the bytes that were written. The buffer's <code>limit()</code>
* is unmodified.
- * </p>
- *
+ *
* @param buffer
* the byte buffer containing the bytes to be written.
* @return the number of bytes actually written.
@@ -65,7 +59,6 @@ public interface WritableByteChannel extends Channel {
* write.
* @throws IOException
* another IO exception occurs, details are in the message.
- * @since Android 1.0
*/
public int write(ByteBuffer buffer) throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java b/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
index 8f84e10..878f731 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
@@ -24,6 +24,7 @@ import java.nio.channels.Channel;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.InterruptibleChannel;
import java.security.AccessController;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
/**
@@ -35,10 +36,7 @@ import java.security.PrivilegedExceptionAction;
* indefinitely, then {@code end(boolean)} after completing the operation. The
* argument to the {@code end} method should indicate if the I/O operation has
* actually completed so that any change may be visible to the invoker.
- * </p>
- *
- * @since Android 1.0
- */
+*/
public abstract class AbstractInterruptibleChannel implements Channel,
InterruptibleChannel {
@@ -56,7 +54,7 @@ public abstract class AbstractInterruptibleChannel implements Channel,
}
});
setInterruptAction.setAccessible(true);
- } catch (Exception e) {
+ } catch (PrivilegedActionException e) {
// FIXME: be accommodate before VM actually provides
// setInterruptAction method
// throw new Error(e);
@@ -69,8 +67,6 @@ public abstract class AbstractInterruptibleChannel implements Channel,
/**
* Default constructor.
- *
- * @since Android 1.0
*/
protected AbstractInterruptibleChannel() {
super();
@@ -82,7 +78,6 @@ public abstract class AbstractInterruptibleChannel implements Channel,
* @return {@code true} if this channel is open, {@code false} if it is
* closed.
* @see java.nio.channels.Channel#isOpen()
- * @since Android 1.0
*/
public synchronized final boolean isOpen() {
return !closed;
@@ -95,16 +90,14 @@ public abstract class AbstractInterruptibleChannel implements Channel,
* <p>
* If an attempt is made to perform an operation on a closed channel then a
* {@link java.nio.channels.ClosedChannelException} is thrown.
- * </p>
* <p>
* If multiple threads attempt to simultaneously close a channel, then only
* one thread will run the closure code and the others will be blocked until
* the first one completes.
- * </p>
- *
+ *
* @throws IOException
* if a problem occurs while closing this channel.
- * @since Android 1.0
+ * @see java.nio.channels.Channel#close()
*/
public final void close() throws IOException {
if (!closed) {
@@ -121,8 +114,6 @@ public abstract class AbstractInterruptibleChannel implements Channel,
* Indicates the beginning of a code section that includes an I/O operation
* that is potentially blocking. After this operation, the application
* should invoke the corresponding {@code end(boolean)} method.
- *
- * @since Android 1.0
*/
protected final void begin() {
// FIXME: be accommodate before VM actually provides
@@ -159,7 +150,6 @@ public abstract class AbstractInterruptibleChannel implements Channel,
* @throws ClosedByInterruptException
* if another thread interrupts the calling thread while this
* method is executing.
- * @since Android 1.0
*/
protected final void end(boolean success) throws AsynchronousCloseException {
// FIXME: be accommodate before VM actually provides
@@ -187,16 +177,13 @@ public abstract class AbstractInterruptibleChannel implements Channel,
* Closes the channel with a guarantee that the channel is not currently
* closed through another invocation of {@code close()} and that the method
* is thread-safe.
- * </p>
* <p>
* Any outstanding threads blocked on I/O operations on this channel must be
* released with either a normal return code, or by throwing an
* {@code AsynchronousCloseException}.
- * </p>
*
* @throws IOException
* if a problem occurs while closing the channel.
- * @since Android 1.0
*/
protected abstract void implCloseChannel() throws IOException;
}
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
index a9bee52..54092ed 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -32,8 +32,6 @@ import java.util.List;
* {@code AbstractSelectableChannel} is the base implementation class for
* selectable channels. It declares methods for registering, unregistering and
* closing selectable channels. It is thread-safe.
- *
- * @since Android 1.0
*/
public abstract class AbstractSelectableChannel extends SelectableChannel {
@@ -44,7 +42,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
*/
private List<SelectionKey> keyList = new ArrayList<SelectionKey>();
- private class BlockingLock {
+ // Marker class so lock type shows up in profilers
+ static private class BlockingLock {
}
private final Object blockingLock = new BlockingLock();
@@ -56,7 +55,6 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
*
* @param selectorProvider
* the selector provider that creates this channel.
- * @since Android 1.0
*/
protected AbstractSelectableChannel(SelectorProvider selectorProvider) {
super();
@@ -68,32 +66,32 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
*
* @see java.nio.channels.SelectableChannel#provider()
* @return this channel's selector provider.
- * @since Android 1.0
*/
+ @Override
public final SelectorProvider provider() {
return provider;
}
/**
* Indicates whether this channel is registered with one or more selectors.
- *
+ *
* @return {@code true} if this channel is registered with a selector,
* {@code false} otherwise.
- * @since Android 1.0
*/
+ @Override
synchronized public final boolean isRegistered() {
return !keyList.isEmpty();
}
/**
* Gets this channel's selection key for the specified selector.
- *
+ *
* @param selector
* the selector with which this channel has been registered.
* @return the selection key for the channel or {@code null} if this channel
* has not been registered with {@code selector}.
- * @since Android 1.0
*/
+ @Override
synchronized public final SelectionKey keyFor(Selector selector) {
for (int i = 0; i < keyList.size(); i++) {
SelectionKey key = keyList.get(i);
@@ -130,8 +128,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
* @throws IllegalSelectorException
* if this channel does not have the same provider as the given
* selector.
- * @since Android 1.0
*/
+ @Override
public final SelectionKey register(Selector selector, int interestSet,
Object attachment) throws ClosedChannelException {
if (!isOpen()) {
@@ -153,10 +151,6 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
// throw NPE exactly to keep consistency
throw new NullPointerException();
}
- if (0 == interestSet) {
- // throw ISE exactly to keep consistency
- throw new IllegalSelectorException();
- }
SelectionKey key = keyFor(selector);
if (null == key) {
key = ((AbstractSelector) selector).register(this, interestSet,
@@ -181,8 +175,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
*
* @throws IOException
* if a problem occurs while closing the channel.
- * @since Android 1.0
*/
+ @Override
synchronized protected final void implCloseChannel() throws IOException {
implCloseSelectableChannel();
for (int i = 0; i < keyList.size(); i++) {
@@ -199,17 +193,16 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
*
* @throws IOException
* if an I/O exception occurs.
- * @since Android 1.0
*/
protected abstract void implCloseSelectableChannel() throws IOException;
/**
* Indicates whether this channel is in blocking mode.
- *
+ *
* @return {@code true} if this channel is blocking, {@code false}
* otherwise.
- * @since Android 1.0
*/
+ @Override
public final boolean isBlocking() {
synchronized (blockingLock) {
return isBlocking;
@@ -219,10 +212,10 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
/**
* Gets the object used for the synchronization of {@code register} and
* {@code configureBlocking}.
- *
+ *
* @return the synchronization object.
- * @since Android 1.0
*/
+ @Override
public final Object blockingLock() {
return blockingLock;
}
@@ -233,6 +226,7 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
* actual setting of the mode is done by calling
* {@code implConfigureBlocking(boolean)}.
*
+ * @see java.nio.channels.SelectableChannel#configureBlocking(boolean)
* @param blockingMode
* {@code true} for setting this channel's mode to blocking,
* {@code false} to set it to non-blocking.
@@ -244,8 +238,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
* registered with at least one selector.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
+ @Override
public final SelectableChannel configureBlocking(boolean blockingMode)
throws IOException {
if (isOpen()) {
@@ -253,7 +247,7 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
if (isBlocking == blockingMode) {
return this;
}
- if (blockingMode && isRegistered()) {
+ if (blockingMode && containsValidKeys()) {
throw new IllegalBlockingModeException();
}
implConfigureBlocking(blockingMode);
@@ -262,7 +256,6 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
return this;
}
throw new ClosedChannelException();
-
}
/**
@@ -273,7 +266,6 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
* {@code false} to set it to non-blocking.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
protected abstract void implConfigureBlocking(boolean blockingMode)
throws IOException;
@@ -287,4 +279,17 @@ public abstract class AbstractSelectableChannel extends SelectableChannel {
}
}
+ /**
+ * Returns true if the keyList contains at least 1 valid key and false
+ * otherwise.
+ */
+ private synchronized boolean containsValidKeys() {
+ for (int i = 0; i < keyList.size(); i++) {
+ SelectionKey key = keyList.get(i);
+ if (key != null && key.isValid()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
index e839126..4c46226 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
package java.nio.channels.spi;
import java.nio.channels.SelectionKey;
@@ -21,8 +21,6 @@ import java.nio.channels.SelectionKey;
/**
* {@code AbstractSelectionKey} is the base implementation class for selection keys.
* It implements validation and cancellation methods.
- *
- * @since Android 1.0
*/
public abstract class AbstractSelectionKey extends SelectionKey {
@@ -33,8 +31,6 @@ public abstract class AbstractSelectionKey extends SelectionKey {
/**
* Constructs a new {@code AbstractSelectionKey}.
- *
- * @since Android 1.0
*/
protected AbstractSelectionKey() {
super();
@@ -43,11 +39,11 @@ public abstract class AbstractSelectionKey extends SelectionKey {
/**
* Indicates whether this key is valid. A key is valid as long as it has not
* been canceled.
- *
+ *
* @return {@code true} if this key has not been canceled, {@code false}
* otherwise.
- * @since Android 1.0
*/
+ @Override
public final boolean isValid() {
return isValid;
}
@@ -57,10 +53,8 @@ public abstract class AbstractSelectionKey extends SelectionKey {
* <p>
* A key that has been canceled is no longer valid. Calling this method on
* an already canceled key does nothing.
- * </p>
- *
- * @since Android 1.0
*/
+ @Override
public final void cancel() {
if (isValid) {
isValid = false;
diff --git a/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java b/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
index adef243..26bbb4f 100644
--- a/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
+++ b/nio/src/main/java/java/nio/channels/spi/AbstractSelector.java
@@ -22,17 +22,16 @@ import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* {@code AbstractSelector} is the base implementation class for selectors.
* It realizes the interruption of selection by {@code begin} and
* {@code end}. It also holds the cancellation and the deletion of the key
* set.
- *
- * @since Android 1.0
*/
public abstract class AbstractSelector extends Selector {
- private volatile boolean isOpen = true;
+ private final AtomicBoolean isOpen = new AtomicBoolean(true);
private SelectorProvider provider = null;
@@ -46,7 +45,6 @@ public abstract class AbstractSelector extends Selector {
*
* @param selectorProvider
* the selector provider that creates this selector.
- * @since Android 1.0
*/
protected AbstractSelector(SelectorProvider selectorProvider) {
provider = selectorProvider;
@@ -59,11 +57,10 @@ public abstract class AbstractSelector extends Selector {
*
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
- public synchronized final void close() throws IOException {
- if (isOpen) {
- isOpen = false;
+ @Override
+ public final void close() throws IOException {
+ if (isOpen.getAndSet(false)) {
implCloseSelector();
}
}
@@ -73,27 +70,26 @@ public abstract class AbstractSelector extends Selector {
*
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
protected abstract void implCloseSelector() throws IOException;
/**
* Indicates whether this selector is open.
- *
+ *
* @return {@code true} if this selector is not closed, {@code false}
* otherwise.
- * @since Android 1.0
*/
+ @Override
public final boolean isOpen() {
- return isOpen;
+ return isOpen.get();
}
/**
* Gets this selector's provider.
*
* @return the provider of this selector.
- * @since Android 1.0
*/
+ @Override
public final SelectorProvider provider() {
return provider;
}
@@ -102,7 +98,6 @@ public abstract class AbstractSelector extends Selector {
* Returns this channel's set of canceled selection keys.
*
* @return the set of canceled selection keys.
- * @since Android 1.0
*/
protected final Set<SelectionKey> cancelledKeys() {
return cancelledKeysSet;
@@ -118,7 +113,6 @@ public abstract class AbstractSelector extends Selector {
* @param attachment
* the attachment for the selection key.
* @return the key related to the channel and this selector.
- * @since Android 1.0
*/
protected abstract SelectionKey register(AbstractSelectableChannel channel,
int operations, Object attachment);
@@ -128,7 +122,6 @@ public abstract class AbstractSelector extends Selector {
*
* @param key
* the key.
- * @since Android 1.0
*/
protected final void deregister(AbstractSelectionKey key) {
((AbstractSelectableChannel) key.channel()).deregister(key);
@@ -139,8 +132,6 @@ public abstract class AbstractSelector extends Selector {
* Indicates the beginning of a code section that includes an I/O operation
* that is potentially blocking. After this operation, the application
* should invoke the corresponding {@code end(boolean)} method.
- *
- * @since Android 1.0
*/
protected final void begin() {
// FIXME: be accommodate before VM actually provides
@@ -162,8 +153,6 @@ public abstract class AbstractSelector extends Selector {
/**
* Indicates the end of a code section that has been started with
* {@code begin()} and that includes a potentially blocking I/O operation.
- *
- * @since Android 1.0
*/
protected final void end() {
// FIXME: be accommodate before VM actually provides
diff --git a/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java b/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
index b4b18e3..b474afa 100644
--- a/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
+++ b/nio/src/main/java/java/nio/channels/spi/SelectorProvider.java
@@ -42,9 +42,6 @@ import org.apache.harmony.nio.internal.SelectorProviderImpl;
* A provider instance can be retrieved through a system property or the
* configuration file in a jar file; if no provide is available that way then
* the system default provider is returned.
- * </p>
- *
- * @since Android 1.0
*/
public abstract class SelectorProvider extends Object {
@@ -55,8 +52,8 @@ public abstract class SelectorProvider extends Object {
private static final String PROVIDER_IN_JAR_RESOURCE = "META-INF/services/java.nio.channels.spi.SelectorProvider"; //$NON-NLS-1$
private static SelectorProvider provider = null;
-
- private static Channel inheritedChannel;
+
+ private static Channel inheritedChannel;
/**
* Constructs a new {@code SelectorProvider}.
@@ -64,7 +61,6 @@ public abstract class SelectorProvider extends Object {
* @throws SecurityException
* if there is a security manager installed that does not permit
* the runtime permission labeled "selectorProvider".
- * @since Android 1.0
*/
protected SelectorProvider() {
super();
@@ -87,9 +83,8 @@ public abstract class SelectorProvider extends Object {
* provider's class name; </li>
* <li> otherwise, a system default provider will be returned.</li>
* </ul>
- *
+ *
* @return the provider.
- * @since Android 1.0
*/
synchronized public static SelectorProvider provider() {
if (null == provider) {
@@ -115,8 +110,8 @@ public abstract class SelectorProvider extends Object {
static SelectorProvider loadProviderByJar() {
Enumeration<URL> enumeration = null;
- ClassLoader classLoader = AccessController.doPrivileged(
- new PrivilegedAction<ClassLoader>() {
+ ClassLoader classLoader = AccessController
+ .doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
return ClassLoader.getSystemClassLoader();
}
@@ -153,40 +148,37 @@ public abstract class SelectorProvider extends Object {
.substring(0, siteComment);
if (0 < className.length()) {
return (SelectorProvider) classLoader.loadClass(
- className).newInstance();
+ className).newInstance();
}
}
} catch (Exception e) {
throw new Error(e);
- // BEGIN android-added
- // copied from a newer version of harmony
} finally {
try {
br.close();
} catch (IOException ioe) {
// Ignore
}
- // END android-added
}
}
return null;
}
/*
- * load by system property.
+ * Load by system property.
*/
static SelectorProvider loadProviderByProperty() {
- return AccessController.doPrivileged(
- new PrivilegedAction<SelectorProvider>() {
+ return AccessController
+ .doPrivileged(new PrivilegedAction<SelectorProvider>() {
public SelectorProvider run() {
try {
- final String className =
- System.getProperty(PROVIDER_IN_SYSTEM_PROPERTY);
+ final String className = System
+ .getProperty(PROVIDER_IN_SYSTEM_PROPERTY);
if (null != className) {
Class<?> spClass = ClassLoader
.getSystemClassLoader().loadClass(
className);
- return (SelectorProvider)spClass.newInstance();
+ return (SelectorProvider) spClass.newInstance();
}
return null;
} catch (Exception e) {
@@ -202,7 +194,6 @@ public abstract class SelectorProvider extends Object {
* @return the new channel.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract DatagramChannel openDatagramChannel() throws IOException;
@@ -212,7 +203,6 @@ public abstract class SelectorProvider extends Object {
* @return the new pipe.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract Pipe openPipe() throws IOException;
@@ -222,7 +212,6 @@ public abstract class SelectorProvider extends Object {
* @return the new selector.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract AbstractSelector openSelector() throws IOException;
@@ -232,7 +221,6 @@ public abstract class SelectorProvider extends Object {
* @return the new channel.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract ServerSocketChannel openServerSocketChannel()
throws IOException;
@@ -243,7 +231,6 @@ public abstract class SelectorProvider extends Object {
* @return the new channel.
* @throws IOException
* if an I/O error occurs.
- * @since Android 1.0
*/
public abstract SocketChannel openSocketChannel() throws IOException;
@@ -257,7 +244,6 @@ public abstract class SelectorProvider extends Object {
* @throws SecurityException
* if there is a security manager installed that does not permit
* the runtime permission labeled "selectorProvider".
- * @since Android 1.0
*/
public Channel inheritedChannel() throws IOException {
// BEGIN android-added
diff --git a/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java b/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
index 7c094e7..315fe57 100644
--- a/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
+++ b/nio/src/main/java/org/apache/harmony/nio/AddressUtil.java
@@ -1,5 +1,4 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
+/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
@@ -16,7 +15,7 @@
*/
/*
- * Android Notice
+ * Android Notice
* In this class the address length was changed from long to int.
* This is due to performance optimizations for the device.
*/
@@ -26,6 +25,10 @@ package org.apache.harmony.nio;
import java.io.FileDescriptor;
import java.nio.Buffer;
import java.nio.channels.Channel;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.FileChannel;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
import org.apache.harmony.luni.platform.FileDescriptorHandler;
import org.apache.harmony.nio.internal.DirectBuffer;
@@ -54,16 +57,17 @@ public class AddressUtil {
}
return ((DirectBuffer) buf).getEffectiveAddress().toInt();
}
-
+
/**
- * Gets the address of native resource held by the given channel, if has
+ * Gets the address of native resource held by the given channel, if it has
* any.
*
- * For network related channel, including SocketChannel, ServerSocketChannel
- * and DatagramChannel, this method returns a int of Socket handler in Linux
- * while returns a SOCKET (UINT_PTR) in windows.
+ * For network related channel, including {@link SocketChannel},
+ * {@link ServerSocketChannel} and {@link DatagramChannel}, this method
+ * returns the Socket handle (long) in Linux, and returns a SOCKET
+ * (UINT_PTR) in windows.
*
- * For FileChannel, this method returns the native file descriptor.
+ * For {@link FileChannel}, this method returns the native file descriptor.
*
* For other channels, this method return 0, which means unsupported
* operation.
@@ -74,10 +78,10 @@ public class AddressUtil {
* otherwise return 0
*/
public static int getChannelAddress(Channel channel){
- if(channel instanceof FileDescriptorHandler){
- return getFDAddress(((FileDescriptorHandler) channel).getFD());
- }else if(channel instanceof FileChannelImpl){
- return ((FileChannelImpl) channel).getHandle();
+ if (channel instanceof FileDescriptorHandler) {
+ return getFDAddress(((FileDescriptorHandler) channel).getFD());
+ } else if (channel instanceof FileChannelImpl) {
+ return ((FileChannelImpl) channel).getHandle();
}
return 0;
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java b/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java
index 5abe24a..e44422d 100644
--- a/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java
+++ b/nio/src/main/java/org/apache/harmony/nio/FileChannelFactory.java
@@ -15,14 +15,13 @@
*/
/*
- * Android Notice
+ * Android Notice
* In this class the address length was changed from long to int.
* This is due to performance optimizations for the device.
*/
package org.apache.harmony.nio;
-
import java.nio.channels.FileChannel;
import org.apache.harmony.nio.internal.ReadOnlyFileChannel;
@@ -37,20 +36,20 @@ import org.apache.harmony.luni.platform.IFileSystem;
*/
public class FileChannelFactory {
public static FileChannel getFileChannel(Object stream, int fd, int mode) {
- switch(mode){
- case IFileSystem.O_RDONLY:
- return new ReadOnlyFileChannel(stream, fd);
- case IFileSystem.O_WRONLY:
- return new WriteOnlyFileChannel(stream, fd);
- case IFileSystem.O_RDWR:
- return new ReadWriteFileChannel(stream, fd);
- case IFileSystem.O_RDWRSYNC:
- return new ReadWriteFileChannel(stream, fd);
- case IFileSystem.O_APPEND:
- return new WriteOnlyFileChannel(stream, fd, true);
- default:
- // nio.09=Unknown file channel type: {0}
- throw new RuntimeException(Messages.getString("nio.09", mode)); //$NON-NLS-1$
+ switch (mode) {
+ case IFileSystem.O_RDONLY:
+ return new ReadOnlyFileChannel(stream, fd);
+ case IFileSystem.O_WRONLY:
+ return new WriteOnlyFileChannel(stream, fd);
+ case IFileSystem.O_RDWR:
+ return new ReadWriteFileChannel(stream, fd);
+ case IFileSystem.O_RDWRSYNC:
+ return new ReadWriteFileChannel(stream, fd);
+ case IFileSystem.O_APPEND:
+ return new WriteOnlyFileChannel(stream, fd, true);
+ default:
+ // nio.09=Unknown file channel type: {0}
+ throw new RuntimeException(Messages.getString("nio.09", mode)); //$NON-NLS-1$
}
}
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
index ac8f77b..513b54c 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/DatagramChannelImpl.java
@@ -18,7 +18,6 @@
package org.apache.harmony.nio.internal;
// BEGIN android-note
-// Copied from a newer version of Harmony.
// In this class the address length was changed from long to int.
// END android-note
@@ -63,7 +62,7 @@ class DatagramChannelImpl extends DatagramChannel implements
private static final int DEFAULT_TIMEOUT = 1;
private static final int ERRCODE_SOCKET_NONBLOCKING_WOULD_BLOCK = -211;
-
+
private static final byte[] stubArray = new byte[0];
// The fd to interact with native code
@@ -245,7 +244,7 @@ class DatagramChannelImpl extends DatagramChannel implements
}
return retAddr;
}
-
+
private SocketAddress receiveImpl(ByteBuffer target, boolean loop)
throws IOException {
SocketAddress retAddr = null;
@@ -256,7 +255,7 @@ class DatagramChannelImpl extends DatagramChannel implements
receivePacket = new DatagramPacket(target.array(), target
.position()
+ target.arrayOffset(), target.remaining());
- } else {
+ } else {
receivePacket = new DatagramPacket(new byte[target.remaining()],
target.remaining());
}
@@ -285,7 +284,7 @@ class DatagramChannelImpl extends DatagramChannel implements
}
}
if (null != receivePacket && null != receivePacket.getAddress()) {
-
+
if (received > 0) {
if (target.hasArray()) {
target.position(oldposition + received);
@@ -300,7 +299,7 @@ class DatagramChannelImpl extends DatagramChannel implements
} while (loop);
return retAddr;
}
-
+
private SocketAddress receiveDirectImpl(ByteBuffer target, boolean loop)
throws IOException {
SocketAddress retAddr = null;
@@ -618,7 +617,7 @@ class DatagramChannelImpl extends DatagramChannel implements
begin();
int length = buf.remaining();
int start = buf.position();
-
+
if (buf.isDirect()) {
int address = AddressUtil.getDirectBufferAddress(buf);
result = networkSystem.sendConnectedDatagramDirect(fd,
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java b/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
index 52a7b65..1af7c54 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/DirectBuffer.java
@@ -18,8 +18,7 @@ package org.apache.harmony.nio.internal;
import org.apache.harmony.luni.platform.PlatformAddress;
public interface DirectBuffer {
- // BEGIN android-changed
- // Copied from a newer version of harmony
+
PlatformAddress getEffectiveAddress();
PlatformAddress getBaseAddress();
@@ -31,5 +30,4 @@ public interface DirectBuffer {
void free();
int getByteCapacity();
- // END android-changed
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
index 687b438..9e72082 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
@@ -16,7 +16,7 @@
*/
/*
- * Android Notice
+ * Android Notice
* In this class the address length was changed from long to int.
* This is due to performance optimizations for the device.
*
@@ -49,7 +49,6 @@ import org.apache.harmony.nio.internal.nls.Messages;
* provided by the port layer.
*
* This class is non-API, but implements the API of the FileChannel interface.
- *
*/
public abstract class FileChannelImpl extends FileChannel {
@@ -73,7 +72,7 @@ public abstract class FileChannelImpl extends FileChannel {
// The object that will track all outstanding locks on this channel.
private final LockManager lockManager = new LockManager();
- private class RepositioningLock {}
+ private static class RepositioningLock {}
private final Object repositioningLock = new RepositioningLock();
private final Object stream;
@@ -115,8 +114,7 @@ public abstract class FileChannelImpl extends FileChannel {
boolean wait) throws IOException {
if ((position < 0) || (size < 0)) {
// nio.0A=Lock position and size must be non-negative.
- throw new IllegalArgumentException(
- Messages.getString("nio.0A")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Messages.getString("nio.0A")); //$NON-NLS-1$
}
int lockType = shared ? IFileSystem.SHARED_LOCK_TYPE
: IFileSystem.EXCLUSIVE_LOCK_TYPE;
@@ -198,8 +196,8 @@ public abstract class FileChannelImpl extends FileChannel {
}
long alignment = position - position % ALLOC_GRANULARITY;
int offset = (int) (position - alignment);
- PlatformAddress address = PlatformAddressFactory.allocMap(handle, alignment, size
- + offset, mapMode);
+ PlatformAddress address = PlatformAddressFactory.allocMap(handle,
+ alignment, size + offset, mapMode);
MappedByteBuffer buffer = null;
try {
buffer = MappedByteBufferFactory.getBuffer(address, mapMode, size,
@@ -225,9 +223,8 @@ public abstract class FileChannelImpl extends FileChannel {
openCheck();
if (newPosition < 0) {
// nio.0B=New position must be non-negative.
- throw new IllegalArgumentException(
- Messages.getString("nio.0B")); //$NON-NLS-1$
- }
+ throw new IllegalArgumentException(Messages.getString("nio.0B")); //$NON-NLS-1$
+ }
synchronized (repositioningLock) {
fileSystem.seek(handle, newPosition, IFileSystem.SEEK_SET);
@@ -236,14 +233,14 @@ public abstract class FileChannelImpl extends FileChannel {
}
public int read(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer){
+ if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
openCheck();
- if (!buffer.hasRemaining()){
+ if (!buffer.hasRemaining()) {
return 0;
}
synchronized (repositioningLock) {
@@ -261,7 +258,7 @@ public abstract class FileChannelImpl extends FileChannel {
public int read(ByteBuffer buffer) throws IOException {
openCheck();
- if (!buffer.hasRemaining()){
+ if (!buffer.hasRemaining()) {
return 0;
}
boolean completed = false;
@@ -273,7 +270,7 @@ public abstract class FileChannelImpl extends FileChannel {
try {
begin();
/*
- * if (bytesRead <= EOF) delt by read completed = false;
+ * if (bytesRead <= EOF) dealt by read completed = false;
*/
bytesRead = (int) fileSystem.readDirect(handle, address,
buffer.position(), buffer.remaining());
@@ -285,7 +282,7 @@ public abstract class FileChannelImpl extends FileChannel {
try {
begin();
/*
- * if (bytesRead <= EOF) delt by read completed = false;
+ * if (bytesRead <= EOF) dealt by read completed = false;
*/
bytesRead = (int) fileSystem.read(handle, buffer.array(),
buffer.arrayOffset() + buffer.position(), buffer
@@ -346,7 +343,7 @@ public abstract class FileChannelImpl extends FileChannel {
}
completed = true;
/*
- * if (bytesRead < EOF) //delt by readv? completed = false;
+ * if (bytesRead < EOF) //dealt by readv? completed = false;
*/
} finally {
end(completed);
@@ -367,16 +364,16 @@ public abstract class FileChannelImpl extends FileChannel {
}
} else {
ByteBuffer buf = directBuffers[i - offset];
- if (bytesRemaining < buf.remaining()){
- // this is the last step.
+ if (bytesRemaining < buf.remaining()) {
+ // this is the last step.
int pos = buf.position();
buffers[i].put(buf);
- buffers[i].position(pos + (int)bytesRemaining);
+ buffers[i].position(pos + (int) bytesRemaining);
bytesRemaining = 0;
} else {
bytesRemaining -= buf.remaining();
buffers[i].put(buf);
- }
+ }
}
}
return bytesRead;
@@ -403,16 +400,15 @@ public abstract class FileChannelImpl extends FileChannel {
if (!src.isOpen()) {
throw new ClosedChannelException();
}
- if (position < 0 || count < 0 || position > Integer.MAX_VALUE
- || count > Integer.MAX_VALUE) {
+ if (position < 0 || count < 0 || count > Integer.MAX_VALUE) {
throw new IllegalArgumentException();
}
- if(position > size()) {
+ if (position > size()) {
return 0;
}
-
+
ByteBuffer buffer = null;
- // BEGIN android-changed
+
try {
if (src instanceof FileChannel) {
FileChannel fileSrc = (FileChannel) src;
@@ -432,10 +428,9 @@ public abstract class FileChannelImpl extends FileChannel {
if (buffer != null) {
// all children of FileChannelImpl currently returns
// an instance of DirectBuffer from map() method
- ((DirectBuffer) buffer).free();
+ ((DirectBuffer) buffer).free();
}
}
- // END android-changed
}
public long transferTo(long position, long count, WritableByteChannel target)
@@ -447,11 +442,10 @@ public abstract class FileChannelImpl extends FileChannel {
if (target instanceof ReadOnlyFileChannel) {
throw new NonWritableChannelException();
}
- if (position < 0 || count < 0 || position > Integer.MAX_VALUE
- || count > Integer.MAX_VALUE) {
+ if (position < 0 || count < 0) {
throw new IllegalArgumentException();
}
-
+
if (count == 0 || position >= size()) {
return 0;
}
@@ -462,7 +456,7 @@ public abstract class FileChannelImpl extends FileChannel {
return kernelTransfer(handle, ((SocketChannelImpl) target).getFD(),
position, count);
}
- // BEGIN android-changed
+
try {
buffer = map(MapMode.READ_ONLY, position, count);
return target.write(buffer);
@@ -474,7 +468,6 @@ public abstract class FileChannelImpl extends FileChannel {
((DirectBuffer) buffer).free();
}
}
- // END android-changed
}
private long kernelTransfer(int l, FileDescriptor fd, long position,
@@ -518,14 +511,14 @@ public abstract class FileChannelImpl extends FileChannel {
*/
public int write(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer){
+ if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
openCheck();
- if (!buffer.hasRemaining()){
+ if (!buffer.hasRemaining()) {
return 0;
}
int bytesWritten = 0;
@@ -653,8 +646,8 @@ public abstract class FileChannelImpl extends FileChannel {
}
return bytesWritten;
}
-
- public int getHandle(){
+
+ public int getHandle() {
return handle;
}
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java
index 4e0ddc9..bfe360b 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/FileLockImpl.java
@@ -16,50 +16,54 @@
package org.apache.harmony.nio.internal;
-
import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
-/*
+/**
* The concrete implementation of an NIO file lock object.
- *
*/
final class FileLockImpl extends FileLock {
// Remembers if this lock has been released via the API.
private boolean isReleased = false;
- /*
- * Returns a new file lock object with the given parameters.
+ /**
+ * Answers a new file lock object with the given parameters.
*
- * @param channel the file channel hosting the lock. @param position the
- * start position of the lock, in bytes @param size the length of the lock,
- * in bytes @param shared whether this lock is shared (true) or exclusive
- * (false)
+ * @param channel
+ * the file channel hosting the lock.
+ * @param position
+ * the start position of the lock, in bytes
+ * @param size
+ * the length of the lock, in bytes
+ * @param shared
+ * whether this lock is shared (true) or exclusive (false)
*/
public FileLockImpl(FileChannel channel, long position, long size,
boolean shared) {
super(channel, position, size, shared);
}
- /*
+ /**
* Tests to see if the lock is valid. A lock can be invalidated if the
* channel it is acquired on is closed or if it is released. (non-Javadoc)
*
* @see java.nio.channels.FileLock#isValid()
*/
+ @Override
public boolean isValid() {
return !isReleased && channel().isOpen();
}
- /*
+ /**
* Releases the file lock on the channel that acquired it. Releasing an
* invalid lock has no effect.
*
* @see java.nio.channels.FileLock#release()
*/
+ @Override
public void release() throws IOException {
if (!channel().isOpen()) {
throw new ClosedChannelException();
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java b/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java
index 6752732..816afcf 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/IOUtil.java
@@ -29,34 +29,20 @@ import java.nio.charset.CoderResult;
import org.apache.harmony.nio.Util;
import org.apache.harmony.nio.internal.nls.Messages;
-
-/*
+/**
* Static methods for I/O util. Used by io package and nio package.
- *
*/
public final class IOUtil {
- // -------------------------------------------------------------------
- // Class variables
- // -------------------------------------------------------------------
-
private static final int DEFAULT_BUFFER_SIZE = 8192;
- // -------------------------------------------------------------------
- // Constructor
- // -------------------------------------------------------------------
-
/*
- * No instance.
+ * Not designed to be instantiated.
*/
private IOUtil() {
super();
}
- // -------------------------------------------------------------------
- // Routine methods.
- // -------------------------------------------------------------------
-
/*
* Read method for InputStreamReader and Channels.
*/
@@ -125,7 +111,7 @@ public final class IOUtil {
}
/*
- * refill the buffer from wrapped InputStream
+ * Refill the buffer from wrapped InputStream.
*/
private static void fillBuf(InputStream in, ByteBuffer bytes,
CharBuffer chars, CharsetDecoder decoder) throws IOException {
@@ -211,7 +197,7 @@ public final class IOUtil {
}
/*
- * convert function used in write.
+ * Convert function used in write.
*/
private static void convert(Object lock, CharsetEncoder encoder,
ByteBuffer bytes, CharBuffer chars, OutputStream out)
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java b/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java
index f3f5a35..b598c15 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/MappedByteBufferFactory.java
@@ -26,17 +26,17 @@ import org.apache.harmony.luni.platform.PlatformAddress;
class MappedByteBufferFactory {
- static final Constructor constructor;
+ static final Constructor<?> constructor;
static {
constructor = AccessController
- .doPrivileged(new PrivilegedAction<Constructor>() {
- public Constructor run() {
+ .doPrivileged(new PrivilegedAction<Constructor<?>>() {
+ public Constructor<?> run() {
try {
- Class wrapperClazz = ClassLoader
+ Class<?> wrapperClazz = ClassLoader
.getSystemClassLoader().loadClass(
"java.nio.MappedByteBufferAdapter"); //$NON-NLS-1$
- Constructor result = wrapperClazz
+ Constructor<?> result = wrapperClazz
.getConstructor(new Class[] {
PlatformAddress.class, int.class,
int.class, int.class });
@@ -51,8 +51,10 @@ class MappedByteBufferFactory {
static MappedByteBuffer getBuffer(PlatformAddress addr, int mapmode,
long size, int offset) throws Exception {
- // Spec points out explicitly that the size of map should be no greater than
- // Integer.MAX_VALUE, so long to int cast is safe here.
+ /*
+ * Spec points out explicitly that the size of map should be no greater
+ * than Integer.MAX_VALUE, so long to int cast is safe here.
+ */
return (MappedByteBuffer) constructor.newInstance(new Object[] { addr,
new Integer((int) size), new Integer(offset),
new Integer(mapmode) });
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java
index beceac4..53e9ce6 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/PipeImpl.java
@@ -108,7 +108,7 @@ final class PipeImpl extends Pipe {
super(provider);
sourceServer = provider.openServerSocketChannel();
sourceServer.socket().bind(
- new InetSocketAddress(InetAddress.getLocalHost(), 0));
+ new InetSocketAddress(InetAddress.getByName(null), 0));
serverPort = sourceServer.socket().getLocalPort();
}
@@ -161,8 +161,8 @@ final class PipeImpl extends Pipe {
}
public boolean finishConnect() throws IOException {
- return sinkSocket.connect(new InetSocketAddress(InetAddress
- .getLocalHost(), serverPort));
+ return sinkSocket.connect(
+ new InetSocketAddress(InetAddress.getByName(null), serverPort));
}
protected void implCloseSelectableChannel() throws IOException {
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java b/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java
index 559fc89..359d108 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/ReadOnlyFileChannel.java
@@ -16,7 +16,7 @@
*/
/*
- * Android Notice
+ * Android Notice
* In this class the address length was changed from long to int.
* This is due to performance optimizations for the device.
*/
@@ -40,10 +40,10 @@ public final class ReadOnlyFileChannel extends FileChannelImpl {
}
public final int write(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer){
+ if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
throw new NonWritableChannelException();
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java
index f863928..c6e9930 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SelectionKeyImpl.java
@@ -4,9 +4,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,37 +20,41 @@ import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.AbstractSelectionKey;
-/*
+/**
* Default implementation of SelectionKey
*/
final class SelectionKeyImpl extends AbstractSelectionKey {
private AbstractSelectableChannel channel;
- int oldInterestOps;
-
private int interestOps;
private int readyOps;
private SelectorImpl selector;
+ // BEGIN android-removed
+ // private int index;
+ // END android-removed
+
public SelectionKeyImpl(AbstractSelectableChannel channel, int operations,
Object attachment, SelectorImpl selector) {
- super();
this.channel = channel;
interestOps = operations;
this.selector = selector;
attach(attachment);
}
+ @Override
public SelectableChannel channel() {
return channel;
}
+ @Override
public int interestOps() {
checkValid();
synchronized (selector.keysLock) {
@@ -58,6 +62,13 @@ final class SelectionKeyImpl extends AbstractSelectionKey {
}
}
+ int interestOpsNoCheck() {
+ synchronized (selector.keysLock) {
+ return interestOps;
+ }
+ }
+
+ @Override
public SelectionKey interestOps(int operations) {
checkValid();
if ((operations & ~(channel().validOps())) != 0) {
@@ -65,15 +76,20 @@ final class SelectionKeyImpl extends AbstractSelectionKey {
}
synchronized (selector.keysLock) {
interestOps = operations;
+ // BEGIN android-removed
+ // selector.modKey(this);
+ // END android-removed
}
return this;
}
+ @Override
public int readyOps() {
checkValid();
return readyOps;
}
+ @Override
public Selector selector() {
return selector;
}
@@ -85,10 +101,28 @@ final class SelectionKeyImpl extends AbstractSelectionKey {
this.readyOps = readyOps;
}
+ // BEGIN android-removed
+ // int getIndex() {
+ // return index;
+ // }
+
+ // void setIndex(int index) {
+ // this.index = index;
+ // }
+ // END android-removed
+
private void checkValid() {
if (!isValid()) {
throw new CancelledKeyException();
}
}
-} \ No newline at end of file
+ /**
+ * Returns true if the channel for this key is connected. If the channel
+ * does not need connecting, this always return true.
+ */
+ boolean isConnected() {
+ return !(channel instanceof SocketChannel)
+ || ((SocketChannel) channel).isConnected();
+ }
+}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
index f8e7d80..9d96454 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
@@ -4,9 +4,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,37 +15,51 @@
*/
package org.apache.harmony.nio.internal;
+// BEGIN android-note
+// This class differs significantly from Harmony. They have adopted indices to
+// track selection keys as-they-change; we avoid that cost by tracking keys on
+// calls to select().
+// END android-note
+
+import org.apache.harmony.luni.platform.FileDescriptorHandler;
+import org.apache.harmony.luni.platform.Platform;
+
import java.io.FileDescriptor;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.IllegalSelectorException;
import java.nio.channels.Pipe;
-import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
+import static java.nio.channels.SelectionKey.*;
import java.nio.channels.Selector;
-import java.nio.channels.SocketChannel;
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.AbstractSelectionKey;
import java.nio.channels.spi.AbstractSelector;
import java.nio.channels.spi.SelectorProvider;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
-import org.apache.harmony.luni.platform.FileDescriptorHandler;
-import org.apache.harmony.luni.platform.Platform;
-
/*
* Default implementation of java.nio.channels.Selector
- *
*/
final class SelectorImpl extends AbstractSelector {
+ private static final int[] EMPTY_INT_ARRAY = new int[0];
+
+ private static final FileDescriptor[] EMPTY_FILE_DESCRIPTORS_ARRAY
+ = new FileDescriptor[0];
+ private static final SelectionKeyImpl[] EMPTY_SELECTION_KEY_IMPLS_ARRAY
+ = new SelectionKeyImpl[0];
+
+ private static final int CONNECT_OR_WRITE = OP_CONNECT | OP_WRITE;
+
+ private static final int ACCEPT_OR_READ = OP_ACCEPT | OP_READ;
+
private static final int MOCK_WRITEBUF_SIZE = 1;
private static final int MOCK_READBUF_SIZE = 8;
@@ -60,38 +74,66 @@ final class SelectorImpl extends AbstractSelector {
private static final int SELECT_NOW = 0;
- // keysLock is used to brief synchronization when get selectionKeys snapshot
- // before selection
- final Object keysLock = new Object();
+ /**
+ * Used to synchronize when a key's interest ops change.
+ */
+ private static class KeysLock {}
+ final Object keysLock = new KeysLock();
- private final Set<SelectionKey> keys = new HashSet<SelectionKey>();
+ private final Set<SelectionKeyImpl> mutableKeys = new HashSet<SelectionKeyImpl>();
+ /**
+ * The unmodifiable set of keys as exposed to the user. This object is used
+ * for synchronization.
+ */
private Set<SelectionKey> unmodifiableKeys = Collections
- .unmodifiableSet(keys);
-
- private final Set<SelectionKey> selectedKeys = new HashSet<SelectionKey>();
+ .<SelectionKey>unmodifiableSet(mutableKeys);
- private Set<SelectionKey> unaddableSelectedKeys = new UnaddableSet<SelectionKey>(
- selectedKeys);
-
- // sink and source are used by wakeup()
- private Pipe.SinkChannel sink;
-
- private Pipe.SourceChannel source;
-
- private FileDescriptor sourcefd;
-
- private SelectionKey[] readableChannels;
+ private final Set<SelectionKey> mutableSelectedKeys = new HashSet<SelectionKey>();
- private SelectionKey[] writableChannels;
+ /**
+ * The unmodifiable set of selectable keys as seen by the user. This object
+ * is used for synchronization.
+ */
+ private final Set<SelectionKey> selectedKeys
+ = new UnaddableSet<SelectionKey>(mutableSelectedKeys);
+
+ /**
+ * File descriptors we're interested in reading from. When actively
+ * selecting, the first element is always the mock channel's file
+ * descriptor, and the other elements are user-specified file descriptors.
+ * Otherwise, all elements are null.
+ */
+ private FileDescriptor[] readableFDs = EMPTY_FILE_DESCRIPTORS_ARRAY;
- private List<FileDescriptor> readableFDs = new ArrayList<FileDescriptor>();
+ /**
+ * File descriptors we're interested in writing from. May be empty. When not
+ * actively selecting, all elements are null.
+ */
+ private FileDescriptor[] writableFDs = EMPTY_FILE_DESCRIPTORS_ARRAY;
- private List<FileDescriptor> writableFDs = new ArrayList<FileDescriptor>();
+ /**
+ * Selection keys that correspond to the concatenation of readableFDs and
+ * writableFDs. This is used to interpret the results returned by select().
+ * When not actively selecting, all elements are null.
+ */
+ private SelectionKeyImpl[] readyKeys = EMPTY_SELECTION_KEY_IMPLS_ARRAY;
- private FileDescriptor[] readable;
+ /**
+ * Selection flags that define the ready ops on the ready keys. When not
+ * actively selecting, all elements are 0. Corresponds to the ready keys
+ * set.
+ */
+ private int[] flags = EMPTY_INT_ARRAY;
- private FileDescriptor[] writable;
+ /**
+ * A mock channel is used to signal wakeups. Whenever the selector should
+ * stop blocking on a select(), a byte is written to the sink and will be
+ * picked up in source by the selecting thread.
+ */
+ private Pipe.SinkChannel sink;
+ private Pipe.SourceChannel source;
+ private FileDescriptor sourcefd;
public SelectorImpl(SelectorProvider selectorProvider) {
super(selectorProvider);
@@ -99,67 +141,82 @@ final class SelectorImpl extends AbstractSelector {
Pipe mockSelector = selectorProvider.openPipe();
sink = mockSelector.sink();
source = mockSelector.source();
- sourcefd = ((FileDescriptorHandler)source).getFD();
+ sourcefd = ((FileDescriptorHandler) source).getFD();
source.configureBlocking(false);
} catch (IOException e) {
- // do nothing
+ // TODO: throw assertion error once IPv6+loopback is fixed
+ e.printStackTrace();
}
}
- /*
+ /**
* @see java.nio.channels.spi.AbstractSelector#implCloseSelector()
*/
+ @Override
protected void implCloseSelector() throws IOException {
- doCancel();
- for (SelectionKey sk : keys) {
- deregister((AbstractSelectionKey) sk);
- }
wakeup();
+ synchronized (this) {
+ synchronized (unmodifiableKeys) {
+ synchronized (selectedKeys) {
+ doCancel();
+ for (SelectionKey sk : mutableKeys) {
+ deregister((AbstractSelectionKey) sk);
+ }
+ }
+ }
+ }
}
- /*
+ /**
* @see java.nio.channels.spi.AbstractSelector#register(java.nio.channels.spi.AbstractSelectableChannel,
* int, java.lang.Object)
*/
+ @Override
protected SelectionKey register(AbstractSelectableChannel channel,
int operations, Object attachment) {
if (!provider().equals(channel.provider())) {
throw new IllegalSelectorException();
}
synchronized (this) {
- synchronized (keys) {
- SelectionKey sk = new SelectionKeyImpl(channel, operations,
- attachment, this);
- keys.add(sk);
- return sk;
+ synchronized (unmodifiableKeys) {
+ SelectionKeyImpl selectionKey = new SelectionKeyImpl(
+ channel, operations, attachment, this);
+ mutableKeys.add(selectionKey);
+ return selectionKey;
}
}
}
- /*
+ /**
* @see java.nio.channels.Selector#keys()
*/
+ @Override
public synchronized Set<SelectionKey> keys() {
closeCheck();
return unmodifiableKeys;
}
+ /*
+ * Checks that the receiver is not closed. If it is throws an exception.
+ */
private void closeCheck() {
if (!isOpen()) {
throw new ClosedSelectorException();
}
}
- /*
+ /**
* @see java.nio.channels.Selector#select()
*/
+ @Override
public int select() throws IOException {
return selectInternal(SELECT_BLOCK);
}
- /*
+ /**
* @see java.nio.channels.Selector#select(long)
*/
+ @Override
public int select(long timeout) throws IOException {
if (timeout < 0) {
throw new IllegalArgumentException();
@@ -167,9 +224,10 @@ final class SelectorImpl extends AbstractSelector {
return selectInternal((0 == timeout) ? SELECT_BLOCK : timeout);
}
- /*
+ /**
* @see java.nio.channels.Selector#selectNow()
*/
+ @Override
public int selectNow() throws IOException {
return selectInternal(SELECT_NOW);
}
@@ -177,156 +235,184 @@ final class SelectorImpl extends AbstractSelector {
private int selectInternal(long timeout) throws IOException {
closeCheck();
synchronized (this) {
- synchronized (keys) {
+ synchronized (unmodifiableKeys) {
synchronized (selectedKeys) {
doCancel();
- int[] readyChannels = null;
boolean isBlock = (SELECT_NOW != timeout);
- // BEGIN android-removed
- // copied from newer version of harmony
- // if (keys.size() == 0) {
- // return 0;
- // }
- // END android-removed
- prepareChannels();
+ int readableKeysCount = 1; // first is always the mock channel
+ int writableKeysCount = 0;
+ synchronized (keysLock) {
+ for (SelectionKeyImpl key : mutableKeys) {
+ int ops = key.interestOpsNoCheck();
+ if ((ACCEPT_OR_READ & ops) != 0) {
+ readableKeysCount++;
+ }
+ if ((CONNECT_OR_WRITE & ops) != 0) {
+ writableKeysCount++;
+ }
+ }
+ prepareChannels(readableKeysCount, writableKeysCount);
+ }
+ boolean success;
try {
if (isBlock) {
begin();
}
- readyChannels = Platform.getNetworkSystem().select(readable, writable, timeout);
+ success = Platform.getNetworkSystem().select(
+ readableFDs, writableFDs, readableKeysCount, writableKeysCount, timeout, flags);
} finally {
- // clear results for next select
- readableFDs.clear();
- writableFDs.clear();
if (isBlock) {
end();
}
}
- return processSelectResult(readyChannels);
+
+ int selected = success ? processSelectResult() : 0;
+
+ Arrays.fill(readableFDs, null);
+ Arrays.fill(writableFDs, null);
+ Arrays.fill(readyKeys, null);
+ Arrays.fill(flags, 0);
+
+ selected -= doCancel();
+
+ return selected;
}
}
}
}
- private boolean isConnected(SelectionKeyImpl key) {
- SelectableChannel channel = key.channel();
- if (channel instanceof SocketChannel) {
- return ((SocketChannel) channel).isConnected();
+ /**
+ * Prepare the readableFDs, writableFDs, readyKeys and flags arrays in
+ * preparation for a call to {@code INetworkSystem#select()}. After they're
+ * used, the array elements must be cleared.
+ */
+ private void prepareChannels(int numReadable, int numWritable) {
+ // grow each array to sufficient capacity. Always grow to at least 1.5x
+ // to avoid growing too frequently
+ if (readableFDs.length < numReadable) {
+ int newSize = Math.max((int) (readableFDs.length * 1.5f), numReadable);
+ readableFDs = new FileDescriptor[newSize];
+ }
+ if (writableFDs.length < numWritable) {
+ int newSize = Math.max((int) (writableFDs.length * 1.5f), numWritable);
+ writableFDs = new FileDescriptor[newSize];
+ }
+ int total = numReadable + numWritable;
+ if (readyKeys.length < total) {
+ int newSize = Math.max((int) (readyKeys.length * 1.5f), total);
+ readyKeys = new SelectionKeyImpl[newSize];
+ flags = new int[newSize];
}
- return true;
- }
- // Prepares and adds channels to list for selection
- private void prepareChannels() {
- readableFDs.add(sourcefd);
- List<SelectionKey> readChannelList = new ArrayList<SelectionKey>();
- readChannelList.add(source.keyFor(this));
- List<SelectionKey> writeChannelList = new ArrayList<SelectionKey>();
- synchronized (keysLock) {
- for (Iterator<SelectionKey> i = keys.iterator(); i.hasNext();) {
- SelectionKeyImpl key = (SelectionKeyImpl) i.next();
- key.oldInterestOps = key.interestOps();
- boolean isReadableChannel = ((SelectionKey.OP_ACCEPT | SelectionKey.OP_READ) & key.oldInterestOps) != 0;
- boolean isWritableChannel = ((SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE) & key.oldInterestOps) != 0;
- SelectableChannel channel = key.channel();
- if (isReadableChannel) {
- readChannelList.add(channel.keyFor(this));
- readableFDs.add(((FileDescriptorHandler)channel).getFD());
- }
- if (isWritableChannel) {
- writeChannelList.add(channel.keyFor(this));
- writableFDs.add(((FileDescriptorHandler)channel).getFD());
- }
+ // populate the FDs, including the mock channel
+ readableFDs[0] = sourcefd;
+ int r = 1;
+ int w = 0;
+ for (SelectionKeyImpl key : mutableKeys) {
+ int interestOps = key.interestOpsNoCheck();
+ if ((ACCEPT_OR_READ & interestOps) != 0) {
+ readableFDs[r] = ((FileDescriptorHandler) key.channel()).getFD();
+ readyKeys[r] = key;
+ r++;
+ }
+ if ((CONNECT_OR_WRITE & interestOps) != 0) {
+ writableFDs[w] = ((FileDescriptorHandler) key.channel()).getFD();
+ readyKeys[w + numReadable] = key;
+ w++;
}
}
- readableChannels = readChannelList.toArray(new SelectionKey[0]);
- writableChannels = writeChannelList.toArray(new SelectionKey[0]);
- readable = readableFDs.toArray(new FileDescriptor[0]);
- writable = writableFDs.toArray(new FileDescriptor[0]);
}
- // Analyses selected channels and adds keys of ready channels to
- // selectedKeys list
- private int processSelectResult(int[] readyChannels) throws IOException {
- if (0 == readyChannels.length) {
- return 0;
- }
+ /**
+ * Updates the key ready ops and selected key set with data from the flags
+ * array.
+ */
+ private int processSelectResult() throws IOException {
// if the mock channel is selected, read the content.
- if (READABLE == readyChannels[0]) {
+ if (READABLE == flags[0]) {
ByteBuffer readbuf = ByteBuffer.allocate(MOCK_READBUF_SIZE);
while (source.read(readbuf) > 0) {
readbuf.flip();
}
}
int selected = 0;
- for (int i = 1; i < readyChannels.length; i++) {
- SelectionKeyImpl key = (SelectionKeyImpl) (i >= readable.length ? writableChannels[i
- - readable.length]
- : readableChannels[i]);
- if (null == key) {
+
+ for (int i = 1; i < flags.length; i++) {
+ if (flags[i] == NA) {
continue;
}
- boolean isOldSelectedKey = selectedKeys.contains(key);
+
+ SelectionKeyImpl key = readyKeys[i];
+ int ops = key.interestOpsNoCheck();
int selectedOp = 0;
- // set ready ops
- switch (readyChannels[i]) {
- case NA:
- selectedOp = 0;
- break;
- case READABLE:
- selectedOp = (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)
- & key.oldInterestOps;
- break;
- case WRITEABLE:
- if (isConnected(key)) {
- selectedOp = SelectionKey.OP_WRITE & key.oldInterestOps;
- } else {
- selectedOp = SelectionKey.OP_CONNECT & key.oldInterestOps;
- }
- break;
+
+ switch (flags[i]) {
+ case READABLE:
+ selectedOp = ACCEPT_OR_READ & ops;
+ break;
+ case WRITEABLE:
+ if (key.isConnected()) {
+ selectedOp = OP_WRITE & ops;
+ } else {
+ selectedOp = OP_CONNECT & ops;
+ }
+ break;
}
if (0 != selectedOp) {
- if (isOldSelectedKey && key.readyOps() != selectedOp) {
+ boolean wasSelected = mutableSelectedKeys.contains(key);
+ if (wasSelected && key.readyOps() != selectedOp) {
key.setReadyOps(key.readyOps() | selectedOp);
selected++;
- } else if (!isOldSelectedKey) {
+ } else if (!wasSelected) {
key.setReadyOps(selectedOp);
- selectedKeys.add(key);
+ mutableSelectedKeys.add(key);
selected++;
}
}
}
- readableChannels = null;
- writableChannels = null;
+
return selected;
}
- /*
+ /**
* @see java.nio.channels.Selector#selectedKeys()
*/
+ @Override
public synchronized Set<SelectionKey> selectedKeys() {
closeCheck();
- return unaddableSelectedKeys;
+ return selectedKeys;
}
- private void doCancel() {
+ /**
+ * Removes cancelled keys from the key set and selected key set, and
+ * deregisters the corresponding channels. Returns the number of keys
+ * removed from the selected key set.
+ */
+ private int doCancel() {
+ int deselected = 0;
+
Set<SelectionKey> cancelledKeys = cancelledKeys();
synchronized (cancelledKeys) {
if (cancelledKeys.size() > 0) {
for (SelectionKey currentkey : cancelledKeys) {
+ mutableKeys.remove(currentkey);
deregister((AbstractSelectionKey) currentkey);
- keys.remove(currentkey);
- selectedKeys.remove(currentkey);
+ if (mutableSelectedKeys.remove(currentkey)) {
+ deselected++;
+ }
}
+ cancelledKeys.clear();
}
- cancelledKeys.clear();
}
+
+ return deselected;
}
- /*
+ /**
* @see java.nio.channels.Selector#wakeup()
*/
+ @Override
public Selector wakeup() {
try {
sink.write(ByteBuffer.allocate(MOCK_WRITEBUF_SIZE));
@@ -338,16 +424,18 @@ final class SelectorImpl extends AbstractSelector {
private static class UnaddableSet<E> implements Set<E> {
- private Set<E> set;
+ private final Set<E> set;
UnaddableSet(Set<E> set) {
this.set = set;
}
+ @Override
public boolean equals(Object object) {
return set.equals(object);
}
+ @Override
public int hashCode() {
return set.hashCode();
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java
index d774b3a..0c75808 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SelectorProviderImpl.java
@@ -25,10 +25,8 @@ import java.nio.channels.SocketChannel;
import java.nio.channels.spi.AbstractSelector;
import java.nio.channels.spi.SelectorProvider;
-
/*
* Internal implementation of SelectorProvider.
- *
*/
public class SelectorProviderImpl extends SelectorProvider {
@@ -39,44 +37,38 @@ public class SelectorProviderImpl extends SelectorProvider {
super();
}
- /*
- *
+ /**
* @see java.nio.channels.spi.SelectorProvider#openDatagramChannel()
*/
public DatagramChannel openDatagramChannel() throws IOException {
return new DatagramChannelImpl(this);
}
- /*
- *
+ /**
* @see java.nio.channels.spi.SelectorProvider#openPipe()
*/
public Pipe openPipe() throws IOException {
return new PipeImpl();
}
- /*
- *
+ /**
* @see java.nio.channels.spi.SelectorProvider#openSelector()
*/
public AbstractSelector openSelector() throws IOException {
return new SelectorImpl(this);
}
- /*
- *
+ /**
* @see java.nio.channels.spi.SelectorProvider#openServerSocketChannel()
*/
public ServerSocketChannel openServerSocketChannel() throws IOException {
return new ServerSocketChannelImpl(this);
}
- /*
- *
+ /**
* @see java.nio.channels.spi.SelectorProvider#openSocketChannel()
*/
public SocketChannel openSocketChannel() throws IOException {
return new SocketChannelImpl(this);
}
-
}
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
index dbef656..22d1b4a 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
@@ -126,15 +126,17 @@ public class ServerSocketChannelImpl extends ServerSocketChannel implements
synchronized (blockingLock()) {
boolean isBlocking = isBlocking();
if (!isBlocking) {
- // for non blocking mode, use select to see whether
- // there are any pending connections.
- int[] tryResult = Platform.getNetworkSystem().select(
+ // BEGIN android-changed
+ // copied from a newer version of Harmony
+ int[] tryResult = new int[1];
+ boolean success = Platform.getNetworkSystem().select(
new FileDescriptor[] { this.fd },
- new FileDescriptor[0], 0);
- if (0 == tryResult.length || 0 == tryResult[0]) {
+ new FileDescriptor[0], 1, 0, 0, tryResult);
+ if (!success || 0 == tryResult[0]) {
// no pending connections, returns immediately.
return null;
}
+ // END android-changed
}
// do accept.
do {
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java b/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
index 1affb21..eec482f 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/SocketChannelImpl.java
@@ -18,7 +18,6 @@
package org.apache.harmony.nio.internal;
// BEGIN android-note
-// Copied from a newer version of Harmony.
// In this class the address length was changed from long to int.
// END android-note
@@ -376,7 +375,7 @@ class SocketChannelImpl extends SocketChannel implements FileDescriptorHandler {
if (!target.hasRemaining()) {
return 0;
}
-
+
int readCount;
if (target.isDirect() || target.hasArray()) {
readCount = readImpl(target);
diff --git a/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java b/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java
index ffcdd14..eb46043 100644
--- a/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java
+++ b/nio/src/main/java/org/apache/harmony/nio/internal/WriteOnlyFileChannel.java
@@ -16,7 +16,7 @@
*/
/*
- * Android Notice
+ * Android Notice
* In this class the address length was changed from long to int.
* This is due to performance optimizations for the device.
*/
@@ -43,9 +43,10 @@ public final class WriteOnlyFileChannel extends FileChannelImpl {
super(stream, handle);
append = isAppend;
}
-
+
/*
* (non-Javadoc)
+ *
* @see org.apache.harmony.nio.internal.FileChannelImpl#position()
*/
public long position() throws IOException {
@@ -62,7 +63,7 @@ public final class WriteOnlyFileChannel extends FileChannelImpl {
}
public long read(ByteBuffer[] buffers, int offset, int length)
- throws IOException {
+ throws IOException {
if (offset < 0 || length < 0 || offset + length > buffers.length) {
throw new IndexOutOfBoundsException();
}
@@ -75,11 +76,11 @@ public final class WriteOnlyFileChannel extends FileChannelImpl {
throw new NonReadableChannelException();
}
- public int read(ByteBuffer buffer, long position) throws IOException {
+ public int read(ByteBuffer buffer, long position) throws IOException {
if (null == buffer) {
throw new NullPointerException();
}
- if (position < 0){
+ if (position < 0) {
throw new IllegalArgumentException();
}
throw new NonReadableChannelException();
@@ -111,5 +112,4 @@ public final class WriteOnlyFileChannel extends FileChannelImpl {
}
return super.basicLock(position, size, shared, wait);
}
-
}