Class AsyncJSON.Factory

java.lang.Object
org.eclipse.jetty.util.ajax.AsyncJSON.Factory
Enclosing class:
AsyncJSON

public static class AsyncJSON.Factory extends Object

The factory that creates AsyncJSON instances.

The factory can be configured with custom JSON.Convertors, and with cached strings that will not be allocated if they can be looked up from the cache.

  • Constructor Details

    • Factory

      public Factory()
  • Method Details

    • getArrayConverter

      public Function<List<?>,Object> getArrayConverter()
      Returns:
      the function to customize the Java representation of JSON arrays
      See Also:
    • setArrayConverter

      public void setArrayConverter(Function<List<?>,Object> arrayConverter)

      Sets the function to convert JSON arrays from their default Java representation, a List<Object>, to another Java data structure such as an Object[].

      Parameters:
      arrayConverter - the function to customize the Java representation of JSON arrays
      See Also:
    • isDetailedParseException

      public boolean isDetailedParseException()
      Returns:
      whether a parse failure should report the whole JSON string or just the last chunk
    • setDetailedParseException

      public void setDetailedParseException(boolean detailedParseException)
      Parameters:
      detailedParseException - whether a parse failure should report the whole JSON string or just the last chunk
    • cache

      public boolean cache(String value)
      Parameters:
      value - the string to cache
      Returns:
      whether the value can be cached
    • cached

      protected String cached(ByteBuffer buffer)

      Attempts to return a cached string from the buffer bytes.

      In case of a cache hit, the string is returned and the buffer position updated.

      In case of cache miss, null is returned and the buffer position is left unaltered.

      Parameters:
      buffer - the buffer to lookup the string from
      Returns:
      a cached string or null
    • newAsyncJSON

      public AsyncJSON newAsyncJSON()
      Returns:
      a new parser instance
    • putConvertor

      public void putConvertor(String className, JSON.Convertor convertor)

      Associates the given JSON.Convertor to the given class name.

      Parameters:
      className - the domain class name such as com.acme.Person
      convertor - the JSON.Convertor that converts Map to domain objects
    • removeConvertor

      public JSON.Convertor removeConvertor(String className)

      Removes the JSON.Convertor associated with the given class name.

      Parameters:
      className - the class name associated with the JSON.Convertor
      Returns:
      the JSON.Convertor associated with the class name, or null
    • getConvertor

      public JSON.Convertor getConvertor(String className)

      Returns the JSON.Convertor associated with the given class name, if any.

      Parameters:
      className - the class name associated with the JSON.Convertor
      Returns:
      the JSON.Convertor associated with the class name, or null