public abstract class InputStreamChannel extends InputStream implements ReadableByteChannel, Closeable
| Modifier and Type | Field and Description |
|---|---|
protected long |
bytesRead |
protected ReadableByteChannel |
channel |
protected static long |
PARK_NANOS_MAX
Maximum nanos to park reader thread to wait for writing data in
non-blocking mode (if selector is present then it will explicitly signal)
|
protected Thread |
parkedThread |
| Modifier | Constructor and Description |
|---|---|
protected |
InputStreamChannel(ReadableByteChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
long |
getBytesRead() |
Thread |
getParkedThread() |
ReadableByteChannel |
getUnderlyingChannel()
Get the underlying
ReadableByteChannel. |
abstract int |
read(ByteBuffer dst) |
protected int |
readBuffered(ByteBuffer dst,
ByteBuffer channelBuffer)
Common base method to read into a given ByteBuffer destination via an
intermediate direct byte buffer owned by the implementation of this class.
|
int |
readFrame() |
int |
readFrameFragment(int fragmentSize) |
abstract int |
readInt()
Reads four input bytes and returns an
int value. |
protected int |
readIntoBuffer(ByteBuffer buffer)
Fill the given buffer reading data from channel at least one byte unless
end-of-stream has been reached.
|
protected int |
readIntoBufferNonBlocking(ByteBuffer buffer)
Fill the given buffer reading data from channel whatever is available in
one call (non-blocking if channel is so configured).
|
protected int |
refillBuffer(ByteBuffer channelBuffer,
int tryReadBytes,
String eofMessage) |
protected int |
refillBufferBase(ByteBuffer channelBuffer,
int tryReadBytes,
String eofMessage) |
protected void |
resetAndCopyLeftOverBytes(ByteBuffer channelBuffer) |
available, close, mark, markSupported, read, read, read, reset, skipprotected final ReadableByteChannel channel
protected volatile Thread parkedThread
protected volatile long bytesRead
protected static final long PARK_NANOS_MAX
protected InputStreamChannel(ReadableByteChannel channel)
public final ReadableByteChannel getUnderlyingChannel()
ReadableByteChannel.public abstract int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelIOExceptionpublic abstract int readInt()
throws IOException
int value. Let
a-d be the first through fourth bytes read. The value returned
is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) |
((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the
writeInt method of interface DataOutput.int value read.EOFException - if this stream reaches the end before reading all the bytes.IOException - if an I/O error occurs.public int readFrame()
throws IOException
IOExceptionpublic int readFrameFragment(int fragmentSize)
throws IOException
IOExceptionprotected final int readBuffered(ByteBuffer dst, ByteBuffer channelBuffer) throws IOException
IOExceptionprotected int refillBuffer(ByteBuffer channelBuffer, int tryReadBytes, String eofMessage) throws IOException
IOExceptionprotected final int refillBufferBase(ByteBuffer channelBuffer, int tryReadBytes, String eofMessage) throws IOException
IOExceptionprotected void resetAndCopyLeftOverBytes(ByteBuffer channelBuffer)
protected int readIntoBuffer(ByteBuffer buffer) throws IOException
IOExceptionprotected int readIntoBufferNonBlocking(ByteBuffer buffer) throws IOException
IOExceptionpublic final Thread getParkedThread()
public final long getBytesRead()
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.