org.elkoserver.foundation.net
Class JSONByteIOFramer

java.lang.Object
  extended by org.elkoserver.foundation.net.JSONByteIOFramer
All Implemented Interfaces:
ByteIOFramer

public class JSONByteIOFramer
extends Object
implements ByteIOFramer

I/O framer implementation for JSON messages.


Constructor Summary
JSONByteIOFramer(Trace msgTrace, MessageReceiver receiver, String label)
          Constructor.
JSONByteIOFramer(Trace msgTrace, MessageReceiver receiver, String label, ChunkyByteArrayInputStream in)
          Constructor with explicit input.
 
Method Summary
 byte[] produceBytes(Object message)
          Generate the bytes for writing a message to a connection.
 void receiveBytes(byte[] data, int length)
          Process bytes of data received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONByteIOFramer

public JSONByteIOFramer(Trace msgTrace,
                        MessageReceiver receiver,
                        String label)
Constructor.


JSONByteIOFramer

public JSONByteIOFramer(Trace msgTrace,
                        MessageReceiver receiver,
                        String label,
                        ChunkyByteArrayInputStream in)
Constructor with explicit input.

Method Detail

receiveBytes

public void receiveBytes(byte[] data,
                         int length)
                  throws IOException
Process bytes of data received.

Specified by:
receiveBytes in interface ByteIOFramer
Parameters:
data - The bytes received.
length - Number of usable bytes in 'data'. End of input is indicated by passing a 'length' value of 0.
Throws:
IOException

produceBytes

public byte[] produceBytes(Object message)
                    throws IOException
Generate the bytes for writing a message to a connection.

Specified by:
produceBytes in interface ByteIOFramer
Parameters:
message - The message to be written. In this implementation, the message must be a string.
Returns:
a byte array containing the writable form of 'message'.
Throws:
IOException