org.jboss.xnio.nio
Class NioPipeSourceChannelImpl

java.lang.Object
  extended by org.jboss.xnio.nio.NioPipeSourceChannelImpl
All Implemented Interfaces:
java.io.Closeable, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, Configurable, StreamSourceChannel, SuspendableReadChannel

public final class NioPipeSourceChannelImpl
extends java.lang.Object
implements StreamSourceChannel


Constructor Summary
NioPipeSourceChannelImpl(java.nio.channels.Pipe.SourceChannel channel, IoHandler<? super StreamSourceChannel> handler, NioXnio nioXnio, java.io.Closeable mbeanHandle)
           
 
Method Summary
 void awaitReadable()
          Block until this channel becomes readable again.
 void awaitReadable(long time, java.util.concurrent.TimeUnit timeUnit)
          Block until this channel becomes readable again, or until the timeout expires.
 void close()
           
<T> T
getOption(ChannelOption<T> option)
          Get the value of a channel option.
 java.util.Set<ChannelOption<?>> getOptions()
          Get the options that may be set on this channel.
 boolean isOpen()
           
 int read(java.nio.ByteBuffer dst)
           
 long read(java.nio.ByteBuffer[] dsts)
           
 long read(java.nio.ByteBuffer[] dsts, int offset, int length)
           
 void resumeReads()
          Resume reads on this channel.
<T> Configurable
setOption(ChannelOption<T> option, T value)
          Set an option for this channel.
 void shutdownReads()
          Places this readable channel at "end of stream".
 void suspendReads()
          Suspend further reads on this channel.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NioPipeSourceChannelImpl

public NioPipeSourceChannelImpl(java.nio.channels.Pipe.SourceChannel channel,
                                IoHandler<? super StreamSourceChannel> handler,
                                NioXnio nioXnio,
                                java.io.Closeable mbeanHandle)
                         throws java.io.IOException
Throws:
java.io.IOException
Method Detail

read

public int read(java.nio.ByteBuffer dst)
         throws java.io.IOException
Specified by:
read in interface java.nio.channels.ReadableByteChannel
Throws:
java.io.IOException

read

public long read(java.nio.ByteBuffer[] dsts)
          throws java.io.IOException
Specified by:
read in interface java.nio.channels.ScatteringByteChannel
Throws:
java.io.IOException

read

public long read(java.nio.ByteBuffer[] dsts,
                 int offset,
                 int length)
          throws java.io.IOException
Specified by:
read in interface java.nio.channels.ScatteringByteChannel
Throws:
java.io.IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface java.nio.channels.Channel

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in interface java.nio.channels.Channel
Throws:
java.io.IOException

suspendReads

public void suspendReads()
Description copied from interface: SuspendableReadChannel
Suspend further reads on this channel. The IoReadHandler.handleReadable(java.nio.channels.Channel) method will not be called until reads are resumed.

Specified by:
suspendReads in interface SuspendableReadChannel

resumeReads

public void resumeReads()
Description copied from interface: SuspendableReadChannel
Resume reads on this channel. The IoReadHandler.handleReadable(java.nio.channels.Channel) method will be called as soon as there is data available to be read.

Specified by:
resumeReads in interface SuspendableReadChannel

shutdownReads

public void shutdownReads()
                   throws java.io.IOException
Description copied from interface: SuspendableReadChannel
Places this readable channel at "end of stream". Further reads will result in EOF.

Specified by:
shutdownReads in interface SuspendableReadChannel
Throws:
java.io.IOException - if an I/O error occurs

awaitReadable

public void awaitReadable()
                   throws java.io.IOException
Description copied from interface: SuspendableReadChannel
Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.

Specified by:
awaitReadable in interface SuspendableReadChannel
Throws:
java.io.IOException - if an I/O error occurs

awaitReadable

public void awaitReadable(long time,
                          java.util.concurrent.TimeUnit timeUnit)
                   throws java.io.IOException
Description copied from interface: SuspendableReadChannel
Block until this channel becomes readable again, or until the timeout expires. This method may return spuriously before the channel becomes readable or the timeout expires.

Specified by:
awaitReadable in interface SuspendableReadChannel
Parameters:
time - the time to wait
timeUnit - the time unit
Throws:
java.io.IOException - if an I/O error occurs

getOption

public <T> T getOption(ChannelOption<T> option)
            throws UnsupportedOptionException,
                   java.io.IOException
Description copied from interface: Configurable
Get the value of a channel option.

Specified by:
getOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to get
Returns:
the value of the option
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.io.IOException - if an I/O error occurred when reading the option

setOption

public <T> Configurable setOption(ChannelOption<T> option,
                                  T value)
                       throws java.lang.IllegalArgumentException,
                              java.io.IOException
Description copied from interface: Configurable
Set an option for this channel.

Specified by:
setOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to set
value - the value of the option to set
Returns:
this channel
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.lang.IllegalArgumentException - if the value is not acceptable for this option
java.io.IOException - if an I/O error occured when modifying the option

getOptions

public java.util.Set<ChannelOption<?>> getOptions()
Description copied from interface: Configurable
Get the options that may be set on this channel.

Specified by:
getOptions in interface Configurable
Returns:
an unmodifiable set of options

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object