Package pl.gsmservice.gateway.utils
Class BlockingParser<T>
- java.lang.Object
-
- pl.gsmservice.gateway.utils.BlockingParser<T>
-
public final class BlockingParser<T> extends java.lang.ObjectBlocking parser that reads from a Reader and delegates to a StreamingParser.
-
-
Constructor Summary
Constructors Constructor Description BlockingParser(java.io.Reader reader, StreamingParser<T> parser)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying readerstatic BlockingParser<java.lang.String>forJsonLines(java.io.Reader reader)Create a blocking parser for JSON Lines formatstatic BlockingParser<EventStreamMessage>forSSE(java.io.Reader reader)Create a blocking parser for SSE formatbooleanhasNext()Check if there are more results available (either buffered or from reader)java.util.Optional<T>next()Read the next parsed result from the Reader.
-
-
-
Constructor Detail
-
BlockingParser
public BlockingParser(java.io.Reader reader, StreamingParser<T> parser)
-
-
Method Detail
-
next
public java.util.Optional<T> next() throws java.io.IOException
Read the next parsed result from the Reader.- Returns:
- next complete parsed result, or empty if no more data
- Throws:
java.io.IOException- if reading fails
-
hasNext
public boolean hasNext() throws java.io.IOExceptionCheck if there are more results available (either buffered or from reader)- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionClose the underlying reader- Throws:
java.io.IOException
-
forJsonLines
public static BlockingParser<java.lang.String> forJsonLines(java.io.Reader reader)
Create a blocking parser for JSON Lines format
-
forSSE
public static BlockingParser<EventStreamMessage> forSSE(java.io.Reader reader)
Create a blocking parser for SSE format
-
-