Package com.styra.opa.openapi.utils
Class EventStreamReader
- java.lang.Object
-
- com.styra.opa.openapi.utils.EventStreamReader
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class EventStreamReader extends java.lang.Object implements java.lang.AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description EventStreamReader(java.io.InputStream in)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static EventStreamMessage
parseMessage(java.lang.String text)
java.util.Optional<EventStreamMessage>
readMessage()
java.lang.String
readRawMessage()
Returns the event message (lines separated by \n) without the terminating \n\n.
-
-
-
Method Detail
-
readRawMessage
public java.lang.String readRawMessage() throws java.io.IOException
Returns the event message (lines separated by \n) without the terminating \n\n. Returns null when end of stream reached (and may occur with a partially read event message that has not yet been terminated). Characters in comment lines are discarded as read (they are not buffered).- Returns:
- the event message
- Throws:
java.io.IOException
-
readMessage
public java.util.Optional<EventStreamMessage> readMessage() throws java.io.IOException
- Throws:
java.io.IOException
-
parseMessage
public static EventStreamMessage parseMessage(java.lang.String text)
-
close
public void close() throws java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
-