Class StreamingParser<T>


  • public final class StreamingParser<T>
    extends java.lang.Object
    Generic streaming parser that handles byte buffer management and delegates format-specific logic to a StreamContentProcessor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<T> add​(java.nio.ByteBuffer inputBuffer)
      Add ByteBuffer data to the parser buffer and extract any complete items.
      java.util.Optional<T> finish()
      Extract any remaining partial content when stream ends.
      static StreamingParser<java.lang.String> forJsonLines()
      Create a streaming parser for JSON Lines format
      static StreamingParser<EventStreamMessage> forSSE()
      Create a streaming parser for SSE format
      boolean hasBufferedData()
      Check if parser has any buffered data
      static boolean matchesPattern​(byte[] data, int pos, int limit, byte... pattern)
      Check if a byte pattern matches at a specific position
      java.util.Optional<T> next()
      Check if there are additional complete items in the buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • add

        public java.util.Optional<T> add​(java.nio.ByteBuffer inputBuffer)
        Add ByteBuffer data to the parser buffer and extract any complete items.
        Parameters:
        inputBuffer - byte data to add (will not be modified)
        Returns:
        next complete parsed result if one becomes available
      • finish

        public java.util.Optional<T> finish()
        Extract any remaining partial content when stream ends.
        Returns:
        final parsed result if there was incomplete data in the buffer
      • next

        public java.util.Optional<T> next()
        Check if there are additional complete items in the buffer.
        Returns:
        next complete parsed result from buffer if available
      • hasBufferedData

        public boolean hasBufferedData()
        Check if parser has any buffered data
      • matchesPattern

        public static boolean matchesPattern​(byte[] data,
                                             int pos,
                                             int limit,
                                             byte... pattern)
        Check if a byte pattern matches at a specific position
      • forJsonLines

        public static StreamingParser<java.lang.String> forJsonLines()
        Create a streaming parser for JSON Lines format