Class DoclingServeClient

java.lang.Object
ai.docling.client.serve.DoclingServeClient
All Implemented Interfaces:
ai.docling.api.serve.DoclingServeApi
Direct Known Subclasses:
DoclingServeJackson2Client, DoclingServeJackson3Client

public abstract class DoclingServeClient extends Object implements ai.docling.api.serve.DoclingServeApi
Abstract class representing a client for interacting with the Docling API.

This class handles the foundational functionality needed to perform HTTP requests to the Docling API, with customizable base URL and HTTP client configurations. It provides abstract methods for JSON serialization and deserialization, allowing implementation-specific customization.

Concrete subclasses must implement readValue(String, Class) and writeValueAsString(Object) for serialization and deserialization behavior.

  • Field Details

    • DEFAULT_BASE_URL

      protected static final URI DEFAULT_BASE_URL
  • Constructor Details

  • Method Details

    • readValue

      protected abstract <T> T readValue(String json, Class<T> valueType)
      Reads and deserializes the given JSON string into an instance of the specified type.
      Type Parameters:
      T - the type of the object to be deserialized
      Parameters:
      json - the JSON string to deserialize; must not be null
      valueType - the Class of the target type; must not be null
      Returns:
      an instance of T deserialized from the provided JSON
      Throws:
      RuntimeException - if the JSON parsing fails
    • writeValueAsString

      protected abstract <T> String writeValueAsString(T value)
      Serializes the given object into its JSON string representation.
      Type Parameters:
      T - the type of the object to serialize
      Parameters:
      value - the object to serialize; must not be null
      Returns:
      the JSON string representation of the given object
      Throws:
      RuntimeException - if serialization fails
    • logRequest

      protected void logRequest(HttpRequest request)
    • logResponse

      protected void logResponse(HttpResponse<String> response, Optional<String> responseBody)
    • execute

      protected <T> T execute(HttpRequest request, Class<T> expectedValueType)
    • getResponse

      protected <T> T getResponse(HttpResponse<String> response, Class<T> expectedReturnType)
    • health

      public ai.docling.api.serve.health.HealthCheckResponse health()
      Specified by:
      health in interface ai.docling.api.serve.DoclingServeApi
    • convertSource

      public ai.docling.api.serve.convert.response.ConvertDocumentResponse convertSource(ai.docling.api.serve.convert.request.ConvertDocumentRequest request)
      Specified by:
      convertSource in interface ai.docling.api.serve.DoclingServeApi