Module methanol

Interface BodyDecoder.Factory

All Known Implementing Classes:
BrotliBodyDecoderFactory, DeflateBodyDecoderFactory, GzipBodyDecoderFactory
Enclosing interface:
BodyDecoder<T>

public static interface BodyDecoder.Factory
A factory of BodyDecoders for some defined encoding. BodyDecoder.Factory implementations are normally registered as service-providers by means described in the ServiceLoader class.
  • Method Details

    • encoding

      String encoding()
      Returns the encoding used by BodyDecoders created by this factory.
    • create

      <T> BodyDecoder<T> create(HttpResponse.BodySubscriber<T> downstream)
      Creates and returns a BodyDecoder with the given downstream.
      Type Parameters:
      T - the body type
      Parameters:
      downstream - the downstream subscriber
    • create

      <T> BodyDecoder<T> create(HttpResponse.BodySubscriber<T> downstream, Executor executor)
      Creates and returns a BodyDecoder with the given downstream and executor.
      Type Parameters:
      T - the body type
      Parameters:
      downstream - the downstream subscriber
      executor - the decoder's executor
    • installedFactories

      static List<BodyDecoder.Factory> installedFactories()
      Returns an immutable list of the registered factories.
      Throws:
      ServiceConfigurationError - if an error occurs while loading the registered factories
    • installedBindings

      static Map<String,BodyDecoder.Factory> installedBindings()
      Returns an immutable map that case-insensitively maps encodings to their corresponding registered factories. If more than one factory is registered for a given encoding, it is unspecified which one ends up being in the map. However, decoders provided by this module are overridable.
    • getFactory

      static Optional<BodyDecoder.Factory> getFactory(String encoding)
      Returns an Optional containing the factory registered for the given encoding. An empty optional is returned if no such factory exists.
      Parameters:
      encoding - the factory's encoding