java.lang.Object
dev.metaschema.databind.io.ModelDetector
Provides a means to analyze content to determine what type of bound data it
contains.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDescribes the result of detecting which model a resource is described by. -
Constructor Summary
ConstructorsConstructorDescriptionModelDetector(IBindingContext bindingContext) Construct a new format detector using the default configuration.ModelDetector(IBindingContext bindingContext, IConfiguration<DeserializationFeature<?>> configuration) Construct a new format detector using the providedconfiguration. -
Method Summary
Modifier and TypeMethodDescription@Owning ModelDetector.Resultdetect(@Owning InputStream inputStream, URI resource, Format format) Analyzes the data from the providedinputStreamto determine it's model.
-
Constructor Details
-
ModelDetector
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 providedconfiguration.- Parameters:
bindingContext- information about how Java classes are bound to Module definitionsconfiguration- 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 providedinputStreamto determine it's model.Ownership semantics: This method transfers ownership of the input stream to the returned
ModelDetector.Resultobject. The stream is wrapped in aMergedStreamthat 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 parsedformat- 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
-