Class FormatDetector

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

public class FormatDetector extends Object
Provides a means to analyze content to determine what Format the data is represented as.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Represents the result of format detection, providing access to the detected format and the data stream for further processing.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Construct a new format detector using the default configuration.
     
    FormatDetector(dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> configuration)
    Construct a new format detector using the provided configuration.
    protected
    FormatDetector(dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> configuration, com.fasterxml.jackson.core.JsonFactory... detectors)
    Construct a new format detector using the provided configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    detect(InputStream inputStream)
    Analyzes the data from the provided inputStream to determine it's format.
    detect(URL resource)
    Analyzes the provided resource to determine it's format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FormatDetector

      public FormatDetector()
      Construct a new format detector using the default configuration.
    • FormatDetector

      public FormatDetector(@NonNull dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> configuration)
      Construct a new format detector using the provided configuration.
      Parameters:
      configuration - the deserialization configuration to use for detection
    • FormatDetector

      protected FormatDetector(@NonNull dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> configuration, @NonNull com.fasterxml.jackson.core.JsonFactory... detectors)
      Construct a new format detector using the provided configuration.
      Parameters:
      configuration - the deserialization configuration to use for detection
      detectors - the JSON parser instances to use for format detection
  • Method Details

    • detect

      @NonNull public FormatDetector.Result detect(@NonNull URL resource) throws IOException
      Analyzes the provided resource to determine it's format.
      Parameters:
      resource - the resource to analyze
      Returns:
      the analysis result
      Throws:
      IOException - if an error occurred while reading the resource
    • detect

      @NonNull public FormatDetector.Result detect(@NonNull InputStream inputStream) throws IOException
      Analyzes the data from the provided inputStream to determine it's format.
      Parameters:
      inputStream - the resource stream to analyze
      Returns:
      the analysis result
      Throws:
      IOException - if an error occurred while reading the resource