Package jadex.commons
Class ListenableStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- jadex.commons.ListenableStream
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.io.Flushable,- java.lang.AutoCloseable
 
 public class ListenableStream extends java.io.OutputStreamA stream that can be listened to.
- 
- 
Field SummaryFields Modifier and Type Field Description protected byte[]bufferThe buffered bytes.protected intlenThe currently used length of the buffer.protected java.util.ListlistenersThe listeners.protected byte[]newlineThe code(s) of the newline character.protected java.io.OutputStreamoutThe super output stream.protected java.lang.StringtypeThe event type to be generated.
 - 
Constructor SummaryConstructors Constructor Description ListenableStream(java.io.OutputStream out, java.lang.String type)Create a new stream.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLineListener(IChangeListener listener)Add a line listener.voidclose()Close the streams.voidflush()Flush the streams.protected voidgenerateEvent()Generate an event for a line and flush the buffer.voidremoveLineListener(IChangeListener listener)Remove a line listener.voidwrite(int b)Write a byte to the stream.
 
- 
- 
- 
Field Detail- 
outprotected java.io.OutputStream out The super output stream.
 - 
typeprotected java.lang.String type The event type to be generated.
 - 
bufferprotected byte[] buffer The buffered bytes.
 - 
lenprotected int len The currently used length of the buffer.
 - 
listenersprotected java.util.List listeners The listeners.
 - 
newlineprotected byte[] newline The code(s) of the newline character.
 
- 
 - 
Method Detail- 
writepublic void write(int b) throws java.io.IOExceptionWrite a byte to the stream.- Specified by:
- writein class- java.io.OutputStream
- Parameters:
- b- The byte.
- Throws:
- java.io.IOException
 
 - 
closepublic void close() throws java.io.IOExceptionClose the streams.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Overrides:
- closein class- java.io.OutputStream
- Throws:
- java.io.IOException
 
 - 
flushpublic void flush() throws java.io.IOExceptionFlush the streams.- Specified by:
- flushin interface- java.io.Flushable
- Overrides:
- flushin class- java.io.OutputStream
- Throws:
- java.io.IOException
 
 - 
addLineListenerpublic void addLineListener(IChangeListener listener) Add a line listener.
 - 
removeLineListenerpublic void removeLineListener(IChangeListener listener) Remove a line listener.
 - 
generateEventprotected void generateEvent() Generate an event for a line and flush the buffer.
 
- 
 
-