All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.qson.parser.QsonParser Maven / Gradle / Ivy

package io.quarkus.qson.parser;

import io.quarkus.qson.writer.JsonByteWriter;

import java.io.IOException;
import java.io.InputStream;

public interface QsonParser {
    /**
     * Initial state
     *
     * @return
     */
    ParserState startState();

    /**
     * Get end target on successful parse
     *
     * @param ctx
     * @param 
     * @return
     */
    default
     T getTarget(ParserContext ctx) {
        return ctx.target();
    }

    /**
     * Read object from InputStream
     *
     * @param is
     * @param 
     * @return
     * @throws IOException
     */
    default  T read(InputStream is) throws IOException {
        ByteArrayParserContext ctx = new ByteArrayParserContext(this);
        return ctx.finish(is);
    }

    /**
     * Read object from byte buffer.  Expects fully buffered json.
     *
     * @param bytes
     * @param 
     * @return
     */
    default  T read(byte[] bytes) {
        ByteArrayParserContext ctx = new ByteArrayParserContext(this);
        return ctx.finish(bytes);
    }

    /**
     * Read object from json string.
     *
     * @param string
     * @param 
     * @return
     * @throws IOException
     */
    default  T read(String string) throws IOException {
        return read(string.getBytes(JsonByteWriter.UTF8));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy