org.otfeed.support.mock
Class SpyStreamerFactory

java.lang.Object
  extended by org.otfeed.support.mock.SpyStreamerFactory
All Implemented Interfaces:
IStreamerFactory

public class SpyStreamerFactory
extends java.lang.Object
implements IStreamerFactory

Wrapper around IStreamerFactory to log content of frames to the print stream. Useful for testing, tracing, and debugging.


Constructor Summary
SpyStreamerFactory(IStreamerFactory engine)
          Creates new spy with the empty id string, wrapping an instance of IStreamerFactory.
SpyStreamerFactory(java.lang.String id, IStreamerFactory engine)
          Creates new spy with the given id string, wrapping an instance of IStreamerFactory.
 
Method Summary
 IStreamer connect(java.lang.String host, int port)
          Creates a connection (synchronously).
 IFormat<java.nio.ByteBuffer> getFormat()
          Format to use when converting ByteBuffer s to human-readable form.
 java.lang.String getId()
          Identification string (optional).
 java.io.PrintStream getReadLogStream()
          Destination for logging the incoming frames.
 java.io.PrintStream getWriteLogStream()
          Destination for logging the outgoing frames.
 void setFormat(IFormat<java.nio.ByteBuffer> val)
          Sets format.
 void setId(java.lang.String val)
          Sets identification sting.
 void setReadLogStream(java.io.PrintStream val)
          Sets read log stream.
 void setWriteLogStream(java.io.PrintStream val)
          Sets write log stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpyStreamerFactory

public SpyStreamerFactory(java.lang.String id,
                          IStreamerFactory engine)
Creates new spy with the given id string, wrapping an instance of IStreamerFactory.

Parameters:
id - id string.
engine - wrapped instance.

SpyStreamerFactory

public SpyStreamerFactory(IStreamerFactory engine)
Creates new spy with the empty id string, wrapping an instance of IStreamerFactory.

Parameters:
engine - wrapped instance.
Method Detail

getReadLogStream

public java.io.PrintStream getReadLogStream()
Destination for logging the incoming frames. Defaults to System.out.

Returns:
print stream.

setReadLogStream

public void setReadLogStream(java.io.PrintStream val)
Sets read log stream.

Parameters:
val - print stream.

getWriteLogStream

public java.io.PrintStream getWriteLogStream()
Destination for logging the outgoing frames. Defaults to System.out.

Returns:
print stream.

setWriteLogStream

public void setWriteLogStream(java.io.PrintStream val)
Sets write log stream.

Parameters:
val - print stream.

getId

public java.lang.String getId()
Identification string (optional). This string is written to the comment area of generated hexdumps. You may want to set it if mustiple simultaneous connections are being spyied upon to distinguish between them. Default value is empty string.

Returns:
id string.

setId

public void setId(java.lang.String val)
Sets identification sting.

Parameters:
val - id string.

getFormat

public IFormat<java.nio.ByteBuffer> getFormat()
Format to use when converting ByteBuffer s to human-readable form. Defaults to BufferFormat.

Returns:
format.

setFormat

public void setFormat(IFormat<java.nio.ByteBuffer> val)
Sets format.

Parameters:
val - format.

connect

public IStreamer connect(java.lang.String host,
                         int port)
                  throws java.io.IOException
Description copied from interface: IStreamerFactory
Creates a connection (synchronously).

Specified by:
connect in interface IStreamerFactory
Throws:
java.io.IOException


Copyright © 2007 Mike Kroutikov. All Rights Reserved.