org.restlet.engine.io
Class InputStreamChannel

java.lang.Object
  extended by org.restlet.engine.io.InputStreamChannel
All Implemented Interfaces:
Closeable, Channel, ReadableByteChannel, BlockableChannel

public class InputStreamChannel
extends Object
implements ReadableByteChannel, BlockableChannel

Readable byte channel wrapping an input stream.

Author:
Jerome Louvel

Constructor Summary
InputStreamChannel(InputStream inputStream)
          Constructor.
 
Method Summary
 void close()
          Closes the underlying input stream.
protected  InputStream getInputStream()
          Returns the underlying input stream.
 boolean isBlocking()
          True if the underlying input stream is able to indicate available bytes upfront.
 boolean isOpen()
          Indicates if the channel and its underlying stream are open.
 int read(ByteBuffer target)
          Reads bytes from the underlying stream to the target buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamChannel

public InputStreamChannel(InputStream inputStream)
                   throws IOException
Constructor.

Parameters:
inputStream -
Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Closes the underlying input stream.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException

getInputStream

protected InputStream getInputStream()
Returns the underlying input stream.

Returns:
The underlying input stream.

isBlocking

public boolean isBlocking()
True if the underlying input stream is able to indicate available bytes upfront.

Specified by:
isBlocking in interface BlockableChannel
Returns:
True if the channel is blocking.

isOpen

public boolean isOpen()
Indicates if the channel and its underlying stream are open.

Specified by:
isOpen in interface Channel
Returns:
True if the channel and its underlying stream are open.

read

public int read(ByteBuffer target)
         throws IOException
Reads bytes from the underlying stream to the target buffer.

Specified by:
read in interface ReadableByteChannel
Parameters:
target - The target byte buffer.
Returns:
The number of bytes read.
Throws:
IOException


Copyright © 2005-2013 Restlet.