All Implemented Interfaces:
ByteArrayFeeder, NonBlockingInputFeeder, Versioned, Closeable, AutoCloseable

public class NonBlockingJsonParser extends NonBlockingUtf8JsonParserBase implements ByteArrayFeeder
Non-blocking parser implementation for JSON content that takes its input via byte[] passed.

NOTE: only supports parsing of UTF-8 encoded content (and 7-bit US-ASCII since it is strict subset of UTF-8): other encodings are not supported.

Since:
2.9
  • Constructor Details

  • Method Details

    • getNonBlockingInputFeeder

      public ByteArrayFeeder getNonBlockingInputFeeder()
      Description copied from class: JsonParser
      Method that will either return a feeder instance (if parser uses non-blocking, aka asynchronous access); or null for parsers that use blocking I/O.
      Overrides:
      getNonBlockingInputFeeder in class JsonParser
      Returns:
      Input feeder to use with non-blocking (async) parsing
    • feedInput

      public void feedInput(byte[] buf, int start, int end) throws IOException
      Description copied from interface: ByteArrayFeeder
      Method that can be called to feed more data, if (and only if) NonBlockingInputFeeder.needMoreInput() returns true.
      Specified by:
      feedInput in interface ByteArrayFeeder
      Parameters:
      buf - Byte array that contains data to feed: caller must ensure data remains stable until it is fully processed (which is true when NonBlockingInputFeeder.needMoreInput() returns true)
      start - Offset within array where input data to process starts
      end - Offset after last byte contained in the input array
      Throws:
      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)
    • releaseBuffered

      public int releaseBuffered(OutputStream out) throws IOException
      Description copied from class: JsonParser
      Method that can be called to push back any content that has been read but not consumed by the parser. This is usually done after reading all content of interest using parser. Content is released by writing it to given stream if possible; if underlying input is byte-based it can released, if not (char-based) it can not.
      Specified by:
      releaseBuffered in class NonBlockingJsonParserBase
      Parameters:
      out - OutputStream to which buffered, undecoded content is written to
      Returns:
      -1 if the underlying content source is not byte based (that is, input can not be sent to OutputStream; otherwise number of bytes released (0 if there was nothing to release)
      Throws:
      IOException - if write to stream threw exception
    • getNextSignedByteFromBuffer

      protected byte getNextSignedByteFromBuffer()
      Specified by:
      getNextSignedByteFromBuffer in class NonBlockingUtf8JsonParserBase
      Returns:
      next signed byte from the buffer
    • getNextUnsignedByteFromBuffer

      protected int getNextUnsignedByteFromBuffer()
      Specified by:
      getNextUnsignedByteFromBuffer in class NonBlockingUtf8JsonParserBase
      Returns:
      next unsigned byte from the buffer
    • getByteFromBuffer

      protected byte getByteFromBuffer(int ptr)
      Specified by:
      getByteFromBuffer in class NonBlockingUtf8JsonParserBase
      Parameters:
      ptr - pointer to byte that is required
      Returns:
      byte from the buffer at the given pointer