com.isti.util
Class LineProcOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.isti.util.LineProcOutputStream
All Implemented Interfaces:
CallBackStringParam, java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
LogOutputStream

public abstract class LineProcOutputStream
extends java.io.OutputStream
implements CallBackStringParam

Title: LineProcOutputStream

Description: Abstract class that can be dropped in, in place of any OutputStream class (stdout for example), to handle character-stream data as lines. A user-supplied call-back method is handed one line of data at a time.

Author:
Hal Schechner 7/9/2003 -- [ET] Modified 'flush()' to only execute "call-back" method if buffer contains data; various minor modifications.

Field Summary
protected  java.lang.String EOL
          String defining what newline char(s) looks like.
protected  int EOL_LEN
          Length of newline char(s).
protected  java.lang.StringBuffer lineBuffer
          Where we keep the current line.
 
Constructor Summary
LineProcOutputStream()
           
 
Method Summary
 void flush()
          Send buffer content to call-back method (if not empty).
 void write(int ch)
          Enters the given character into the output stream.
 
Methods inherited from class java.io.OutputStream
close, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.isti.util.CallBackStringParam
callBackMethod
 

Field Detail

lineBuffer

protected final java.lang.StringBuffer lineBuffer
Where we keep the current line.


EOL

protected final java.lang.String EOL
String defining what newline char(s) looks like.

See Also:
Constant Field Values

EOL_LEN

protected final int EOL_LEN
Length of newline char(s).

Constructor Detail

LineProcOutputStream

public LineProcOutputStream()
Method Detail

write

public void write(int ch)
Enters the given character into the output stream. The characters are buffered until a newline ('\n') character is encountered; then the entire line of characters (including the newline) is sent to the call-back method.

Specified by:
write in class java.io.OutputStream
Parameters:
ch - the character to enter.

flush

public void flush()
Send buffer content to call-back method (if not empty).

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream