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

io.ebean.service.SpiJsonService Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebean.service;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * JSON service that Ebean is expected to provide.
 *
 * Supports converting between JSON content and simple java Maps/Lists.
 */
public interface SpiJsonService extends BootstrapService {

  /**
   * Write the nested Map/List as json.
   */
  String write(Object object) throws IOException;

  /**
   * Write the nested Map/List as json to the writer.
   */
  void write(Object object, Writer writer) throws IOException;

  /**
   * Write the nested Map/List as json to the jsonGenerator.
   */
  void write(Object object, JsonGenerator jsonGenerator) throws IOException;

  /**
   * Write the collection as json array to the jsonGenerator.
   */
  void writeCollection(Collection collection, JsonGenerator jsonGenerator) throws IOException;

  /**
   * Parse the json and return as a Map additionally specifying if the returned map should
   * be modify aware meaning that it can detect when it has been modified.
   */
  Map parseObject(String json, boolean modifyAware) throws IOException;

  /**
   * Parse the json and return as a Map.
   */
  Map parseObject(String json) throws IOException;

  /**
   * Parse the json and return as a Map taking a reader.
   */
  Map parseObject(Reader reader, boolean modifyAware) throws IOException;

  /**
   * Parse the json and return as a Map taking a reader.
   */
  Map parseObject(Reader reader) throws IOException;

  /**
   * Parse the json and return as a Map taking a JsonParser.
   */
  Map parseObject(JsonParser parser) throws IOException;

  /**
   * Parse the json and return as a Map taking a JsonParser and a starting token.
   * 

* Used when the first token is checked to see if the value is null prior to calling this. *

*/ Map parseObject(JsonParser parser, JsonToken token) throws IOException; /** * Parse the json and return as a modify aware List. */ List parseList(String json, boolean modifyAware) throws IOException; /** * Parse the json and return as a List. */ List parseList(String json) throws IOException; /** * Parse the json and return as a List taking a Reader. */ List parseList(Reader reader) throws IOException; /** * Parse the json and return as a List taking a JsonParser. */ List parseList(JsonParser parser) throws IOException; /** * Parse the json returning as a List taking into account the current token. */ List parseList(JsonParser parser, JsonToken currentToken) throws IOException; /** * Parse the json and return as a List or Map. */ Object parse(String json) throws IOException; /** * Parse the json and return as a List or Map. */ Object parse(Reader reader) throws IOException; /** * Parse the json and return as a List or Map. */ Object parse(JsonParser parser) throws IOException; /** * Parse the json returning a Set that might be modify aware. */ Set parseSet(String json, boolean modifyAware) throws IOException; /** * Parse the json returning as a Set taking into account the current token. */ Set parseSet(JsonParser parser, JsonToken currentToken) throws IOException; }