Skip to content

Add support for char-based NonBlockingInputFeeder #1604

@robtimus

Description

@robtimus

NonBlockingInputFeeder currently has two sub-interfaces, ByteArrayFeeder with implementation NonBlockingByteArrayJsonParser and ByteBufferFeeder with implementation NonBlockingByteBufferJsonParser. These only work with bytes though. It's possible to use NonBlockingByteBufferJsonParser for char[] or CharBuffer by converting the latter to ByteBuffer (StandardCharsets.UTF_8.encode(charBuffer)). However, currentLocation() and currentTokenLocation() return -1 from getCharOffset(), because the counter is only maintained for bytes. That makes it impossible for me to use non-blocking parsing in one of my projects, where the locations are essential.

It would be nice to have the following additional classes and interfaces:

  • interface CharArrayFeeder: a copy of ByteArrayFeeder but for char[]
  • interface CharBufferFeeder: a copy of ByteBufferFeeder but for CharBuffer
  • class NonBlockingCharArrayJsonParser implements CharArrayFeeder
  • class NonBlockingCharBufferJsonParser implements CharBufferFeeder

I see one issue with this however. These two classes would ideally (indirectly) extend NonBlockingJsonParserBase, because that one is "Intermediate base class for non-blocking JSON parsers". That class is written for parsing from bytes though, with fields like _symbols and _pendingBytes, and updating it to also support parsing from chars is probably difficult in a non-breaking way. Maybe someone can think of a nice way to overcome this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions