Interface NonBlockingInputFeeder

  • All Known Subinterfaces:
    NonBlockingParser
    All Known Implementing Classes:
    NonBlockingParserImpl

    public interface NonBlockingInputFeeder
    Interface used by non-blocking JsonParser to get more input to parse. It is accessed by entity that feeds content to parse; at any given point only one chunk of content can be processed so caller has to take care to only feed more content when existing content has been parsed (which occurs when parser's nextToken is called). Once application using non-blocking parser has no more data to feed it should call endOfInput() to indicate end of logical input stream.
    Author:
    Tatu Saloranta
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void endOfInput()
      Method that should be called after last chunk of data to parse has been fed (with feedInput(byte[], int, int)); can be called regardless of what needMoreInput() returns.
      void feedInput​(byte[] data, int offset, int len)
      Method that can be called to feed more data, if (and only if) needMoreInput() returns true.
      boolean needMoreInput()
      Method called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).
    • Method Detail

      • needMoreInput

        boolean needMoreInput()
        Method called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).
      • feedInput

        void feedInput​(byte[] data,
                       int offset,
                       int len)
                throws java.io.IOException
        Method that can be called to feed more data, if (and only if) needMoreInput() returns true.
        Parameters:
        data - Byte array that contains data to feed: caller must ensure data remains stable until it is fully processed (which is true when needMoreInput() returns true)
        offset - Offset within array where input data to process starts
        len - Length of input data within array to process.
        Throws:
        java.io.IOException - if the state is such that this method should not be called (has not yet consumed existing input data, or has been marked as closed)
      • endOfInput

        void endOfInput()
        Method that should be called after last chunk of data to parse has been fed (with feedInput(byte[], int, int)); can be called regardless of what needMoreInput() returns. After calling this method, no more data can be fed; and parser assumes no more data will be available.