Package jadex.common
Class ListenableStream
java.lang.Object
java.io.OutputStream
jadex.common.ListenableStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A stream that can be listened to.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]The buffered bytes.protected intThe currently used length of the buffer.protected ListThe listeners.protected byte[]The code(s) of the newline character.protected OutputStreamThe super output stream.protected StringThe event type to be generated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLineListener(IChangeListener listener) Add a line listener.voidclose()Close the streams.voidflush()Flush the streams.protected voidGenerate 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.Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
out
The super output stream. -
type
The event type to be generated. -
buffer
protected byte[] bufferThe buffered bytes. -
len
protected int lenThe currently used length of the buffer. -
listeners
The listeners. -
newline
protected byte[] newlineThe code(s) of the newline character.
-
-
Constructor Details
-
ListenableStream
Create a new stream.- Parameters:
out- The output stream.
-
-
Method Details
-
write
Write a byte to the stream.- Specified by:
writein classOutputStream- Parameters:
b- The byte.- Throws:
IOException
-
close
Close the streams.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
Flush the streams.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
addLineListener
Add a line listener. -
removeLineListener
Remove a line listener. -
generateEvent
protected void generateEvent()Generate an event for a line and flush the buffer.
-