Class BlockingParser<T>


  • public final class BlockingParser<T>
    extends java.lang.Object
    Blocking parser that reads from a Reader and delegates to a StreamingParser.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the underlying reader
      static BlockingParser<java.lang.String> forJsonLines​(java.io.Reader reader)
      Create a blocking parser for JSON Lines format
      static BlockingParser<EventStreamMessage> forSSE​(java.io.Reader reader)
      Create a blocking parser for SSE format
      boolean hasNext()
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.IOException
        Check if there are more results available (either buffered or from reader)
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Close 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