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 int
The currently used length of the buffer.protected List
The listeners.protected byte[]
The code(s) of the newline character.protected OutputStream
The super output stream.protected String
The event type to be generated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLineListener
(IChangeListener listener) Add a line listener.void
close()
Close the streams.void
flush()
Flush the streams.protected void
Generate an event for a line and flush the buffer.void
removeLineListener
(IChangeListener listener) Remove a line listener.void
write
(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:
write
in classOutputStream
- Parameters:
b
- The byte.- Throws:
IOException
-
close
Close the streams.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
Flush the streams.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in 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.
-