Class ModelDetector

java.lang.Object
dev.metaschema.databind.io.ModelDetector

public class ModelDetector extends Object
Provides a means to analyze content to determine what type of bound data it contains.
  • Constructor Details

    • ModelDetector

      public ModelDetector(@NonNull IBindingContext bindingContext)
      Construct a new format detector using the default configuration.
      Parameters:
      bindingContext - information about how Java classes are bound to Module definitions
    • ModelDetector

      public ModelDetector(@NonNull IBindingContext bindingContext, @NonNull IConfiguration<DeserializationFeature<?>> configuration)
      Construct a new format detector using the provided configuration.
      Parameters:
      bindingContext - information about how Java classes are bound to Module definitions
      configuration - the deserialization configuration
  • Method Details

    • detect

      @NonNull @Owning public @Owning ModelDetector.Result detect(@NonNull @Owning @Owning InputStream inputStream, @NonNull URI resource, @NonNull Format format) throws IOException
      Analyzes the data from the provided inputStream to determine it's model.

      Ownership semantics: This method transfers ownership of the input stream to the returned ModelDetector.Result object. The stream is wrapped in a MergedStream that replays the buffered detection data followed by the remaining stream content. The caller should NOT close the original stream; instead, close the Result object which will close the underlying stream.

      Parameters:
      inputStream - the resource stream to analyze. Ownership is transferred to the returned Result; the caller should not close this stream directly.
      resource - the resource being parsed
      format - the expected format of the data to read
      Returns:
      the analysis result. The caller owns this result and is responsible for closing it, which will close the underlying stream.
      Throws:
      IOException - if an error occurred while reading the resource