001package io.avaje.jsonb.spi;
002
003import io.avaje.jsonb.JsonReader;
004import io.avaje.jsonb.JsonWriter;
005
006import java.io.*;
007
008/**
009 * Provides the underlying JsonReader and JsonWriter to use.
010 */
011public interface IOAdapter {
012
013  /**
014   * Return the JsonReader given json string content.
015   */
016  JsonReader reader(String json);
017
018  /**
019   * Return the JsonReader given json content as bytes.
020   */
021  JsonReader reader(byte[] json);
022
023  /**
024   * Return the JsonReader given json string content.
025   */
026  JsonReader reader(Reader reader);
027
028  /**
029   * Return the JsonReader given json string content.
030   */
031  JsonReader reader(InputStream inputStream);
032
033  /**
034   * Return the JsonWriter given writer to use.
035   */
036  JsonWriter writer(Writer writer);
037
038  /**
039   * Return the JsonWriter given the outputStream.
040   */
041  JsonWriter writer(OutputStream outputStream);
042
043  /**
044   * Return a JsonWriter for use for writing to json string.
045   */
046  BufferedJsonWriter bufferedWriter();
047
048  /**
049   * Return a JsonWriter to use for writing json to byte array.
050   */
051  BytesJsonWriter bufferedWriterAsBytes();
052
053  /**
054   * Return PropertyNames given the names of properties.
055   * <p>
056   * The PropertyNames can prepare the names for writing such as
057   * escaping quotes and encoding to bytes so that the names can
058   * be written more efficiently.
059   *
060   * @see JsonWriter#names(PropertyNames)
061   * @see JsonWriter#name(int)
062   */
063  PropertyNames properties(String... names);
064}