calypso.util
Class ByteLineBuffer

java.lang.Object
  |
  +--calypso.util.ByteLineBuffer

public class ByteLineBuffer
extends java.lang.Object

This class is stores data in a private ByteBuf appending new data as needed, and returning line separated data.


Constructor Summary
ByteLineBuffer()
          Constructs an empty ByteLineBuffer.
 
Method Summary
 boolean pullLine(ByteBuf buf)
          Returns a ByteBuf with a line of data which was separated by or any combination.
 void pushBytes(ByteBuf buf)
          Appends data to the end of the internal ByteBuf.
 void pushEOF()
          indicates that the last piece of data is now present.
 void setInputEOL(ByteBuf buf)
          Sets the EOL characters to look for in the incoming stream.
 void setOutputEOL(ByteBuf buf)
          End of line characters & or any combination will be replaced by this string if it is present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteLineBuffer

public ByteLineBuffer()
Constructs an empty ByteLineBuffer.
Method Detail

pushBytes

public void pushBytes(ByteBuf buf)
Appends data to the end of the internal ByteBuf.
Parameters:
buf - data to append to internal buffer

pushEOF

public void pushEOF()
indicates that the last piece of data is now present.

setInputEOL

public void setInputEOL(ByteBuf buf)
Sets the EOL characters to look for in the incoming stream. Setting this to be null will cause it to look for any of , , or . Note that null (the default) could cause up to one extra to be held in the buffer (in the case where the last byte read from the underlying stream was , and no following byte (or EOF) has yet been read.)

setOutputEOL

public void setOutputEOL(ByteBuf buf)
End of line characters & or any combination will be replaced by this string if it is present. Setting this to a zero length string will cause them to be stripped. Setting this to null will cause the EOL characters to be passed through unchanged (the default).
Parameters:
buf - ByteBuf representing EOL replacement string

pullLine

public boolean pullLine(ByteBuf buf)
Returns a ByteBuf with a line of data which was separated by or any combination. Holds the last line in the ByteBuf until pushEOF() is called. If a ByteBuf containing data is sent in, the data is removed.
Parameters:
buf - single line of data in a ByteBuf
Returns:
true if a line was retrieved, false if not