Class ObjectBufferChannel

java.lang.Object
  extended by ObjectBufferChannel
All Implemented Interfaces:
ObjectChannel

public class ObjectBufferChannel
extends java.lang.Object
implements ObjectChannel

ObjectBufferChannel. This class creates a communication channel using a socket.

Author:
Heinz Kredel.

Field Summary
(package private) static int DEFAULT_CAPACITY
          default capacity for ByteBuffer.
(package private)  java.nio.ByteBuffer hbb
          heap ByteBuffer.
(package private)  ObjectBuffer ob
          object ByteBuffer wraper.
(package private)  java.nio.channels.SocketChannel soc
          socket channel.
 
Constructor Summary
ObjectBufferChannel(java.nio.channels.SocketChannel s)
          Constructs a socket channel on the given socket s.
ObjectBufferChannel(java.nio.channels.SocketChannel s, int cap)
          Constructs a socket channel on the given socket s.
 
Method Summary
 void close()
          Closes the channel.
 java.lang.Object receive()
          Receives an object.
 void send(java.lang.Object v)
          Sends an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CAPACITY

static final int DEFAULT_CAPACITY
default capacity for ByteBuffer.

See Also:
Constant Field Values

hbb

final java.nio.ByteBuffer hbb
heap ByteBuffer.


ob

final ObjectBuffer ob
object ByteBuffer wraper.


soc

final java.nio.channels.SocketChannel soc
socket channel.

Constructor Detail

ObjectBufferChannel

public ObjectBufferChannel(java.nio.channels.SocketChannel s,
                           int cap)
                    throws java.io.IOException
Constructs a socket channel on the given socket s.

Parameters:
s - socket channel.
cap - capacity of ByteBuffer.
Throws:
java.io.IOException

ObjectBufferChannel

public ObjectBufferChannel(java.nio.channels.SocketChannel s)
                    throws java.io.IOException
Constructs a socket channel on the given socket s.

Parameters:
s - socket channel.
Throws:
java.io.IOException
Method Detail

send

public void send(java.lang.Object v)
          throws java.io.IOException
Sends an object.

Specified by:
send in interface ObjectChannel
Parameters:
v - Object to send.
Throws:
java.io.IOException

receive

public java.lang.Object receive()
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
Receives an object.

Specified by:
receive in interface ObjectChannel
Returns:
received Object.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

close

public void close()
Closes the channel.

Specified by:
close in interface ObjectChannel