org.abstracthorizon.danube.support.logging
Class DirectionalLoggingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.abstracthorizon.danube.support.logging.LoggingInputStream
          extended by org.abstracthorizon.danube.support.logging.DirectionalLoggingInputStream
All Implemented Interfaces:
Closeable

public class DirectionalLoggingInputStream
extends LoggingInputStream

Outputs reading from the input stream to log output stream showing directional marks ">". Given input stream read bytes are duplicated to log stream.

Author:
Daniel Sendula

Field Summary
protected  boolean flag
          Internal flag to show when to output directional char
 
Fields inherited from class org.abstracthorizon.danube.support.logging.LoggingInputStream
inputStream, logging, logOutputStream, marked, ptr
 
Constructor Summary
DirectionalLoggingInputStream(InputStream inputStream, OutputStream logOutputStream)
          Constructor
 
Method Summary
static boolean output(boolean flag, OutputStream out, char direction, byte[] buf, int off, int len)
          Outputs part of an array scanning it for LF and sending direction chars accodingly
static boolean output(boolean flag, OutputStream out, char direction, int i)
          Outputs a byte making sure that direction character is printed too
 int read()
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class org.abstracthorizon.danube.support.logging.LoggingInputStream
available, close, isLogging, mark, markSupported, read, reset, setLogging, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flag

protected boolean flag
Internal flag to show when to output directional char

Constructor Detail

DirectionalLoggingInputStream

public DirectionalLoggingInputStream(InputStream inputStream,
                                     OutputStream logOutputStream)
Constructor

Parameters:
inputStream - input stream to be logged
logOutputStream - log output stream
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class LoggingInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class LoggingInputStream
Throws:
IOException

output

public static boolean output(boolean flag,
                             OutputStream out,
                             char direction,
                             int i)
                      throws IOException
Outputs a byte making sure that direction character is printed too

Parameters:
flag - flag
out - output stream
direction - direction char
i - byte to be sent to output stream
Returns:
flag
Throws:
IOException - io exception

output

public static boolean output(boolean flag,
                             OutputStream out,
                             char direction,
                             byte[] buf,
                             int off,
                             int len)
                      throws IOException
Outputs part of an array scanning it for LF and sending direction chars accodingly

Parameters:
flag - flag
out - output stream
direction - direction
buf - buffer to be sent to output stream
off - offset in the buffer
len - length of data to be sent
Returns:
flag
Throws:
IOException - io exception


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.