Class MimeTypeResolver

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      MimeTypeResolver(ImmutableConfig conf)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static String cleanMimeType(String origType) Cleans a MimeType name by removing out the actual MimeType, from a string of the form:
      void reload(ImmutableConfig conf)
      String autoResolveContentType(String typeName, @NotNull() String url, @Nullable() Array<byte> data) A facade interface to trying all the possible mime type resolution strategies available within Tika.
      String getMimeType(String url) Facade interface to Tika's underlying getMimeType method.
      String forName(String name) A facade interface to Tika's underlying forName method.
      String detect(Path path) Facade interface to Tika's underlying getMimeType method.
      String detect(File file) Facade interface to Tika's underlying getMimeType method.
      • Methods inherited from class java.lang.Object

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

      • MimeTypeResolver

        MimeTypeResolver(ImmutableConfig conf)
    • Method Detail

      • cleanMimeType

         static String cleanMimeType(String origType)

        Cleans a MimeType name by removing out the actual MimeType, from a string of the form:

        Parameters:
        origType - The original mime type string to be cleaned.
        Returns:

        The primary type, and subtype, concatenated, e.g., the actual mime type.

      • reload

         void reload(ImmutableConfig conf)
      • autoResolveContentType

         String autoResolveContentType(String typeName, @NotNull() String url, @Nullable() Array<byte> data)

        A facade interface to trying all the possible mime type resolution strategies available within Tika. First, the mime type provided in typeName is cleaned, with cleanMimeType. Then the cleaned mime type is looked up in the underlying Tika MimeTypes registry, by its cleaned name. If the MimeType is found, then that mime type is used, otherwise URL resolution is used to try and determine the mime type. However, if mime.type.magic is enabled in ImmutableConfig, then mime type magic resolution is used to try and obtain a better-than-the-default approximation of the MimeType.

        Parameters:
        typeName - The original mime type, returned from a ProtocolOutput.
        url - The given @see url, that AppConstants was trying to text.
        data - The byte data, returned from the text, if any.
        Returns:

        The correctly, automatically guessed MimeType name.

      • getMimeType

         String getMimeType(String url)

        Facade interface to Tika's underlying getMimeType method.

        Parameters:
        url - A string representation of the document to sense the MimeType for.
        Returns:

        An appropriate MimeType, identified from the given Document url in string form.

      • forName

         String forName(String name)

        A facade interface to Tika's underlying forName method.

        Parameters:
        name - The name of a valid MimeType in the Tika mime registry.
        Returns:

        The object representation of the MimeType, if it exists, or null otherwise.

      • detect

         String detect(Path path)

        Facade interface to Tika's underlying getMimeType method.

        Parameters:
        path - The Path to sense the MimeType for.
        Returns:

        The MimeType of the given File, or null if it cannot be determined.

      • detect

         String detect(File file)

        Facade interface to Tika's underlying getMimeType method.

        Parameters:
        file - The File to sense the MimeType for.
        Returns:

        The MimeType of the given File, or null if it cannot be determined.