XNIO API 2.0.0.GA

org.jboss.xnio.channels
Class BlockingByteChannel

java.lang.Object
  extended by org.jboss.xnio.channels.BlockingByteChannel
All Implemented Interfaces:
java.io.Closeable, java.nio.channels.ByteChannel, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.WritableByteChannel

public class BlockingByteChannel
extends java.lang.Object
implements java.nio.channels.ScatteringByteChannel, java.nio.channels.GatheringByteChannel, java.nio.channels.ByteChannel

A blocking wrapper for a StreamChannel. Read and write operations will block until some data may be transferred. Once any amount of data is read or written, the operation will return.


Constructor Summary
BlockingByteChannel(StreamChannel delegate)
          Construct a new instance.
 
Method Summary
 void close()
          
 boolean isOpen()
          
 int read(java.nio.ByteBuffer dst)
          Perform a blocking read operation.
 long read(java.nio.ByteBuffer[] dsts)
          Perform a blocking, scattering read operation.
 long read(java.nio.ByteBuffer[] dsts, int offset, int length)
          Perform a blocking, scattering read operation.
 int write(java.nio.ByteBuffer src)
          Perform a blocking write operation.
 long write(java.nio.ByteBuffer[] srcs)
          Perform a blocking, gathering write operation.
 long write(java.nio.ByteBuffer[] srcs, int offset, int length)
          Perform a blocking, gathering write operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingByteChannel

public BlockingByteChannel(StreamChannel delegate)
Construct a new instance.

Parameters:
delegate - the channel to forward I/O operations to
Method Detail

read

public long read(java.nio.ByteBuffer[] dsts,
                 int offset,
                 int length)
          throws java.io.IOException
Perform a blocking, scattering read operation.

Specified by:
read in interface java.nio.channels.ScatteringByteChannel
Parameters:
dsts - the destination buffers
offset - the offset into the destination buffer array
length - the number of buffers to read into
Returns:
the number of bytes actually read (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

read

public long read(java.nio.ByteBuffer[] dsts)
          throws java.io.IOException
Perform a blocking, scattering read operation.

Specified by:
read in interface java.nio.channels.ScatteringByteChannel
Parameters:
dsts - the destination buffers
Returns:
the number of bytes actually read (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

read

public int read(java.nio.ByteBuffer dst)
         throws java.io.IOException
Perform a blocking read operation.

Specified by:
read in interface java.nio.channels.ReadableByteChannel
Parameters:
dst - the destination buffer
Returns:
the number of bytes actually read (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

write

public long write(java.nio.ByteBuffer[] srcs,
                  int offset,
                  int length)
           throws java.io.IOException
Perform a blocking, gathering write operation.

Specified by:
write in interface java.nio.channels.GatheringByteChannel
Parameters:
srcs - the source buffers
offset - the offset into the destination buffer array
length - the number of buffers to write from
Returns:
the number of bytes actually written (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

write

public long write(java.nio.ByteBuffer[] srcs)
           throws java.io.IOException
Perform a blocking, gathering write operation.

Specified by:
write in interface java.nio.channels.GatheringByteChannel
Parameters:
srcs - the source buffers
Returns:
the number of bytes actually written (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

write

public int write(java.nio.ByteBuffer src)
          throws java.io.IOException
Perform a blocking write operation.

Specified by:
write in interface java.nio.channels.WritableByteChannel
Parameters:
src - the source buffer
Returns:
the number of bytes actually written (will be greater than zero)
Throws:
java.io.IOException - if an I/O error occurs

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

XNIO API 2.0.0.GA

Copyright © 2009 JBoss, a division of Red Hat, Inc.