Package sonia.scm.io

Interface ContentTypeResolver


public interface ContentTypeResolver
ContentTypeResolver is able to detect the ContentType of files based on their path and (optinally) a few starting bytes. These files do not have to be real files on the file system, but can be hypothetical constructs ("What content type is most probable for a file named like this").
Since:
2.23.0
  • Method Details

    • resolve

      ContentType resolve(String path)
      Detects the ContentType of the given path, by only using path based strategies.
      Parameters:
      path - path of the file
      Returns:
      ContentType of path
    • resolve

      ContentType resolve(String path, byte[] contentPrefix)
      Detects the ContentType of the given path, by using path and content based strategies.
      Parameters:
      path - path of the file
      contentPrefix - first few bytes of the content
      Returns:
      ContentType of path and content prefix
    • findSyntaxModesByLanguage

      default Map<String,String> findSyntaxModesByLanguage(String language)
      Returns a map of syntax highlighting modes such as ace, codemirror or prism by language.
      Parameters:
      language - name of the coding language
      Since:
      2.28.0